From patchwork Fri Mar 23 16:54:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10305149 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 C1E6860384 for ; Fri, 23 Mar 2018 16:54:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B23AC28FDC for ; Fri, 23 Mar 2018 16:54:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4EBC29093; Fri, 23 Mar 2018 16:54:54 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 E939828FDC for ; Fri, 23 Mar 2018 16:54:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752096AbeCWQyx (ORCPT ); Fri, 23 Mar 2018 12:54:53 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50440 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751632AbeCWQyw (ORCPT ); Fri, 23 Mar 2018 12:54:52 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2NGo2Ub021741; Fri, 23 Mar 2018 16:54:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=jO1udt6+gkRok2In+ZT6NHt1CaZPKz+/D92iMdoThos=; b=gs64kMp7sDdO/Iudef+v5U8NcCJBYKf64bkhuzX2CheVPb1OLO4TAvvsey8Pgre3MIoq 5ETGG4rNGCnt8UPkMlDGpScXsPodq0wDoES1PXJh986KJNxkjSUo3r54gNS5/vOP+W9B 5o2Ec1l103Y6nr9Q28hNtl7XpWTksc8bKrbGcQ7HhZxujQ1dY1vWiwPHjUncRW9Vn5EO sjMivoSW68ndMskG+XazXXOLhLal3Psh8fGMqnwFX4a4UpGaINzY3WLzB8YvFxW7nH39 pCpHeSywAjdDFGNsfFWBINtRjD97X93iymCVvumW3UdojYptoKWcd32RlApFl7pOs9QI Lw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2gw5es00pg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Mar 2018 16:54:49 +0000 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 w2NGsmOg017756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Mar 2018 16:54:49 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2NGsmKd029043; Fri, 23 Mar 2018 16:54:48 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Mar 2018 09:54:48 -0700 Subject: [PATCH 4/4] xfs/278: find sfdir inode field prefix From: "Darrick J. Wong" To: eguan@linux.alibaba.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Fri, 23 Mar 2018 09:54:47 -0700 Message-ID: <152182408764.14523.16193613645363841396.stgit@magnolia> In-Reply-To: <152182406249.14523.2186010254497227366.stgit@magnolia> References: <152182406249.14523.2186010254497227366.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8841 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=733 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803200127 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Use the xfs set/get metadata field helpers to detect the correct sfdir field name prefix on v4-v5 filesystems. This enables us to test inode link count corrections on a (deliberately) disconnected directory. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- tests/xfs/278 | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe fstests" 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/tests/xfs/278 b/tests/xfs/278 index b94ee9c..47012a3 100755 --- a/tests/xfs/278 +++ b/tests/xfs/278 @@ -61,17 +61,39 @@ _scratch_unmount echo "Silence is goodness..." +get_sfdir_prefix() { + local dir_ino="$1" + + for prefix in "u.sfdir3" "u.sfdir2" "u3.sfdir3"; do + if [ -n "$(_scratch_xfs_get_metadata_field \ + "${prefix}.hdr.parent.i4" \ + "inode ${dir_ino}")" ]; then + echo "${prefix}" + return 0 + fi + done + _scratch_xfs_db -c "inode ${dir_ino}" -c 'p' >> $seqres.full + return 1 +} +set_ifield() { + _scratch_xfs_set_metadata_field "$1" 0 "inode $2" >> $seqres.full +} + +sfdir_prefix="$(get_sfdir_prefix "$DIR_INO" || \ + _fail "Cannot determine sfdir prefix")" + # Corrupt DIR -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].inumber.i4 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].name 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].offset 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].namelen 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.hdr.parent.i4 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write core.nlinkv2 0" >> $seqres.full + +set_ifield "${sfdir_prefix}.list[0].inumber.i4" "$DIR_INO" +set_ifield "${sfdir_prefix}.list[0].name" "$DIR_INO" +set_ifield "${sfdir_prefix}.list[0].offset" "$DIR_INO" +set_ifield "${sfdir_prefix}.list[0].namelen" "$DIR_INO" +set_ifield "${sfdir_prefix}.hdr.parent.i4" "$DIR_INO" +set_ifield "core.nlinkv2" "$DIR_INO" # Corrupt SUBDIR -_scratch_xfs_db -x -c "inode $SUBDIR_INO" -c "write u.sfdir2.hdr.parent.i4 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $SUBDIR_INO" -c "write core.nlinkv2 0" >> $seqres.full +set_ifield "${sfdir_prefix}.hdr.parent.i4" "$SUBDIR_INO" +set_ifield "core.nlinkv2" "$SUBDIR_INO" echo "===== BEGIN of xfs_repair =====" >> $seqres.full echo "" >>$seqres.full