From patchwork Wed Feb 5 00:46:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11365629 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C559E139A for ; Wed, 5 Feb 2020 00:46:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A415121744 for ; Wed, 5 Feb 2020 00:46:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ESOd+Nie" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727714AbgBEAqX (ORCPT ); Tue, 4 Feb 2020 19:46:23 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45034 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727494AbgBEAqT (ORCPT ); Tue, 4 Feb 2020 19:46:19 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150e3I9124453; Wed, 5 Feb 2020 00:46:17 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-2019-08-05; bh=sjcVntsIVL4zGRPl/H2qMytL1Z6cx0T8c1zR/x23MS4=; b=ESOd+Niewam4i6vUo+xMuZN4Zthk8a/lqg2t4nBYT2gQQLBZW1Hkf6S0ltJLqTH3AHaQ 50HAGyx4HN0ynhcwyY4SPdkYWJDGXccl+qMS16X2WkGQ0T0jmSoeWN7uX1fxH4AwQV1F YzKNI2D5Iw00Jrj0XIHRoCU2XbK8K0lvGdgNnXWSPFmEY1085lm0Xn+KRpCazlnl55Xw nDThUK5eE98SB6d0JmVwy8cwS0uxKZTlDMESVfAcIhrZbaEksQtOKampySzB540csetG Ygcd2QJKzvp2sCQtUohfhkprFTOKB+5NREM2weI2jqXn/96hYnwBEM0vp8YQLPM9nrpE Qw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2xykbp00hb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:46:17 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150cub4165880; Wed, 5 Feb 2020 00:46:16 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2xykbqgc5a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:46:16 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0150kF85010090; Wed, 5 Feb 2020 00:46:15 GMT Received: from localhost (/10.159.250.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Feb 2020 16:46:14 -0800 Subject: [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Tue, 04 Feb 2020 16:46:13 -0800 Message-ID: <158086357391.2079557.7271114884346251108.stgit@magnolia> In-Reply-To: <158086356778.2079557.17601708483399404544.stgit@magnolia> References: <158086356778.2079557.17601708483399404544.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=915 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2002050001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=962 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2002050001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Re-fix the sorting in this file. Signed-off-by: Darrick J. Wong Reviewed-by: Chaitanya Kulkarni Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig --- libxfs/libxfs_api_defs.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index c7fa1607..6e09685b 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -93,6 +93,7 @@ #define xfs_dqblk_repair libxfs_dqblk_repair #define xfs_dquot_verify libxfs_dquot_verify +#define xfs_finobt_calc_reserves libxfs_finobt_calc_reserves #define xfs_free_extent libxfs_free_extent #define xfs_fs_geometry libxfs_fs_geometry #define xfs_highbit32 libxfs_highbit32 @@ -118,13 +119,16 @@ #define xfs_perag_put libxfs_perag_put #define xfs_prealloc_blocks libxfs_prealloc_blocks +#define xfs_read_agf libxfs_read_agf #define xfs_refc_block libxfs_refc_block +#define xfs_refcountbt_calc_reserves libxfs_refcountbt_calc_reserves #define xfs_refcountbt_init_cursor libxfs_refcountbt_init_cursor #define xfs_refcountbt_maxrecs libxfs_refcountbt_maxrecs #define xfs_refcount_get_rec libxfs_refcount_get_rec #define xfs_refcount_lookup_le libxfs_refcount_lookup_le #define xfs_rmap_alloc libxfs_rmap_alloc +#define xfs_rmapbt_calc_reserves libxfs_rmapbt_calc_reserves #define xfs_rmapbt_init_cursor libxfs_rmapbt_init_cursor #define xfs_rmapbt_maxrecs libxfs_rmapbt_maxrecs #define xfs_rmap_compare libxfs_rmap_compare @@ -176,9 +180,6 @@ #define xfs_verify_rtbno libxfs_verify_rtbno #define xfs_zero_extent libxfs_zero_extent -#define xfs_refcountbt_calc_reserves libxfs_refcountbt_calc_reserves -#define xfs_finobt_calc_reserves libxfs_finobt_calc_reserves -#define xfs_rmapbt_calc_reserves libxfs_rmapbt_calc_reserves -#define xfs_read_agf libxfs_read_agf +/* Please keep this list alphabetized. */ #endif /* __LIBXFS_API_DEFS_H__ */ From patchwork Wed Feb 5 00:46:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11365631 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F23514B4 for ; Wed, 5 Feb 2020 00:46:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EA1E21744 for ; Wed, 5 Feb 2020 00:46:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="AAKPz++8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727674AbgBEAq3 (ORCPT ); Tue, 4 Feb 2020 19:46:29 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:33782 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727627AbgBEAq3 (ORCPT ); Tue, 4 Feb 2020 19:46:29 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150eRod103884; Wed, 5 Feb 2020 00:46:25 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-2019-08-05; bh=pZsTRJVzXjcAMsmwaAVS3YjEAyOBOdxUOT/qvTdcVAs=; b=AAKPz++8I79DyJLqTMiJrRqwmdv8qRcjRA8PMbTdVJ2EsL51ZPIwZow+kVFOkC3bfzv/ FDip9p1zfbRMnBS87HWBIg4CPU5cdauu64oiPaFwRBR9D2OvhaJRyb4O/AcF5J8GBc0y mZ4uZHUR7/wbJEb1bfAnn8pY+4lGkj4e+2NB/58oizv0N2ig6QzG7vSt+BcRnsGjufEO ZqkMxRPWBmYivYZ4RC+0eYsMcSXyS2vdBHOf0RhK7j3aUcoJEXXkFyDGoSF7/OfpmLdI mY3ZXfdypEYIth6DHiQkS+qOoaS0OxBakwctB/uZLfKuFaXz47gtx3kRffUmkSynl9k8 bg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2xykbp00kp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:46:25 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150cvLi165904; Wed, 5 Feb 2020 00:46:24 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2xykbqgcds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:46:24 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0150kNBi010114; Wed, 5 Feb 2020 00:46:23 GMT Received: from localhost (/10.159.250.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Feb 2020 16:46:22 -0800 Subject: [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Eric Sandeen Date: Tue, 04 Feb 2020 16:46:20 -0800 Message-ID: <158086358002.2079557.9233731246621270812.stgit@magnolia> In-Reply-To: <158086356778.2079557.17601708483399404544.stgit@magnolia> References: <158086356778.2079557.17601708483399404544.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2002050001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2002050001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong libfrog isn't supposed to depend on libxfs, so don't include the header file in the libfrog source code. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig --- libfrog/fsgeom.c | 4 +++- libfrog/linux.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libfrog/fsgeom.c b/libfrog/fsgeom.c index 19a4911f..bd93924e 100644 --- a/libfrog/fsgeom.c +++ b/libfrog/fsgeom.c @@ -2,7 +2,9 @@ /* * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. */ -#include "libxfs.h" +#include "platform_defs.h" +#include "xfs.h" +#include "bitops.h" #include "fsgeom.h" #include "util.h" diff --git a/libfrog/linux.c b/libfrog/linux.c index 79bd79eb..41a168b4 100644 --- a/libfrog/linux.c +++ b/libfrog/linux.c @@ -9,8 +9,8 @@ #include #include -#include "libxfs_priv.h" -#include "xfs_fs.h" +#include "platform_defs.h" +#include "xfs.h" #include "init.h" extern char *progname; From patchwork Wed Feb 5 00:46:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11365633 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D841139A for ; Wed, 5 Feb 2020 00:46:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B64421582 for ; Wed, 5 Feb 2020 00:46:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RLShm4Fo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727791AbgBEAqc (ORCPT ); Tue, 4 Feb 2020 19:46:32 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45122 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727494AbgBEAqc (ORCPT ); Tue, 4 Feb 2020 19:46:32 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150deCd124168; Wed, 5 Feb 2020 00:46:30 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-2019-08-05; bh=UyanGVnv18tTGVAI6RvxMpneWZd5sZ/AkObhesMMnt4=; b=RLShm4FopeRJdJPSin/HDKO17RnUwPWTUgV2cN1o9qqcYHkBmrUDHG7zRcRnT2tnUu1Y kL0/VG5ABv1YmwIQ6exS0maA0IdzIGF/LOYUHHBGY2NsAGJ6Z4zx/AoC0eVYtsQkCefJ b5XWdMAlbBv0dVDDibjFj5JPek4wfXp0RYjKjGDMKp2sSIp89asbHThtVkoXzZ6eZ1Pg HeitVvI2ed5vI8xWHc17hIQ5AHaNhCLsxfboRPPAEsBfnv/U9aHcqtfOMtECC5UJPxih 7ta518lPzyb6P+f7I5501B0JIHl7oBvEwNReBjIUe2XSDf7s0Dbe0qu+VkbhO5DP4Yfo Jg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2xykbp00hh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:46:30 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150cvK9165952; Wed, 5 Feb 2020 00:46:29 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2xykbqgcky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:46:29 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0150kTqR010867; Wed, 5 Feb 2020 00:46:29 GMT Received: from localhost (/10.159.250.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Feb 2020 16:46:28 -0800 Subject: [PATCH 3/4] xfs_repair: refactor attr root block pointer check From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Tue, 04 Feb 2020 16:46:28 -0800 Message-ID: <158086358798.2079557.6562544272527988911.stgit@magnolia> In-Reply-To: <158086356778.2079557.17601708483399404544.stgit@magnolia> References: <158086356778.2079557.17601708483399404544.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2002050001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2002050001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In process_longform_attr, replace the agcount check with a call to the fsblock verification function in libxfs. Now we can also catch blocks that point to static FS metadata. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig --- repair/attr_repair.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repair/attr_repair.c b/repair/attr_repair.c index 9a44f610..7b26df33 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -980,21 +980,21 @@ process_longform_attr( *repair = 0; bno = blkmap_get(blkmap, 0); - - if ( bno == NULLFSBLOCK ) { + if (bno == NULLFSBLOCK) { if (dip->di_aformat == XFS_DINODE_FMT_EXTENTS && be16_to_cpu(dip->di_anextents) == 0) return(0); /* the kernel can handle this state */ do_warn( _("block 0 of inode %" PRIu64 " attribute fork is missing\n"), ino); - return(1); + return 1; } + /* FIX FOR bug 653709 -- EKN */ - if (mp->m_sb.sb_agcount < XFS_FSB_TO_AGNO(mp, bno)) { + if (!xfs_verify_fsbno(mp, bno)) { do_warn( _("agno of attribute fork of inode %" PRIu64 " out of regular partition\n"), ino); - return(1); + return 1; } bp = libxfs_readbuf(mp->m_dev, XFS_FSB_TO_DADDR(mp, bno), From patchwork Wed Feb 5 00:46:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11365635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24CC3139A for ; Wed, 5 Feb 2020 00:46:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECDFD21744 for ; Wed, 5 Feb 2020 00:46:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qcB2EuPD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727706AbgBEAqi (ORCPT ); Tue, 4 Feb 2020 19:46:38 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45208 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727494AbgBEAqi (ORCPT ); Tue, 4 Feb 2020 19:46:38 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150dOKh123807; Wed, 5 Feb 2020 00:46:36 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-2019-08-05; bh=U63uJNXBMpQY1GkVGlBWoEQsNY2eR9MA/ljxef1JK+U=; b=qcB2EuPD5aL5nOo7lWKW6crMQIZw/+9xb9iRaCfwIEN5A32EE+b2Icvs5rIq3547rhCe KD/uBEzBITKa+5i2DCmZJQOtdaRGsah+and+Kg/k34FsxFS4JhYeuUtrWSijpZoRfU9B 4mCehmSvd2KB4+J0LTE5e+5S38X4unbtt533K6VOfdpT4yQwoDncicqdoL9SZee1kt0M hcg2aX5loesFsftjJaLOWsvbPJLctxI7pD6SK4wOXCuqrlPaqtsf6kA4P0xT3Tb8bhAe XO8cYu9rv+OK1mupxsC/YbS9zXoaDFloQy5oB5TuxOw1z5qZn9iBzLxkSLJCLU/ys37Q Kw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2xykbp00hr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:46:36 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150dhXU115027; Wed, 5 Feb 2020 00:46:35 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2xykc30xb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:46:35 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0150kZKw011111; Wed, 5 Feb 2020 00:46:35 GMT Received: from localhost (/10.159.250.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Feb 2020 16:46:35 -0800 Subject: [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Tue, 04 Feb 2020 16:46:34 -0800 Message-ID: <158086359417.2079557.4428155306169446299.stgit@magnolia> In-Reply-To: <158086356778.2079557.17601708483399404544.stgit@magnolia> References: <158086356778.2079557.17601708483399404544.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2002050001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2002050001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In process_longform_attr, we enforce that the root block of the attribute index must have both forw or back pointers set to zero. Unfortunately, the code that nulls out the pointers is not aware that the root block could be in da3 node format. This leads to corruption of da3 root node blocks because the functions that convert attr3 leaf headers to and from the ondisk structures perform some interpretation of firstused on what they think is an attr1 leaf block. Found by using xfs/402 to fuzz hdr.info.hdr.forw. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/attr_repair.c | 181 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 117 insertions(+), 64 deletions(-) diff --git a/repair/attr_repair.c b/repair/attr_repair.c index 7b26df33..535fcfbb 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -952,6 +952,106 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"), return 0; } +static int +process_longform_leaf_root( + struct xfs_mount *mp, + xfs_ino_t ino, + struct xfs_dinode *dip, + struct blkmap *blkmap, + int *repair, + struct xfs_buf *bp) +{ + struct xfs_attr3_icleaf_hdr leafhdr; + xfs_dahash_t next_hashval; + int badness; + int repairlinks = 0; + + /* + * check sibling pointers in leaf block or root block 0 before + * we have to release the btree block + */ + xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, bp->b_addr); + if (leafhdr.forw != 0 || leafhdr.back != 0) { + if (!no_modify) { + do_warn( +_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), + ino); + repairlinks = 1; + leafhdr.forw = 0; + leafhdr.back = 0; + xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo, bp->b_addr, + &leafhdr); + } else { + do_warn( +_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino); + } + } + + badness = process_leaf_attr_block(mp, bp->b_addr, 0, ino, blkmap, 0, + &next_hashval, repair); + if (badness) { + *repair = 0; + /* the block is bad. lose the attribute fork. */ + libxfs_putbuf(bp); + return 1; + } + + *repair = *repair || repairlinks; + + if (*repair && !no_modify) + libxfs_writebuf(bp, 0); + else + libxfs_putbuf(bp); + + return 0; +} + +static int +process_longform_da_root( + struct xfs_mount *mp, + xfs_ino_t ino, + struct xfs_dinode *dip, + struct blkmap *blkmap, + int *repair, + struct xfs_buf *bp) +{ + struct xfs_da3_icnode_hdr da3_hdr; + int repairlinks = 0; + int error; + + libxfs_da3_node_hdr_from_disk(mp, &da3_hdr, bp->b_addr); + /* + * check sibling pointers in leaf block or root block 0 before + * we have to release the btree block + */ + if (da3_hdr.forw != 0 || da3_hdr.back != 0) { + if (!no_modify) { + do_warn( +_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), + ino); + + repairlinks = 1; + da3_hdr.forw = 0; + da3_hdr.back = 0; + xfs_da3_node_hdr_to_disk(mp, bp->b_addr, &da3_hdr); + } else { + do_warn( +_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino); + } + } + + /* must do this now, to release block 0 before the traversal */ + if ((*repair || repairlinks) && !no_modify) { + *repair = 1; + libxfs_writebuf(bp, 0); + } else + libxfs_putbuf(bp); + error = process_node_attr(mp, ino, dip, blkmap); /* + repair */ + if (error) + *repair = 0; + return error; +} + /* * Start processing for a leaf or fuller btree. * A leaf directory is one where the attribute fork is too big for @@ -963,19 +1063,15 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"), */ static int process_longform_attr( - xfs_mount_t *mp, - xfs_ino_t ino, - xfs_dinode_t *dip, - blkmap_t *blkmap, - int *repair) /* out - 1 if something was fixed */ + struct xfs_mount *mp, + xfs_ino_t ino, + struct xfs_dinode *dip, + struct blkmap *blkmap, + int *repair) /* out - 1 if something was fixed */ { - xfs_attr_leafblock_t *leaf; - xfs_fsblock_t bno; - xfs_buf_t *bp; - xfs_dahash_t next_hashval; - int repairlinks = 0; - struct xfs_attr3_icleaf_hdr leafhdr; - int error; + xfs_fsblock_t bno; + struct xfs_buf *bp; + struct xfs_da_blkinfo *info; *repair = 0; @@ -1015,74 +1111,31 @@ process_longform_attr( return 1; } - /* verify leaf block */ - leaf = bp->b_addr; - xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf); - - /* check sibling pointers in leaf block or root block 0 before - * we have to release the btree block - */ - if (leafhdr.forw != 0 || leafhdr.back != 0) { - if (!no_modify) { - do_warn( - _("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), - ino); - repairlinks = 1; - leafhdr.forw = 0; - leafhdr.back = 0; - xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo, - leaf, &leafhdr); - } else { - do_warn( - _("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino); - } - } - /* * use magic number to tell us what type of attribute this is. * it's possible to have a node or leaf attribute in either an * extent format or btree format attribute fork. */ - switch (leafhdr.magic) { + info = bp->b_addr; + switch (be16_to_cpu(info->magic)) { case XFS_ATTR_LEAF_MAGIC: /* leaf-form attribute */ case XFS_ATTR3_LEAF_MAGIC: - if (process_leaf_attr_block(mp, leaf, 0, ino, blkmap, - 0, &next_hashval, repair)) { - *repair = 0; - /* the block is bad. lose the attribute fork. */ - libxfs_putbuf(bp); - return(1); - } - *repair = *repair || repairlinks; - break; - + return process_longform_leaf_root(mp, ino, dip, blkmap, repair, + bp); case XFS_DA_NODE_MAGIC: /* btree-form attribute */ case XFS_DA3_NODE_MAGIC: - /* must do this now, to release block 0 before the traversal */ - if ((*repair || repairlinks) && !no_modify) { - *repair = 1; - libxfs_writebuf(bp, 0); - } else - libxfs_putbuf(bp); - error = process_node_attr(mp, ino, dip, blkmap); /* + repair */ - if (error) - *repair = 0; - return error; + return process_longform_da_root(mp, ino, dip, blkmap, repair, + bp); default: do_warn( _("bad attribute leaf magic # %#x for dir ino %" PRIu64 "\n"), - be16_to_cpu(leaf->hdr.info.magic), ino); + be16_to_cpu(info->magic), ino); libxfs_putbuf(bp); *repair = 0; - return(1); + return 1; } - if (*repair && !no_modify) - libxfs_writebuf(bp, 0); - else - libxfs_putbuf(bp); - - return(0); /* repair may be set */ + return 0; /* should never get here */ }