From patchwork Wed Dec 7 00:19:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9486705 X-Mozilla-Keys: nonjunk Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sandeen.net X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 X-Spam-HP: BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5,RP_MATCHES_RCVD=-0.1,UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001 X-Original-To: sandeen@sandeen.net Delivered-To: sandeen@sandeen.net Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by sandeen.net (Postfix) with ESMTP id B258C47968F for ; Tue, 6 Dec 2016 18:18:08 -0600 (CST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752817AbcLGATH (ORCPT ); Tue, 6 Dec 2016 19:19:07 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:23743 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752099AbcLGATG (ORCPT ); Tue, 6 Dec 2016 19:19:06 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uB70J31d024136 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 7 Dec 2016 00:19:03 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id uB70J3aP003814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 7 Dec 2016 00:19:03 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uB70J3tt026983; Wed, 7 Dec 2016 00:19:03 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 06 Dec 2016 16:19:02 -0800 Subject: [PATCH 08/11] populate: cache scratch metadata images From: "Darrick J. Wong" To: david@fromorbit.com, eguan@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Tue, 06 Dec 2016 16:19:01 -0800 Message-ID: <148106994166.19334.6295439286918894885.stgit@birch.djwong.org> In-Reply-To: <148106989109.19334.6839386416313318071.stgit@birch.djwong.org> References: <148106989109.19334.6839386416313318071.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Create a helper function to create a populated FS image and dump the metadata into a file on the test device, with the purpose of allowing future (fuzzer) invocations of _populate_fs use the cached metadata to save time. Signed-off-by: Darrick J. Wong --- common/populate | 44 ++++++++++++++++++++++++++++++++++++++++++++ common/rc | 3 ++- 2 files changed, 46 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/common/populate b/common/populate index 74a77a1..0e6bcfd 100644 --- a/common/populate +++ b/common/populate @@ -605,3 +605,47 @@ _scratch_populate() { ;; esac } + +# Populate a scratch FS from scratch or from a cached image. +_scratch_populate_cached() { + POPULATE_METADUMP="${TEST_DIR}/__populate.${FSTYP}" + POPULATE_METADUMP_DESCR="${TEST_DIR}/__populate.${FSTYP}.txt" + + # Don't keep metadata images cached for more 48 hours... + rm -rf "$(find "${POPULATE_METADUMP}" -mtime +2 2>/dev/null)" + + # Throw away cached image if it doesn't match our spec. + meta_descr="FSTYP ${FSTYP} MKFS_OPTIONS ${MKFS_OPTIONS} ARGS $@" + cmp -s "${POPULATE_METADUMP_DESCR}" <(echo "${meta_descr}") || rm -rf "${POPULATE_METADUMP}" + + # Do we have a cached image? + if [ -r "${POPULATE_METADUMP}" ]; then + case "${FSTYP}" in + "xfs") + xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" && return + ;; + "ext2"|"ext3"|"ext4") + e2image -r "${POPULATE_METADUMP}" "${SCRATCH_DEV}" && return + ;; + esac + fi + + # Oh well, just create one from scratch + _scratch_mkfs + echo "${meta_descr}" > "${POPULATE_METADUMP_DESCR}" + case "${FSTYP}" in + "xfs") + _scratch_xfs_populate $@ + _scratch_xfs_populate_check + _scratch_metadump "${POPULATE_METADUMP}" -a -o + ;; + "ext2"|"ext3"|"ext4") + _scratch_ext4_populate $@ + _scratch_ext4_populate_check + e2image -Q "${SCRATCH_DEV}" "${POPULATE_METADUMP}" + ;; + *) + _fail "Don't know how to populate a ${FSTYP} filesystem." + ;; + esac +} diff --git a/common/rc b/common/rc index 2719b23..e5cffd0 100644 --- a/common/rc +++ b/common/rc @@ -413,12 +413,13 @@ _scratch_mkfs_options() _scratch_metadump() { dumpfile=$1 + shift options= [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ options="-l $SCRATCH_LOGDEV" - xfs_metadump $options $SCRATCH_DEV $dumpfile + xfs_metadump $options "$@" $SCRATCH_DEV $dumpfile } _setup_large_ext4_fs()