From patchwork Sat Jan 21 08:10:25 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: 9530101 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 7534D600CA for ; Sat, 21 Jan 2017 08:10:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 638F32842E for ; Sat, 21 Jan 2017 08:10:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 573B428620; Sat, 21 Jan 2017 08:10:33 +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 6564628527 for ; Sat, 21 Jan 2017 08:10:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751307AbdAUIKa (ORCPT ); Sat, 21 Jan 2017 03:10:30 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:20735 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751233AbdAUIKa (ORCPT ); Sat, 21 Jan 2017 03:10:30 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v0L8ARWh018319 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 21 Jan 2017 08:10:28 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v0L8ARos029721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 21 Jan 2017 08:10:27 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v0L8AQcw009013; Sat, 21 Jan 2017 08:10:27 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 21 Jan 2017 00:10:26 -0800 Subject: [PATCH 1/9] populate: create all types of XFS metadata From: "Darrick J. Wong" To: eguan@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Sat, 21 Jan 2017 00:10:25 -0800 Message-ID: <148498622559.17109.10510252598264540682.stgit@birch.djwong.org> In-Reply-To: <148498621936.17109.4249711513404036449.stgit@birch.djwong.org> References: <148498621936.17109.4249711513404036449.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: aserv0021.oracle.com [141.146.126.233] 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 We have three new metadata types -- rmapbt, rtrmapbt, and refcountbt. Ensure that we populate the scratch fs with all three. Signed-off-by: Darrick J. Wong --- common/populate | 97 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 10 deletions(-) -- 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 df6550d..164fdd3 100644 --- a/common/populate +++ b/common/populate @@ -24,6 +24,7 @@ _require_xfs_io_command "falloc" _require_xfs_io_command "fpunch" +_require_test_program "punch-alternating" _require_xfs_db_blocktrash_z_command() { test "${FSTYP}" = "xfs" || _notrun "cannot run xfs_db on ${FSTYP}" @@ -97,6 +98,12 @@ _scratch_xfs_populate() { # Data: + # Fill up the root inode chunk + echo "+ fill root ino chunk" + seq 1 64 | while read f; do + $XFS_IO_PROG -f -c "truncate 0" "${SCRATCH_MNT}/dummy${f}" + done + # Regular files # - FMT_EXTENTS echo "+ extents file" @@ -106,9 +113,7 @@ _scratch_xfs_populate() { echo "+ btree extents file" nr="$((blksz * 2 / 16))" $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" "${SCRATCH_MNT}/S_IFREG.FMT_BTREE" - for i in $(seq 1 2 ${nr}); do - $XFS_IO_PROG -f -c "fpunch $((i * blksz)) ${blksz}" "${SCRATCH_MNT}/S_IFREG.FMT_BTREE" - done + ./src/punch-alternating "${SCRATCH_MNT}/S_IFREG.FMT_BTREE" # Directories # - INLINE @@ -128,6 +133,7 @@ _scratch_xfs_populate() { __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_NODE" "$((16 * dblksz / 40))" true # - BTREE + echo "+ btree dir" __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_BTREE" "$((128 * dblksz / 40))" true # Symlinks @@ -164,13 +170,13 @@ _scratch_xfs_populate() { # FMT_EXTENTS with a remote less-than-a-block value echo "+ attr extents with a remote less-than-a-block value" touch "${SCRATCH_MNT}/ATTR.FMT_EXTENTS_REMOTE3K" - $XFS_IO_PROG -f -c "pwrite -S 0x43 0 3k" "${SCRATCH_MNT}/attrvalfile" > /dev/null + $XFS_IO_PROG -f -c "pwrite -S 0x43 0 $((blksz - 300))" "${SCRATCH_MNT}/attrvalfile" > /dev/null attr -q -s user.remotebtreeattrname "${SCRATCH_MNT}/ATTR.FMT_EXTENTS_REMOTE3K" < "${SCRATCH_MNT}/attrvalfile" # FMT_EXTENTS with a remote block-size value echo "+ attr extents with a remote one-block value" touch "${SCRATCH_MNT}/ATTR.FMT_EXTENTS_REMOTE4K" - $XFS_IO_PROG -f -c "pwrite -S 0x44 0 4k" "${SCRATCH_MNT}/attrvalfile" > /dev/null + $XFS_IO_PROG -f -c "pwrite -S 0x44 0 ${blksz}" "${SCRATCH_MNT}/attrvalfile" > /dev/null attr -q -s user.remotebtreeattrname "${SCRATCH_MNT}/ATTR.FMT_EXTENTS_REMOTE4K" < "${SCRATCH_MNT}/attrvalfile" rm -rf "${SCRATCH_MNT}/attrvalfile" @@ -180,10 +186,43 @@ _scratch_xfs_populate() { $XFS_IO_PROG -f -c 'fsync' "${SCRATCH_MNT}/unused" rm -rf "${SCRATCH_MNT}/unused" + # Free space btree + echo "+ freesp btree" + nr="$((blksz * 2 / 8))" + $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" "${SCRATCH_MNT}/BNOBT" + ./src/punch-alternating "${SCRATCH_MNT}/BNOBT" + + # Reverse-mapping btree + is_rmapbt="$(xfs_info "${SCRATCH_MNT}" | grep -c 'rmapbt=1')" + if [ $is_rmapbt -gt 0 ]; then + echo "+ rmapbt btree" + nr="$((blksz * 2 / 24))" + $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" "${SCRATCH_MNT}/RMAPBT" + ./src/punch-alternating "${SCRATCH_MNT}/RMAPBT" + fi + + # Realtime Reverse-mapping btree + is_rt="$(xfs_info "${SCRATCH_MNT}" | grep -c 'rtextents=[1-9]')" + if [ $is_rmapbt -gt 0 ] && [ $is_rt -gt 0 ]; then + echo "+ rtrmapbt btree" + nr="$((blksz * 2 / 32))" + $XFS_IO_PROG -f -R -c "pwrite -S 0x62 0 $((blksz * nr))" "${SCRATCH_MNT}/RTRMAPBT" + ./src/punch-alternating "${SCRATCH_MNT}/RTRMAPBT" + fi + + # Reference-count btree + is_reflink="$(xfs_info "${SCRATCH_MNT}" | grep -c 'reflink=1')" + if [ $is_reflink -gt 0 ]; then + echo "+ reflink btree" + nr="$((blksz * 2 / 12))" + $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" "${SCRATCH_MNT}/REFCOUNTBT" + cp --reflink=always "${SCRATCH_MNT}/REFCOUNTBT" "${SCRATCH_MNT}/REFCOUNTBT2" + ./src/punch-alternating "${SCRATCH_MNT}/REFCOUNTBT" + fi + # Copy some real files (xfs tests, I guess...) echo "+ real files" - #__populate_fill_fs "${SCRATCH_MNT}" 40 - cp -pRdu --reflink=always "${SCRATCH_MNT}/S_IFREG.FMT_BTREE" "${SCRATCH_MNT}/S_IFREG.FMT_BTREE.REFLINK" 2> /dev/null + __populate_fill_fs "${SCRATCH_MNT}" 5 umount "${SCRATCH_MNT}" } @@ -212,9 +251,7 @@ _scratch_ext4_populate() { echo "+ extent tree file" nr="$((blksz * 2 / 12))" $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" "${SCRATCH_MNT}/S_IFREG.FMT_ETREE" - for i in $(seq 1 2 ${nr}); do - $XFS_IO_PROG -f -c "fpunch $((i * blksz)) ${blksz}" "${SCRATCH_MNT}/S_IFREG.FMT_ETREE" - done + ./src/punch-alternating "${SCRATCH_MNT}/S_IFREG.FMT_ETREE" # Directories # - INLINE @@ -349,6 +386,39 @@ __populate_check_xfs_attr() { esac } +# Check that there's at least one per-AG btree with multiple levels +__populate_check_xfs_agbtree_height() { + bt_type="$1" + nr_ags=$(_scratch_xfs_db -c 'sb 0' -c 'p agcount' | awk '{print $3}') + + case "${bt_type}" in + "bno"|"cnt"|"rmap"|"refcnt") + hdr="agf" + bt_prefix="${bt_type}" + ;; + "ino") + hdr="agi" + bt_prefix="" + ;; + "fino") + hdr="agi" + bt_prefix="free_" + ;; + *) + _fail "Don't know about AG btree ${bt_type}" + ;; + esac + + seq 0 $((nr_ags - 1)) | while read ag; do + bt_level=$(_scratch_xfs_db -c "${hdr} ${ag}" -c "p ${bt_prefix}level" | awk '{print $3}') + if [ "${bt_level}" -gt 1 ]; then + return 100 + fi + done + test $? -eq 100 || _fail "Failed to create ${bt_type} of sufficient height!" + return 1 +} + # Check that populate created all the types of files we wanted _scratch_xfs_populate_check() { _scratch_mount @@ -367,6 +437,9 @@ _scratch_xfs_populate_check() { leaf_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_LEAF")" node_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_NODE")" btree_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_BTREE")" + is_finobt=$(xfs_info "${SCRATCH_MNT}" | grep -c 'finobt=1') + is_rmapbt=$(xfs_info "${SCRATCH_MNT}" | grep -c 'rmapbt=1') + is_reflink=$(xfs_info "${SCRATCH_MNT}" | grep -c 'reflink=1') blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')" @@ -389,6 +462,10 @@ _scratch_xfs_populate_check() { __populate_check_xfs_attr "${node_attr}" "node" __populate_check_xfs_attr "${btree_attr}" "btree" __populate_check_xfs_aformat "${btree_attr}" "btree" + __populate_check_xfs_agbtree_height "bno" + __populate_check_xfs_agbtree_height "cnt" + test $is_rmapbt -ne 0 && __populate_check_xfs_agbtree_height "rmap" + test $is_reflink -ne 0 && __populate_check_xfs_agbtree_height "refcnt" } # Check data fork format of ext4 file