From patchwork Thu Jan 5 01:17:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9498205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40D50606B4 for ; Thu, 5 Jan 2017 01:17:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AAB328339 for ; Thu, 5 Jan 2017 01:17:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FB29283A6; Thu, 5 Jan 2017 01:17:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D80672839B for ; Thu, 5 Jan 2017 01:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935726AbdAEBRq (ORCPT ); Wed, 4 Jan 2017 20:17:46 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:45715 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933960AbdAEBRp (ORCPT ); Wed, 4 Jan 2017 20:17:45 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v051HgRF028696 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Jan 2017 01:17:43 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v051Hgmg005030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 5 Jan 2017 01:17:42 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v051HeEB010615; Thu, 5 Jan 2017 01:17:41 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Jan 2017 17:17:39 -0800 Subject: [PATCH 6/9] populate: cache scratch metadata images From: "Darrick J. Wong" To: eguan@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Wed, 04 Jan 2017 17:17:38 -0800 Message-ID: <148357905878.10436.1866572956612127885.stgit@birch.djwong.org> In-Reply-To: <148357902056.10436.12795484251467155460.stgit@birch.djwong.org> References: <148357902056.10436.12795484251467155460.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 f012173..91a7753 100644 --- a/common/populate +++ b/common/populate @@ -673,3 +673,47 @@ _fill_fs() file_count=$((file_count + 1)) done } + +# 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 46bfb68..6323f54 100644 --- a/common/rc +++ b/common/rc @@ -471,12 +471,13 @@ _scratch_do_mkfs() _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()