From patchwork Mon Oct 26 23:31:59 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: 11858995 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 B2C19921 for ; Mon, 26 Oct 2020 23:32:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 920A4207F7 for ; Mon, 26 Oct 2020 23:32:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="IPxJk54J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406346AbgJZXcE (ORCPT ); Mon, 26 Oct 2020 19:32:04 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:41122 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406297AbgJZXcE (ORCPT ); Mon, 26 Oct 2020 19:32:04 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNPvE6177195; Mon, 26 Oct 2020 23:32:02 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-2020-01-29; bh=QRfDRbDjPEkgXHzDFrX8ErWZ2zWlsdQpw5tpqo35YpI=; b=IPxJk54JVfKyDA8oSqpaH4BVEWPgCfNZp8Vq1B4qSWj+xLjTWMVWljAYay8Vll5qaZcH BcsFMo2AcgxbS86fK+8i0b08i5dDJKWMWDroL7hbO6IEINxqPr9SM8kyBC0f1GtXAaOq D4eOStOY5fwcjVJutmGQg/Dj1V++UBaJIuKSR7WltG+nG1NU3s04hInFf/vr6+n2C/ya rGYjdfAcB1vRjDT8IGemjHHkpG/vK6ruNlMdm4G8sioUYQ7c0sFdNxh1F0CEnPt1NFXC tV98ZJbwXm/LkKqTObzE1SJeWiGLs1AcJLfYWypVxhlQKxkCHwqe7v1WafCXWFuOIl3+ tA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 34c9saqcsy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Oct 2020 23:32:02 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNPxSQ110493; Mon, 26 Oct 2020 23:32:02 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 34cx5wfqea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Oct 2020 23:32:02 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09QNW1uS004549; Mon, 26 Oct 2020 23:32:01 GMT Received: from localhost (/10.159.145.170) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Oct 2020 16:32:00 -0700 Subject: [PATCH 1/5] mkfs: allow users to specify rtinherit=0 From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Oct 2020 16:31:59 -0700 Message-ID: <160375511989.879169.8816363379781873320.stgit@magnolia> In-Reply-To: <160375511371.879169.3659553317719857738.stgit@magnolia> References: <160375511371.879169.3659553317719857738.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 clxscore=1015 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong mkfs has quite a few boolean options that can be specified in several ways: "option=1" (turn it on), "option" (turn it on), or "option=0" (turn it off). For whatever reason, rtinherit sticks out as the only mkfs parameter that doesn't behave that way. Let's make it behave the same as all the other boolean variables. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Eric Sandeen Reviewed-by: Christoph Hellwig --- mkfs/xfs_mkfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 8fe149d74b0a..908d520df909 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -349,7 +349,7 @@ static struct opt_params dopts = { }, { .index = D_RTINHERIT, .conflicts = { { NULL, LAST_CONFLICT } }, - .minval = 1, + .minval = 0, .maxval = 1, .defaultval = 1, }, @@ -1429,6 +1429,8 @@ data_opts_parser( case D_RTINHERIT: if (getnum(value, opts, subopt)) cli->fsx.fsx_xflags |= FS_XFLAG_RTINHERIT; + else + cli->fsx.fsx_xflags &= ~FS_XFLAG_RTINHERIT; break; case D_PROJINHERIT: cli->fsx.fsx_projid = getnum(value, opts, subopt); From patchwork Mon Oct 26 23:32:05 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: 11859005 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 A6414921 for ; Mon, 26 Oct 2020 23:32:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B8A620878 for ; Mon, 26 Oct 2020 23:32:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="0bjFxqEn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406350AbgJZXcS (ORCPT ); Mon, 26 Oct 2020 19:32:18 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:41292 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406297AbgJZXcR (ORCPT ); Mon, 26 Oct 2020 19:32:17 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNPI5o177109; Mon, 26 Oct 2020 23:32:16 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-2020-01-29; bh=yl4CouYa+M0qURVPVz3diPwJMMwTBvS+AAPV7GvCDT8=; b=0bjFxqEnQ/lA3aV4SNEF+jTYCjmHlzWCQ2cdqif2JZNuNElfaruBpzahJI/JYSvyTmnq +CjzF5rSRGwVBcFFYo39nhYDnGOeYvWfpWQAcy04TQ6zRubapOqUfpboT1tUiksU/7X9 wN1NHOqRdDwOJXTY7Yj5LK8uBpXbqVUvtNfAQ1eHJx6F87B8sjHs5O5Wud3OoTib4gxY WvHH5cRZzBw6EErzSqBMnl1EAThmmIlDggJy7lahsRdFaC6mHI9qkXK7iyl0JXXcRxH5 hlTyOLmnvG3mmX1lH7UdLI0g9W0y2O8YS6wy86Qvp+EjVffZJCopJ7uUAB0mRE9pGm/Y 2w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 34c9saqctm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Oct 2020 23:32:16 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNQEeN032501; Mon, 26 Oct 2020 23:32:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 34cx1q29y2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Oct 2020 23:32:15 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09QNWE6n004683; Mon, 26 Oct 2020 23:32:14 GMT Received: from localhost (/10.159.145.170) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Oct 2020 16:32:06 -0700 Subject: [PATCH 2/5] xfs: remove unnecessary parameter from scrub_scan_estimate_blocks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Oct 2020 16:32:05 -0700 Message-ID: <160375512596.879169.13683347692314634844.stgit@magnolia> In-Reply-To: <160375511371.879169.3659553317719857738.stgit@magnolia> References: <160375511371.879169.3659553317719857738.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=2 malwarescore=0 mlxlogscore=999 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 clxscore=1015 suspectscore=2 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The only caller that cares about the file counts uses it to compute the number of files used, so return that and save a parameter. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig --- scrub/fscounters.c | 8 +++----- scrub/fscounters.h | 2 +- scrub/phase6.c | 7 +++---- scrub/phase7.c | 5 +---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/scrub/fscounters.c b/scrub/fscounters.c index e9901fcdf6df..9a240d49477b 100644 --- a/scrub/fscounters.c +++ b/scrub/fscounters.c @@ -116,7 +116,7 @@ scrub_count_all_inodes( } /* - * Estimate the number of blocks and inodes in the filesystem. Returns 0 + * Estimate the number of blocks and used inodes in the filesystem. Returns 0 * or a positive error number. */ int @@ -126,8 +126,7 @@ scrub_scan_estimate_blocks( unsigned long long *d_bfree, unsigned long long *r_blocks, unsigned long long *r_bfree, - unsigned long long *f_files, - unsigned long long *f_free) + unsigned long long *f_files_used) { struct xfs_fsop_counts fc; int error; @@ -141,8 +140,7 @@ scrub_scan_estimate_blocks( *d_bfree = fc.freedata; *r_blocks = ctx->mnt.fsgeom.rtblocks; *r_bfree = fc.freertx; - *f_files = fc.allocino; - *f_free = fc.freeino; + *f_files_used = fc.allocino - fc.freeino; return 0; } diff --git a/scrub/fscounters.h b/scrub/fscounters.h index 1fae58a6b287..13bd9967f004 100644 --- a/scrub/fscounters.h +++ b/scrub/fscounters.h @@ -9,7 +9,7 @@ int scrub_scan_estimate_blocks(struct scrub_ctx *ctx, unsigned long long *d_blocks, unsigned long long *d_bfree, unsigned long long *r_blocks, unsigned long long *r_bfree, - unsigned long long *f_files, unsigned long long *f_free); + unsigned long long *f_files_used); int scrub_count_all_inodes(struct scrub_ctx *ctx, uint64_t *count); #endif /* XFS_SCRUB_FSCOUNTERS_H_ */ diff --git a/scrub/phase6.c b/scrub/phase6.c index 8d976732d8e1..87828b60fbed 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -719,12 +719,11 @@ phase6_estimate( unsigned long long d_bfree; unsigned long long r_blocks; unsigned long long r_bfree; - unsigned long long f_files; - unsigned long long f_free; + unsigned long long dontcare; int ret; - ret = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, - &r_blocks, &r_bfree, &f_files, &f_free); + ret = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, &r_blocks, + &r_bfree, &dontcare); if (ret) { str_liberror(ctx, ret, _("estimating verify work")); return ret; diff --git a/scrub/phase7.c b/scrub/phase7.c index 96876f7c0596..bc652ab6f44a 100644 --- a/scrub/phase7.c +++ b/scrub/phase7.c @@ -111,8 +111,6 @@ phase7_func( unsigned long long d_bfree; unsigned long long r_blocks; unsigned long long r_bfree; - unsigned long long f_files; - unsigned long long f_free; bool complain; int ip; int error; @@ -160,7 +158,7 @@ phase7_func( } error = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, &r_blocks, - &r_bfree, &f_files, &f_free); + &r_bfree, &used_files); if (error) { str_liberror(ctx, error, _("estimating verify work")); return error; @@ -177,7 +175,6 @@ phase7_func( /* Report on what we found. */ used_data = cvt_off_fsb_to_b(&ctx->mnt, d_blocks - d_bfree); used_rt = cvt_off_fsb_to_b(&ctx->mnt, r_blocks - r_bfree); - used_files = f_files - f_free; stat_data = totalcount.dbytes; stat_rt = totalcount.rbytes; From patchwork Mon Oct 26 23:32:12 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: 11859001 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 5933A1130 for ; Mon, 26 Oct 2020 23:32:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C5D420809 for ; Mon, 26 Oct 2020 23:32:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="PzGeFeW3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406348AbgJZXcP (ORCPT ); Mon, 26 Oct 2020 19:32:15 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:41270 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406297AbgJZXcP (ORCPT ); Mon, 26 Oct 2020 19:32:15 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNPwg7177218; Mon, 26 Oct 2020 23:32:14 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-2020-01-29; bh=7UGFDoNAnO5qtszXy53gLFVdPZvrwxe7IrNeSFrFge8=; b=PzGeFeW3gPgZLt8I7KO5+RhJUWffNRQUUiqv5X+OpGogJLEWGGCTWTG3r6Dh7AWMYKrD uZyKV7jBnSpf2XYG5Rct4nP/u8l0nJY4sW8uFO9h3Xy//ckRiAR1b0UZS3Pz5ez7XdT+ LZWQeuNS9byE269bjkgcBv8FMJmtNxDOHt1x/Voxwargs29XZpDRyK0oVIuNTqiIGMjS Hg7k45xdxnDYOk2NVdx++lPyksSfE4jftZw+9kZvx/LEAy6Lqsc5vO5DgzzQ8eNG1dF4 qkAKmaB2k8Lpf2mE+6INQTqM9hG8Leeoa6FB2rfOmpLa98e6iZ87Ew1gSiP2l7piVY+X dQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 34c9saqctk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Oct 2020 23:32:14 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNQN6e058335; Mon, 26 Oct 2020 23:32:13 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 34cwukr73x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Oct 2020 23:32:13 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09QNWDrJ006563; Mon, 26 Oct 2020 23:32:13 GMT Received: from localhost (/10.159.145.170) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Oct 2020 16:32:12 -0700 Subject: [PATCH 3/5] xfs_db: report ranges of invalid rt blocks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Oct 2020 16:32:12 -0700 Message-ID: <160375513208.879169.14762082637245127153.stgit@magnolia> In-Reply-To: <160375511371.879169.3659553317719857738.stgit@magnolia> References: <160375511371.879169.3659553317719857738.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 clxscore=1015 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Copy-pasta the block range reporting code from check_range into check_rrange so that we don't flood stdout with a ton of low value messages when a bit flips somewhere in rt metadata. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig --- db/check.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/db/check.c b/db/check.c index 553249dc9a41..5aede6cca15c 100644 --- a/db/check.c +++ b/db/check.c @@ -1569,19 +1569,46 @@ check_rootdir(void) } } +static inline void +report_rrange( + xfs_rfsblock_t low, + xfs_rfsblock_t high) +{ + if (low == high) + dbprintf(_("rtblock %llu out of range\n"), low); + else + dbprintf(_("rtblocks %llu..%llu out of range\n"), low, high); +} + static int check_rrange( xfs_rfsblock_t bno, xfs_extlen_t len) { xfs_extlen_t i; + xfs_rfsblock_t low = 0; + xfs_rfsblock_t high = 0; + bool valid_range = false; + int cur, prev = 0; if (bno + len - 1 >= mp->m_sb.sb_rblocks) { for (i = 0; i < len; i++) { - if (!sflag || CHECK_BLIST(bno + i)) - dbprintf(_("rtblock %llu out of range\n"), - bno + i); + cur = !sflag || CHECK_BLIST(bno + i) ? 1 : 0; + if (cur == 1 && prev == 0) { + low = high = bno + i; + valid_range = true; + } else if (cur == 0 && prev == 0) { + /* Do nothing */ + } else if (cur == 0 && prev == 1) { + report_rrange(low, high); + valid_range = false; + } else if (cur == 1 && prev == 1) { + high = bno + i; + } + prev = cur; } + if (valid_range) + report_rrange(low, high); error++; return 0; } From patchwork Mon Oct 26 23:32:18 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: 11859009 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 0E1D41130 for ; Mon, 26 Oct 2020 23:32:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2B8020732 for ; Mon, 26 Oct 2020 23:32:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="HKvx3sgy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406385AbgJZXc0 (ORCPT ); Mon, 26 Oct 2020 19:32:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:53124 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406383AbgJZXc0 (ORCPT ); Mon, 26 Oct 2020 19:32:26 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNQKwt165355; Mon, 26 Oct 2020 23:32:24 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-2020-01-29; bh=9igQvsfjybZ3UAyjftY49uO7d+W0gsXiUS5oidEbLq4=; b=HKvx3sgypv8jaS91erWY6gQjhzPbeGSD1sSLTsyioeLalv9yybxaEf7LkReLRQtUF+Hj e6qJYOrPM5jthsPH2EI0KXzBcXApzXVYk0mBnNX+RJ4EBumv6LUNtj4aPVt1Ait7FQKS YKzl4PAeDCwDaY7Vmst2g4wpqYYToHgaCBA3V8uLGXjjUL0XR8fmeE02p0RvqTuLSw8g zBGizoNyM2DJOPfUlsRA7IZSx8hgY+cYEm+dnZsHnuo4JPzYz3TfEnV327lymrD7eHeV LWi0w3fwFp23fg4MdNYu560IzuLRmp6+wALj7wzKI0GKo81z0ItTzwFzcVV2KIHLH3Qv 9w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 34dgm3vufg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Oct 2020 23:32:24 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNQQ97032815; Mon, 26 Oct 2020 23:32:23 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 34cx1q2a1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Oct 2020 23:32:23 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09QNWM5B006595; Mon, 26 Oct 2020 23:32:22 GMT Received: from localhost (/10.159.145.170) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Oct 2020 16:32:19 -0700 Subject: [PATCH 4/5] xfs_repair: skip the rmap and refcount btree checks when the levels are garbage From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Oct 2020 16:32:18 -0700 Message-ID: <160375513815.879169.8550751453198927018.stgit@magnolia> In-Reply-To: <160375511371.879169.3659553317719857738.stgit@magnolia> References: <160375511371.879169.3659553317719857738.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 impostorscore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In validate_ag[fi], we should check that the levels of the rmap and refcount btrees are valid. If they aren't, we need to tell phase4 to skip the comparison between the existing and incore rmap and refcount data. The comparison routines use libxfs btree cursors, which assume that the caller validated bc_nlevels and will corrupt memory if we load a btree cursor with a garbage level count. This was found by examing a core dump from a failed xfs/086 invocation. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig --- repair/scan.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/repair/scan.c b/repair/scan.c index 42b299f75067..2a38ae5197c6 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -2279,23 +2279,31 @@ validate_agf( if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { struct rmap_priv priv; + unsigned int levels; memset(&priv.high_key, 0xFF, sizeof(priv.high_key)); priv.high_key.rm_blockcount = 0; priv.agcnts = agcnts; priv.last_rec.rm_owner = XFS_RMAP_OWN_UNKNOWN; priv.nr_blocks = 0; + + levels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]); + if (levels >= XFS_BTREE_MAXLEVELS) { + do_warn(_("bad levels %u for rmapbt root, agno %d\n"), + levels, agno); + rmap_avoid_check(); + } + bno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_RMAP]); if (libxfs_verify_agbno(mp, agno, bno)) { - scan_sbtree(bno, - be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]), - agno, 0, scan_rmapbt, 1, XFS_RMAP_CRC_MAGIC, - &priv, &xfs_rmapbt_buf_ops); + scan_sbtree(bno, levels, agno, 0, scan_rmapbt, 1, + XFS_RMAP_CRC_MAGIC, &priv, + &xfs_rmapbt_buf_ops); if (be32_to_cpu(agf->agf_rmap_blocks) != priv.nr_blocks) do_warn(_("bad rmapbt block count %u, saw %u\n"), priv.nr_blocks, be32_to_cpu(agf->agf_rmap_blocks)); - } else { + } else { do_warn(_("bad agbno %u for rmapbt root, agno %d\n"), bno, agno); rmap_avoid_check(); @@ -2303,20 +2311,28 @@ validate_agf( } if (xfs_sb_version_hasreflink(&mp->m_sb)) { + unsigned int levels; + + levels = be32_to_cpu(agf->agf_refcount_level); + if (levels >= XFS_BTREE_MAXLEVELS) { + do_warn(_("bad levels %u for refcountbt root, agno %d\n"), + levels, agno); + refcount_avoid_check(); + } + bno = be32_to_cpu(agf->agf_refcount_root); if (libxfs_verify_agbno(mp, agno, bno)) { struct refc_priv priv; memset(&priv, 0, sizeof(priv)); - scan_sbtree(bno, - be32_to_cpu(agf->agf_refcount_level), - agno, 0, scan_refcbt, 1, XFS_REFC_CRC_MAGIC, - &priv, &xfs_refcountbt_buf_ops); + scan_sbtree(bno, levels, agno, 0, scan_refcbt, 1, + XFS_REFC_CRC_MAGIC, &priv, + &xfs_refcountbt_buf_ops); if (be32_to_cpu(agf->agf_refcount_blocks) != priv.nr_blocks) do_warn(_("bad refcountbt block count %u, saw %u\n"), priv.nr_blocks, be32_to_cpu(agf->agf_refcount_blocks)); - } else { + } else { do_warn(_("bad agbno %u for refcntbt root, agno %d\n"), bno, agno); refcount_avoid_check(); From patchwork Mon Oct 26 23:32:24 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: 11859043 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 04302921 for ; Mon, 26 Oct 2020 23:34:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D946020872 for ; Mon, 26 Oct 2020 23:34:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YEkhw7Dh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406540AbgJZXe2 (ORCPT ); Mon, 26 Oct 2020 19:34:28 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:42948 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406526AbgJZXe2 (ORCPT ); Mon, 26 Oct 2020 19:34:28 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNPwgF177218; Mon, 26 Oct 2020 23:34:26 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-2020-01-29; bh=3VX5HxL8Xd8Mq98QR14M32nsPvNJBTOlzJe8A8FBjL8=; b=YEkhw7DhZ/4yjzQ8U76eObyAXjtsW+3OVwseOwvx8FVxrLDq1A2jB7kIB+ITEe/5K+hX pAsChoG+EXe+dCHd8I0AcE9HKRVgysJ+gFwjjXjbbyM104vmH+DPV9RClcLEGCc3Hank +bwS2gAAIbzopIcHIjYuopzoOUBGw/LtU37qvIIgWqDTUDW0dAHfqH1HcbAlSFd3oDhn dow2aEVTMbZlmzYI2VANcj789gKdlnW2SJ/i0PO3o3nyKM3aJopbD82LLcYHSDm6SY33 mi2FcxVYB3KLRBItQUiaTksDF6AA0nb50Wy96ZMuYqo25grgmZ0NlGYFiwwyvae6DMv3 zA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 34c9saqd1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Oct 2020 23:34:26 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09QNPxBS110452; Mon, 26 Oct 2020 23:32:25 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 34cx5wfqqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Oct 2020 23:32:25 +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 09QNWPix006610; Mon, 26 Oct 2020 23:32:25 GMT Received: from localhost (/10.159.145.170) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Oct 2020 16:32:25 -0700 Subject: [PATCH 5/5] xfs_repair: correctly detect partially written extents From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Oct 2020 16:32:24 -0700 Message-ID: <160375514426.879169.1166063350727282652.stgit@magnolia> In-Reply-To: <160375511371.879169.3659553317719857738.stgit@magnolia> References: <160375511371.879169.3659553317719857738.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 mlxlogscore=999 suspectscore=2 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9786 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 clxscore=1015 suspectscore=2 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010260153 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Recently, I was able to create a realtime file with a 16b extent size and the following data fork mapping: data offset 0 startblock 144 (0/144) count 3 flag 0 data offset 3 startblock 147 (0/147) count 3 flag 1 data offset 6 startblock 150 (0/150) count 10 flag 0 Notice how we have a written extent, then an unwritten extent, and then another written extent. The current code in process_rt_rec trips over that third extent, because repair only knows not to complain about inuse extents if the mapping was unwritten. This loop logic is confusing, because it tries to do too many things. Move the phase3 and phase4 code to separate helper functions, then isolate the code that handles a mapping that starts in the middle of an rt extent so that it's clearer what's going on. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig --- repair/dinode.c | 180 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 112 insertions(+), 68 deletions(-) diff --git a/repair/dinode.c b/repair/dinode.c index c89f21e08373..028a23cd5c8c 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -176,76 +176,69 @@ verify_dfsbno_range( return XR_DFSBNORANGE_VALID; } + static int -process_rt_rec( +process_rt_rec_dups( struct xfs_mount *mp, - struct xfs_bmbt_irec *irec, xfs_ino_t ino, - xfs_rfsblock_t *tot, - int check_dups) + struct xfs_bmbt_irec *irec) { - xfs_fsblock_t b, lastb; + xfs_fsblock_t b; xfs_rtblock_t ext; - int state; - int pwe; /* partially-written extent */ - /* - * check numeric validity of the extent - */ - if (!libxfs_verify_rtbno(mp, irec->br_startblock)) { - do_warn( -_("inode %" PRIu64 " - bad rt extent start block number %" PRIu64 ", offset %" PRIu64 "\n"), - ino, - irec->br_startblock, - irec->br_startoff); - return 1; - } - - lastb = irec->br_startblock + irec->br_blockcount - 1; - if (!libxfs_verify_rtbno(mp, lastb)) { - do_warn( -_("inode %" PRIu64 " - bad rt extent last block number %" PRIu64 ", offset %" PRIu64 "\n"), - ino, - lastb, - irec->br_startoff); - return 1; - } - if (lastb < irec->br_startblock) { - do_warn( -_("inode %" PRIu64 " - bad rt extent overflows - start %" PRIu64 ", " - "end %" PRIu64 ", offset %" PRIu64 "\n"), - ino, - irec->br_startblock, - lastb, - irec->br_startoff); - return 1; - } - - /* - * set the appropriate number of extents - * this iterates block by block, this can be optimised using extents - */ - for (b = irec->br_startblock; b < irec->br_startblock + - irec->br_blockcount; b += mp->m_sb.sb_rextsize) { + for (b = rounddown(irec->br_startblock, mp->m_sb.sb_rextsize); + b < irec->br_startblock + irec->br_blockcount; + b += mp->m_sb.sb_rextsize) { ext = (xfs_rtblock_t) b / mp->m_sb.sb_rextsize; - pwe = irec->br_state == XFS_EXT_UNWRITTEN && - (b % mp->m_sb.sb_rextsize != 0); - - if (check_dups == 1) { - if (search_rt_dup_extent(mp, ext) && !pwe) { - do_warn( + if (search_rt_dup_extent(mp, ext)) { + do_warn( _("data fork in rt ino %" PRIu64 " claims dup rt extent," - "off - %" PRIu64 ", start - %" PRIu64 ", count %" PRIu64 "\n"), - ino, - irec->br_startoff, - irec->br_startblock, - irec->br_blockcount); - return 1; - } - continue; +"off - %" PRIu64 ", start - %" PRIu64 ", count %" PRIu64 "\n"), + ino, + irec->br_startoff, + irec->br_startblock, + irec->br_blockcount); + return 1; } + } + return 0; +} + +static int +process_rt_rec_state( + struct xfs_mount *mp, + xfs_ino_t ino, + struct xfs_bmbt_irec *irec) +{ + xfs_fsblock_t b = irec->br_startblock; + xfs_rtblock_t ext; + int state; + + do { + ext = (xfs_rtblock_t)b / mp->m_sb.sb_rextsize; state = get_rtbmap(ext); + + if ((b % mp->m_sb.sb_rextsize) != 0) { + /* + * We are midway through a partially written extent. + * If we don't find the state that gets set in the + * other clause of this loop body, then we have a + * partially *mapped* rt extent and should complain. + */ + if (state != XR_E_INUSE) + do_error( +_("data fork in rt inode %" PRIu64 " found invalid rt extent %"PRIu64" state %d at rt block %"PRIu64"\n"), + ino, ext, state, b); + b = roundup(b, mp->m_sb.sb_rextsize); + continue; + } + + /* + * This is the start of an rt extent. Set the extent state if + * nobody else has claimed the extent, or complain if there are + * conflicting states. + */ switch (state) { case XR_E_FREE: case XR_E_UNKNOWN: @@ -253,32 +246,83 @@ _("data fork in rt ino %" PRIu64 " claims dup rt extent," break; case XR_E_BAD_STATE: do_error( -_("bad state in rt block map %" PRIu64 "\n"), +_("bad state in rt extent map %" PRIu64 "\n"), ext); case XR_E_FS_MAP: case XR_E_INO: case XR_E_INUSE_FS: do_error( -_("data fork in rt inode %" PRIu64 " found metadata block %" PRIu64 " in rt bmap\n"), +_("data fork in rt inode %" PRIu64 " found rt metadata extent %" PRIu64 " in rt bmap\n"), ino, ext); case XR_E_INUSE: - if (pwe) - break; - /* fall through */ case XR_E_MULT: set_rtbmap(ext, XR_E_MULT); do_warn( -_("data fork in rt inode %" PRIu64 " claims used rt block %" PRIu64 "\n"), - ino, ext); +_("data fork in rt inode %" PRIu64 " claims used rt extent %" PRIu64 "\n"), + ino, b); return 1; case XR_E_FREE1: default: do_error( -_("illegal state %d in rt block map %" PRIu64 "\n"), - state, b); +_("illegal state %d in rt extent %" PRIu64 "\n"), + state, ext); } + b += mp->m_sb.sb_rextsize; + } while (b < irec->br_startblock + irec->br_blockcount); + + return 0; +} + +static int +process_rt_rec( + struct xfs_mount *mp, + struct xfs_bmbt_irec *irec, + xfs_ino_t ino, + xfs_rfsblock_t *tot, + int check_dups) +{ + xfs_fsblock_t lastb; + int bad; + + /* + * check numeric validity of the extent + */ + if (!libxfs_verify_rtbno(mp, irec->br_startblock)) { + do_warn( +_("inode %" PRIu64 " - bad rt extent start block number %" PRIu64 ", offset %" PRIu64 "\n"), + ino, + irec->br_startblock, + irec->br_startoff); + return 1; } + lastb = irec->br_startblock + irec->br_blockcount - 1; + if (!libxfs_verify_rtbno(mp, lastb)) { + do_warn( +_("inode %" PRIu64 " - bad rt extent last block number %" PRIu64 ", offset %" PRIu64 "\n"), + ino, + lastb, + irec->br_startoff); + return 1; + } + if (lastb < irec->br_startblock) { + do_warn( +_("inode %" PRIu64 " - bad rt extent overflows - start %" PRIu64 ", " + "end %" PRIu64 ", offset %" PRIu64 "\n"), + ino, + irec->br_startblock, + lastb, + irec->br_startoff); + return 1; + } + + if (check_dups) + bad = process_rt_rec_dups(mp, ino, irec); + else + bad = process_rt_rec_state(mp, ino, irec); + if (bad) + return bad; + /* * bump up the block counter */