From patchwork Tue Jun 2 04:25:07 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: 11582925 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 D7E86913 for ; Tue, 2 Jun 2020 04:27:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C065020738 for ; Tue, 2 Jun 2020 04:27:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="K+2csg9o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725781AbgFBE1O (ORCPT ); Tue, 2 Jun 2020 00:27:14 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:34406 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgFBE1O (ORCPT ); Tue, 2 Jun 2020 00:27:14 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524HODo106930; Tue, 2 Jun 2020 04:27:11 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=Vd29LH/YNdn0VZY/kCU+SsC+OGiJthMBLsLp9uCiEIo=; b=K+2csg9o+PxwePGiWcqGGdEpe0vlcVAZhjrBYo/OG1aG0kpht+3AW4L6sxjungcyP51w rz5lI83CBMUO2BoBJEM78An2S4JhFD7kW1TAoMcc440H9g2+RZYVPgmMIBPcYaMgTTIf /2dQx1nKswmca7/Yvms18Uen/uupSDUGoP5Sud/LBR+WoDqcVsbaqNUjCfT6sajEf3/g lvCn7oleGn44NifrGTjtaQPTk7GMMEgvXz0/kjMshtkcI5CxoHBF1a6NY+PV9/+HAuKc oDP+OJud8PrENggjIjcbDel4ELClc0+CfLzEcNN4gy3Fl8+Empu4UHxLdL3iYDiZpjNd Gw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 31bfem1tb6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:27:11 +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 0524HwW2040219; Tue, 2 Jun 2020 04:25:11 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 31c18sgg0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:25:11 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524PADL020245; Tue, 2 Jun 2020 04:25:10 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:25:10 -0700 Subject: [PATCH 01/17] xfs_quota: fix unsigned int id comparisons From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:07 -0700 Message-ID: <159107190741.313760.11195530788081068638.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Fix compiler warnings about unsigned int comparisons by replacing them with an explicit check for the one possible invalid value (-1U). id_from_string sets exitcode to nonzero when it sees this value, so the call sites don't have to do that. Coverity-id: 1463855, 1463856, 1463857 Fixes: 67a73d6139d0 ("xfs_quota: refactor code to generate id from name") Fixes: 36dc471cc9bb ("xfs_quota: allow individual timer extension") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- quota/edit.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/quota/edit.c b/quota/edit.c index cf9508bf..01d358f7 100644 --- a/quota/edit.c +++ b/quota/edit.c @@ -307,11 +307,11 @@ limit_f( id = id_from_string(name, type); - if (id >= 0) - set_limits(id, type, mask, fs_path->fs_name, - &bsoft, &bhard, &isoft, &ihard, &rtbsoft, &rtbhard); - else - exitcode = -1; + if (id == -1) + return 0; + + set_limits(id, type, mask, fs_path->fs_name, + &bsoft, &bhard, &isoft, &ihard, &rtbsoft, &rtbhard); return 0; } @@ -545,9 +545,10 @@ timer_f( if (name) id = id_from_string(name, type); - if (id >= 0) - set_timer(id, type, mask, fs_path->fs_name, value); + if (id == -1) + return 0; + set_timer(id, type, mask, fs_path->fs_name, value); return 0; } @@ -642,11 +643,10 @@ warn_f( } id = id_from_string(name, type); - if (id >= 0) - set_warnings(id, type, mask, fs_path->fs_name, value); - else - exitcode = -1; + if (id == -1) + return 0; + set_warnings(id, type, mask, fs_path->fs_name, value); return 0; } From patchwork Tue Jun 2 04:25:15 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: 11582909 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 023E7913 for ; Tue, 2 Jun 2020 04:25:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA838206C3 for ; Tue, 2 Jun 2020 04:25:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="bfgI+zi3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725787AbgFBEZY (ORCPT ); Tue, 2 Jun 2020 00:25:24 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33526 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgFBEZY (ORCPT ); Tue, 2 Jun 2020 00:25:24 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524HLmn106921; Tue, 2 Jun 2020 04:25:18 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=YDcCzvPWwIOrFQb6qFvuy7GbWhGiPNN5BAHmj0HSvSs=; b=bfgI+zi3xlJm7+sE+wr3eZGYmViIAUe/dmerJt9ZB7gpAJVFPUK5dpRVx3lNkSsKekxu y4A9noLPJYgHkIXrvvbjjdjSwzujeTpq/snTmT3+Xb6v0BYrPPnuN2yqakm24fyi4hZV o1qZ79XMchkglrfFI6omJloi+SYX056A71YIZ0cCDTSPLIOrVzAW3m/FG8S72D4+jQdp iNByJjmzjj5VDm4CCXA6nApVJbWoIpiojRXwfSRuFE1JreJ/cSdpY/LA7AvVCJYXVWFZ Zh5ZLtWgncdHQkLCW3Qb0aJjorDkAKdsxhGtUpPUn2Wxpbw1Ogh1FkCGizP1l8Mr5jVF BQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 31bfem1t7r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:25:18 +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 0524I1fd040399; Tue, 2 Jun 2020 04:25:17 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 31c18sgg34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:25:17 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0524PGQd020761; Tue, 2 Jun 2020 04:25:16 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:25:16 -0700 Subject: [PATCH 02/17] xfs_repair: fix missing dir buffer corruption checks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:15 -0700 Message-ID: <159107191545.313760.9884644443421173377.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The da_read_buf() function operates in "salvage" mode, which means that if the verifiers fail, it will return a buffer with b_error set. The callers of da_read_buf, however, do not adequately check for verifier errors, which means that repair can fail to flag a corrupt filesystem. Fix the callers to do this properly. The dabtree block walker and the dabtree path checker functions to complain any time the da node / leafn verifiers fail. Fix the directory block walking functions to complain about EFSCORRUPTED, since they already dealt with EFSBADCRC. Found by running xfs/496 against lhdr.stale = middlebit. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/da_util.c | 25 ++++++++++++++++--------- repair/dir2.c | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/repair/da_util.c b/repair/da_util.c index 5061880f..7239c2e2 100644 --- a/repair/da_util.c +++ b/repair/da_util.c @@ -134,6 +134,15 @@ _("can't read %s block %u for inode %" PRIu64 "\n"), goto error_out; } + /* corrupt leafn/node; rebuild the dir. */ + if (bp->b_error == -EFSBADCRC || bp->b_error == -EFSCORRUPTED) { + do_warn( +_("corrupt %s tree block %u for inode %" PRIu64 "\n"), + FORKNAME(whichfork), bno, da_cursor->ino); + libxfs_buf_relse(bp); + goto error_out; + } + node = bp->b_addr; libxfs_da3_node_hdr_from_disk(mp, &nodehdr, node); @@ -160,15 +169,6 @@ _("bad %s magic number 0x%x in inode %" PRIu64 " bno = %u\n"), goto error_out; } - /* corrupt node; rebuild the dir. */ - if (bp->b_error == -EFSBADCRC || bp->b_error == -EFSCORRUPTED) { - libxfs_buf_relse(bp); - do_warn( -_("corrupt %s tree block %u for inode %" PRIu64 "\n"), - FORKNAME(whichfork), bno, da_cursor->ino); - goto error_out; - } - if (nodehdr.count > geo->node_ents) { do_warn( _("bad %s record count in inode %" PRIu64 ", count = %d, max = %d\n"), @@ -562,6 +562,13 @@ _("can't read %s block %u for inode %" PRIu64 "\n"), FORKNAME(whichfork), dabno, cursor->ino); return 1; } + if (bp->b_error == -EFSCORRUPTED || bp->b_error == -EFSBADCRC) { + do_warn( +_("corrupt %s tree block %u for inode %" PRIu64 "\n"), + FORKNAME(whichfork), dabno, cursor->ino); + libxfs_buf_relse(bp); + return 1; + } newnode = bp->b_addr; libxfs_da3_node_hdr_from_disk(mp, &nodehdr, newnode); diff --git a/repair/dir2.c b/repair/dir2.c index cbbce601..b374bc7b 100644 --- a/repair/dir2.c +++ b/repair/dir2.c @@ -983,6 +983,13 @@ _("can't read block %u for directory inode %" PRIu64 "\n"), mp->m_dir_geo->datablk, ino); return 1; } + if (bp->b_error == -EFSCORRUPTED) { + do_warn( +_("corrupt directory block %u for inode %" PRIu64 "\n"), + mp->m_dir_geo->datablk, ino); + libxfs_buf_relse(bp); + return 1; + } /* * Verify the block */ @@ -1122,6 +1129,13 @@ _("can't read file block %u for directory inode %" PRIu64 "\n"), da_bno, ino); goto error_out; } + if (bp->b_error == -EFSCORRUPTED) { + do_warn( +_("corrupt directory leafn block %u for inode %" PRIu64 "\n"), + da_bno, ino); + libxfs_buf_relse(bp); + goto error_out; + } leaf = bp->b_addr; libxfs_dir2_leaf_hdr_from_disk(mp, &leafhdr, leaf); /* @@ -1324,6 +1338,13 @@ _("can't read block %" PRIu64 " for directory inode %" PRIu64 "\n"), dbno, ino); continue; } + if (bp->b_error == -EFSCORRUPTED) { + do_warn( +_("corrupt directory data block %lu for inode %" PRIu64 "\n"), + dbno, ino); + libxfs_buf_relse(bp); + continue; + } data = bp->b_addr; if (!(be32_to_cpu(data->magic) == XFS_DIR2_DATA_MAGIC || be32_to_cpu(data->magic) == XFS_DIR3_DATA_MAGIC)) From patchwork Tue Jun 2 04:25:21 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: 11582959 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 9EB62913 for ; Tue, 2 Jun 2020 04:29:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8725E20738 for ; Tue, 2 Jun 2020 04:29:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="oNNG3v22" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726007AbgFBE33 (ORCPT ); Tue, 2 Jun 2020 00:29:29 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47964 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbgFBE33 (ORCPT ); Tue, 2 Jun 2020 00:29:29 -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 0524IvBT134904; Tue, 2 Jun 2020 04:27:23 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=mXy5YEuIaZGeAvHZOI1Kt5Bqd63avZ3RVwpo2nDf6w0=; b=oNNG3v22Xf9mbMZyomoFevswdjixJQ6LdoYX71jXCLD0FT+fkMTRKJcB1s6NM3wRv5gS moXw8pmWvM3jysq1UQvw1ZQPIPCXr19sijcW2uqIr2ul4OdFk6PiPbAGU3326DwlfC6p gxcVSnIEAgQ87DlzYkcbApvg0xlr7KG52+GvXTlo2JEEjwyODsUhiKWIVoodVME48Ziy aWCBIWH5uSdjlMyMcmGrZB1hraZmGihuUAy/k6Pbe1VciySQTcot/2ABPf/LWxRLTIGr kEhB/TYMfxwDvUlpFOQUunZB8WUoszcut9fLQBlwoMzu5zBN75S0XLUCUn+MRUVzDOKh Aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 31d5qr20rf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:27:23 +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 0524Hv9H040104; Tue, 2 Jun 2020 04:25:23 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 31c18sgg57-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:25:23 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524PMM6020412; Tue, 2 Jun 2020 04:25:22 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:25:22 -0700 Subject: [PATCH 03/17] xfs_repair: warn when we would have rebuilt a directory From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:21 -0700 Message-ID: <159107192170.313760.304032041602234316.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 cotscore=-2147483648 mlxscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong longform_dir2_entry_check should warn the user when we would have rebuilt a directory had -n not been given on the command line. The missing warning results in repair returning 0 (all clean) when in fact there were things that it would have fixed. Found by running xfs/496 against lents[0].hashval = middlebit. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/phase6.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/repair/phase6.c b/repair/phase6.c index 5e3b394a..b6391326 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -2425,6 +2425,9 @@ longform_dir2_entry_check(xfs_mount_t *mp, *num_illegal = 0; *need_dot = 0; } else { + if (fixit || dotdot_update) + do_warn( + _("would rebuild directory inode %" PRIu64 "\n"), ino); for (i = 0; i < num_bps; i++) if (bplist[i]) libxfs_buf_relse(bplist[i]); From patchwork Tue Jun 2 04:25:27 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: 11582911 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 5F27160D for ; Tue, 2 Jun 2020 04:25:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49C20206C3 for ; Tue, 2 Jun 2020 04:25:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="0D3bPc8l" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725872AbgFBEZf (ORCPT ); Tue, 2 Jun 2020 00:25:35 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46192 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgFBEZe (ORCPT ); Tue, 2 Jun 2020 00:25:34 -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 0524ISFv121736; Tue, 2 Jun 2020 04:25: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-2020-01-29; bh=O18ot5zOb1loWyrXY4Qwj1C8MzNz+bjPn/RnijNPXgQ=; b=0D3bPc8lErqmN0L7QyudKRGI7ZdvS0ATRr5l105aw3EgDN+Kn+ahrOQP19LOiwO0RCHu xHId3UGNxFALxohBP22aJYn9SAYgQ2nHXY4oyQpHk5nvTrzFob8JFLSNCyLupbARG/0K yJ5kaFZoFVrSuoaaO0mRXq/Zg4gBRigLYjC413t0e41KpcaWGLCOTW63RVRpEm1yF9HC /jHs/1SXlF2jdGpkiw8T09ObtzxULMz0is94eUvUCyqk5NVbg/U84C4OLfNbUC85dwZX 0NH660lgVslxHPQSrgTBcCx8hc0ma2cuF45HVjQrEbAWB19yGW+r9KVsJhRHhEVvHtHI lw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 31d5qr20n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:25:30 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524JDxm091125; Tue, 2 Jun 2020 04:25:29 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 31c1dwge0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:25:29 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524PTcw020452; Tue, 2 Jun 2020 04:25:29 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:25:28 -0700 Subject: [PATCH 04/17] xfs_repair: check for AG btree records that would wrap around From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:27 -0700 Message-ID: <159107192786.313760.11817417037779916800.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 cotscore=-2147483648 mlxscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong For AG btree types, make sure that each record's length is not so huge that integer wraparound would happen. Found via xfs/358 fuzzing recs[1].blockcount = ones. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/scan.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/repair/scan.c b/repair/scan.c index 5c8d8b23..1ddb5763 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -684,7 +684,8 @@ _("%s freespace btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), b, i, name, agno, bno); continue; } - if (len == 0 || !verify_agbno(mp, agno, end - 1)) { + if (len == 0 || end <= b || + !verify_agbno(mp, agno, end - 1)) { do_warn( _("invalid length %u in record %u of %s btree block %u/%u\n"), len, i, name, agno, bno); @@ -1066,7 +1067,8 @@ _("%s rmap btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), b, i, name, agno, bno); continue; } - if (len == 0 || !verify_agbno(mp, agno, end - 1)) { + if (len == 0 || end <= b || + !verify_agbno(mp, agno, end - 1)) { do_warn( _("invalid length %u in record %u of %s btree block %u/%u\n"), len, i, name, agno, bno); @@ -1353,7 +1355,8 @@ _("leftover CoW extent has invalid startblock in record %u of %s btree block %u/ b, i, name, agno, bno); continue; } - if (len == 0 || !verify_agbno(mp, agno, end - 1)) { + if (len == 0 || end <= agb || + !verify_agbno(mp, agno, end - 1)) { do_warn( _("invalid length %u in record %u of %s btree block %u/%u\n"), len, i, name, agno, bno); From patchwork Tue Jun 2 04:25: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: 11582963 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 26FF3913 for ; Tue, 2 Jun 2020 04:29:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 105622074B for ; Tue, 2 Jun 2020 04:29:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="So4P20Q1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726019AbgFBE3k (ORCPT ); Tue, 2 Jun 2020 00:29:40 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48042 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbgFBE3k (ORCPT ); Tue, 2 Jun 2020 00:29:40 -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 0524ILne121680; Tue, 2 Jun 2020 04:27: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-2020-01-29; bh=GX4OYNA+UG6kfHNmM9f1YoQqzYOa7eOJvmrVvIPngh8=; b=So4P20Q1+6LEzj8PTTbokdDxWPIogqAqunIcZr/GCPHs812lIi41kLjgoZBUa9M1alce X3dlvOm1/Nr4+6XY1n8XaLukoCN6YJVd2ubWJwHHvsN4/FPo6qUdWICgAw+NFXNYi0qu 8Myt8pJbwBmC8Ojn5b4e1xcedBceinTmAj3PyqM8tsXfMckXBhYIhqDGLF5VBbmF8bGq p/yGo0ydNa1TOwYEXo+HYjTdfFEVLeDNEtFFefk4DN89nJBhQ39kzyzVHs37lNq4x7Xx uLFHHNdJ1s88VESkcsqgEQ28N4NGW5uuq8rTHTPrY6sQINSlwjWa8jVmLtSFS0YtZDdi NA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31d5qr20rt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:27:36 +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 0524HuYc126657; Tue, 2 Jun 2020 04:25:35 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 31c25mnfu6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:25:35 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0524PZr8020900; Tue, 2 Jun 2020 04:25:35 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:25:35 -0700 Subject: [PATCH 05/17] xfs_repair: fix bnobt and refcountbt record order checks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:34 -0700 Message-ID: <159107193410.313760.7458420982893800558.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 cotscore=-2147483648 mlxscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The bnobt and refcountbt scanners attempt to check that records are in the correct order. However, the lastblock variable in both functions ought to be set to the end of the previous record (instead of the start) because otherwise we fail to catch overlapping records, which are not allowed in either btree type. Found by running xfs/410 with recs[1].blockcount = middlebit. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repair/scan.c b/repair/scan.c index 1ddb5763..2d156d64 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -699,7 +699,7 @@ _("%s freespace btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), "out-of-order bno btree record %d (%u %u) block %u/%u\n"), i, b, len, agno, bno); } else { - lastblock = b; + lastblock = end - 1; } } else { agcnts->fdblocks += len; @@ -1396,7 +1396,7 @@ _("extent (%u/%u) len %u claimed, state is %d\n"), "out-of-order %s btree record %d (%u %u) block %u/%u\n"), name, i, b, len, agno, bno); } else { - lastblock = b; + lastblock = end - 1; } /* Is this record mergeable with the last one? */ From patchwork Tue Jun 2 04:25:40 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: 11582913 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 01C32913 for ; Tue, 2 Jun 2020 04:25:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF20920738 for ; Tue, 2 Jun 2020 04:25:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="XaxqIZef" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725900AbgFBEZr (ORCPT ); Tue, 2 Jun 2020 00:25:47 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33746 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgFBEZr (ORCPT ); Tue, 2 Jun 2020 00:25:47 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524Hvo4107049; Tue, 2 Jun 2020 04:25:43 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=P+U+IoRBI7cVMkghKY1uOtC1GtaFENvsDXFcVl545yk=; b=XaxqIZefP/HtnR7tdkcIg1oiG9MMLLLsikJkgmRJJ+n6HQb2XFxlcrQCkZDbwZQwz8nq 2xPtxaOcuJ2SrpsDIY1BZMpVpCdeevQQhemVeUjltRm0tX+NNtxmslkTWbTTtyfnACX1 pBb/ask5UNhjCpcfIcCo/6heFAGu3Sh01dfz62CUAqYx3ceN0/tDkAHG2WWK+lQXzVaZ roBAjuo1FyX2nD819YZDOWMW2+p3zX/YtM1W3NcSLSK7hgQNxfItTudYHoFeYMTk+5QZ nOsgrVEGIk27nKjab4UHXLfgljtSH4FeFSYAEvMgk+yp9fx1U+1IYNgsRM71EwA0x0/x 4w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 31bfem1t8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:25:43 +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 0524JMRD102175; Tue, 2 Jun 2020 04:25:42 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 31c12ng417-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:25:42 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524PfkR020486; Tue, 2 Jun 2020 04:25:41 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:25:41 -0700 Subject: [PATCH 06/17] xfs_repair: check for out-of-order inobt records From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:40 -0700 Message-ID: <159107194026.313760.17246981571184212290.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Make sure that the inode btree records are in order. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/scan.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/repair/scan.c b/repair/scan.c index 2d156d64..7c46ab89 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -1947,6 +1947,7 @@ scan_inobt( const struct xfs_buf_ops *ops) { struct aghdr_cnts *agcnts = priv; + xfs_agino_t lastino = 0; int i; int numrecs; int state; @@ -2029,7 +2030,16 @@ _("inode btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), * the block. skip processing of bogus records. */ for (i = 0; i < numrecs; i++) { + xfs_agino_t startino; + freecount = inorec_get_freecount(mp, &rp[i]); + startino = be32_to_cpu(rp[i].ir_startino); + if (i > 0 && startino <= lastino) + do_warn(_( + "out-of-order ino btree record %d (%u) block %u/%u\n"), + i, startino, agno, bno); + else + lastino = startino + XFS_INODES_PER_CHUNK - 1; if (magic == XFS_IBT_MAGIC || magic == XFS_IBT_CRC_MAGIC) { From patchwork Tue Jun 2 04:25:46 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: 11582965 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 31EA360D for ; Tue, 2 Jun 2020 04:29:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B3C220738 for ; Tue, 2 Jun 2020 04:29:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YW/EHLnD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726032AbgFBE3w (ORCPT ); Tue, 2 Jun 2020 00:29:52 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:35814 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbgFBE3w (ORCPT ); Tue, 2 Jun 2020 00:29:52 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524GvGD106525; Tue, 2 Jun 2020 04:27:48 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=KJZzEwctKaE+IzYXEBAXzxTx1R5uomN41GZbLM6VwmI=; b=YW/EHLnDYdSm7O6cfoUwbjlo1XPw/93BXdGbQBPJSGGTlt5bfLhFlbZt9sFZBow6fYQt CulprSqMeznchLkG4foCyuqEa8Irp+xi95rNoHTmJXuHPFpyb4dg8MkfmD0sH/MPyw3d MdRAjBjhklHNQvVMLXU/T4lt6B15jD4tbwIcoHpbmH/ct+8GDy7GvTEjIZ9VHPuwSBS0 gATH50b5n2RLo90d8yHm85Qa5I0gP60TZDMyuVwTFd91GzUbAcs3R0kVs52M4a0sBeMx Env2kiSZLXwfne4/1i2WAISnN0Fr7OTAzS/v0MDxJWeNaSA7jjaZ6JvRyUQooBU2XRAp yQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 31bfem1tc9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:27:48 +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 0524HuhQ126583; Tue, 2 Jun 2020 04:25:48 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 31c25mng7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:25:48 +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 0524Pl3v019672; Tue, 2 Jun 2020 04:25:47 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:25:47 -0700 Subject: [PATCH 07/17] xfs_repair: fix rmapbt record order check From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:46 -0700 Message-ID: <159107194648.313760.17092174816202906919.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The rmapbt record order checks here don't quite work properly. For non-shared filesystems, we fail to check that the startblock of the nth record comes entirely after the previous record. However, for filesystems with shared blocks (reflink) we correctly check that the startblock/owner/offset of the nth record comes after the previous one. Therefore, make the reflink fs checks use "laststartblock" to preserve that functionality while making the non-reflink fs checks use "lastblock" to fix the problem outlined above. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/scan.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/repair/scan.c b/repair/scan.c index 7c46ab89..7508f7e8 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -925,15 +925,15 @@ struct rmap_priv { static bool rmap_in_order( xfs_agblock_t b, - xfs_agblock_t lastblock, + xfs_agblock_t laststartblock, uint64_t owner, uint64_t lastowner, uint64_t offset, uint64_t lastoffset) { - if (b > lastblock) + if (b > laststartblock) return true; - else if (b < lastblock) + else if (b < laststartblock) return false; if (owner > lastowner) @@ -964,6 +964,7 @@ scan_rmapbt( int hdr_errors = 0; int numrecs; int state; + xfs_agblock_t laststartblock = 0; xfs_agblock_t lastblock = 0; uint64_t lastowner = 0; uint64_t lastoffset = 0; @@ -1101,14 +1102,15 @@ _("%s rmap btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), /* Check for out of order records. */ if (i == 0) { advance: - lastblock = b; + laststartblock = b; + lastblock = end - 1; lastowner = owner; lastoffset = offset; } else { bool bad; if (xfs_sb_version_hasreflink(&mp->m_sb)) - bad = !rmap_in_order(b, lastblock, + bad = !rmap_in_order(b, laststartblock, owner, lastowner, offset, lastoffset); else From patchwork Tue Jun 2 04:25:52 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: 11582915 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 E771A913 for ; Tue, 2 Jun 2020 04:25:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE56F206C3 for ; Tue, 2 Jun 2020 04:25:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="HB+qM4bm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725793AbgFBEZ7 (ORCPT ); Tue, 2 Jun 2020 00:25:59 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33840 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgFBEZ7 (ORCPT ); Tue, 2 Jun 2020 00:25:59 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524Gfsg106493; Tue, 2 Jun 2020 04:25:55 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=FTGHLV7G+ugo0tkrFuj4rLHZRCw962nJ8h/xSYiWln0=; b=HB+qM4bm+6ghzuCgzdTVXBDd6B3RcZ5o0PZfDawy5fJ2iDyxYAsbsQn6XGYtAkTKodJR mPKRWpUhOAZ8svNmjhKJeRvlaiKGIFLUcXRDX/hg5JUBQdZqAmxbfNdTvcOVKerFODKT fBawLxM8XK5wqwwdvIV2lOTkxdwLHhPZJz7Kz0MDOEUkLrto3AOAWQud0SbqJVjB3JrF BsHPQChhWr/57ZLJvuJ1PAXOINTrSsJ9Pfi7sGdJAkty6zGqThBG+PIVHzHGEN0P42lk ftDpnXPXLpABES5OB1AmdZhewDyvoYRLnkTLIrjb+BlprmfTUJm4E7Ju/gxFq/kf1XTL xg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 31bfem1t8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:25:55 +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 0524Hvdq040061; Tue, 2 Jun 2020 04:25:54 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 31c18sggfv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:25:54 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524PsuT020597; Tue, 2 Jun 2020 04:25:54 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:25:53 -0700 Subject: [PATCH 08/17] xfs_repair: tag inobt vs finobt errors properly From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:52 -0700 Message-ID: <159107195269.313760.9235612924680444467.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Amend the generic inode btree block scanner function to tag correctly which tree it's complaining about. Previously, dubious finobt headers would be attributed to the "inode btree", which is at best ambiguous and misleading at worst. Signed-off-by: Darrick J. Wong 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 7508f7e8..fff54ecf 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -1949,6 +1949,7 @@ scan_inobt( const struct xfs_buf_ops *ops) { struct aghdr_cnts *agcnts = priv; + char *name; xfs_agino_t lastino = 0; int i; int numrecs; @@ -1961,17 +1962,32 @@ scan_inobt( hdr_errors = 0; + switch (magic) { + case XFS_FIBT_MAGIC: + case XFS_FIBT_CRC_MAGIC: + name = "fino"; + break; + case XFS_IBT_MAGIC: + case XFS_IBT_CRC_MAGIC: + name = "ino"; + break; + default: + name = "(unknown)"; + assert(0); + break; + } + if (be32_to_cpu(block->bb_magic) != magic) { - do_warn(_("bad magic # %#x in inobt block %d/%d\n"), - be32_to_cpu(block->bb_magic), agno, bno); + do_warn(_("bad magic # %#x in %sbt block %d/%d\n"), + be32_to_cpu(block->bb_magic), name, agno, bno); hdr_errors++; bad_ino_btree = 1; if (suspect) return; } if (be16_to_cpu(block->bb_level) != level) { - do_warn(_("expected level %d got %d in inobt block %d/%d\n"), - level, be16_to_cpu(block->bb_level), agno, bno); + do_warn(_("expected level %d got %d in %sbt block %d/%d\n"), + level, be16_to_cpu(block->bb_level), name, agno, bno); hdr_errors++; bad_ino_btree = 1; if (suspect) @@ -1993,8 +2009,8 @@ scan_inobt( default: set_bmap(agno, bno, XR_E_MULT); do_warn( -_("inode btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), - state, agno, bno, suspect); +_("%sbt btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), + name, state, agno, bno, suspect); } numrecs = be16_to_cpu(block->bb_numrecs); @@ -2016,8 +2032,8 @@ _("inode btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), if (hdr_errors) { bad_ino_btree = 1; - do_warn(_("dubious inode btree block header %d/%d\n"), - agno, bno); + do_warn(_("dubious %sbt btree block header %d/%d\n"), + name, agno, bno); suspect++; } @@ -2038,8 +2054,8 @@ _("inode btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), startino = be32_to_cpu(rp[i].ir_startino); if (i > 0 && startino <= lastino) do_warn(_( - "out-of-order ino btree record %d (%u) block %u/%u\n"), - i, startino, agno, bno); + "out-of-order %s btree record %d (%u) block %u/%u\n"), + name, i, startino, agno, bno); else lastino = startino + XFS_INODES_PER_CHUNK - 1; From patchwork Tue Jun 2 04:25:58 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: 11582935 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 601BB60D for ; Tue, 2 Jun 2020 04:28:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4803E20738 for ; Tue, 2 Jun 2020 04:28:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="j2QN2vTc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725900AbgFBE2F (ORCPT ); Tue, 2 Jun 2020 00:28:05 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:34876 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgFBE2F (ORCPT ); Tue, 2 Jun 2020 00:28:05 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524H8bK106584; Tue, 2 Jun 2020 04:26:01 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=xQo/NubJ8pV+EOcJ+3qkQrjvP54eNJjBR6SO+r65MAo=; b=j2QN2vTc0gtCma7h9Chbjj6G1FHYZN2eIaj8rFO+r08UQxWUczPftgAHRh2YllRywGfN xK5hERdBEjCLfNIYa3z+I2CnSwgKG4IXEz75Lta+ibM9FZ1qTZl9V98hxnWvxVyrLjRj HQr8hIdfle6Ali1WATukAfV6Lsd4qJt+T42DzX17cihI+CwnJ6UCwlSX2dJpSHlOChHh 3hoNcAEFUsA/bu9GYdX327K0J/Tjq08kan3fYk7/HbaSoatCd9fJL630MOZLa8C9eQR7 8uHVE1SkjcgeExW80X2Wk+K1Pz0JsGp1VE2VnG+lRMk8PEIsPm6P044IewfG1/mPBBKe GQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 31bfem1t8x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:26:01 +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 0524HuYh126657; Tue, 2 Jun 2020 04:26:01 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 31c25mngn2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:01 +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 0524Q0Oi019788; Tue, 2 Jun 2020 04:26:00 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:00 -0700 Subject: [PATCH 09/17] xfs_repair: complain about bad interior btree pointers From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:25:58 -0700 Message-ID: <159107195896.313760.2369698179955785000.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Actually complain about garbage btree node pointers, don't just silently ignore them. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/libxfs_api_defs.h | 1 + repair/scan.c | 55 +++++++++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 4462036b..7b264ff2 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -180,6 +180,7 @@ #define xfs_trans_roll_inode libxfs_trans_roll_inode #define xfs_trans_roll libxfs_trans_roll +#define xfs_verify_agbno libxfs_verify_agbno #define xfs_verify_cksum libxfs_verify_cksum #define xfs_verify_dir_ino libxfs_verify_dir_ino #define xfs_verify_ino libxfs_verify_ino diff --git a/repair/scan.c b/repair/scan.c index fff54ecf..719ad035 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -779,6 +779,14 @@ _("%s freespace btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), for (i = 0; i < numrecs; i++) { xfs_agblock_t agbno = be32_to_cpu(pp[i]); + if (!libxfs_verify_agbno(mp, agno, agbno)) { + do_warn( + _("bad btree pointer (%u) in %sbt block %u/%u\n"), + agbno, name, agno, bno); + suspect++; + return; + } + /* * XXX - put sibling detection right here. * we know our sibling chain is good. So as we go, @@ -788,10 +796,8 @@ _("%s freespace btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), * pointer mismatch, try and extract as much data * as possible. */ - if (agbno != 0 && verify_agbno(mp, agno, agbno)) { - scan_sbtree(agbno, level, agno, suspect, scan_allocbt, - 0, magic, priv, ops); - } + scan_sbtree(agbno, level, agno, suspect, scan_allocbt, 0, + magic, priv, ops); } } @@ -1234,10 +1240,16 @@ _("%s rmap btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), continue; } - if (agbno != 0 && verify_agbno(mp, agno, agbno)) { - scan_sbtree(agbno, level, agno, suspect, scan_rmapbt, 0, - magic, priv, ops); + if (!libxfs_verify_agbno(mp, agno, agbno)) { + do_warn( + _("bad btree pointer (%u) in %sbt block %u/%u\n"), + agbno, name, agno, bno); + suspect++; + return; } + + scan_sbtree(agbno, level, agno, suspect, scan_rmapbt, 0, magic, + priv, ops); } out: @@ -1454,10 +1466,16 @@ _("extent (%u/%u) len %u claimed, state is %d\n"), for (i = 0; i < numrecs; i++) { xfs_agblock_t agbno = be32_to_cpu(pp[i]); - if (agbno != 0 && verify_agbno(mp, agno, agbno)) { - scan_sbtree(agbno, level, agno, suspect, scan_refcbt, 0, - magic, priv, ops); + if (!libxfs_verify_agbno(mp, agno, agbno)) { + do_warn( + _("bad btree pointer (%u) in %sbt block %u/%u\n"), + agbno, name, agno, bno); + suspect++; + return; } + + scan_sbtree(agbno, level, agno, suspect, scan_refcbt, 0, magic, + priv, ops); } out: if (suspect) @@ -2125,11 +2143,18 @@ _("%sbt btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), } for (i = 0; i < numrecs; i++) { - if (be32_to_cpu(pp[i]) != 0 && verify_agbno(mp, agno, - be32_to_cpu(pp[i]))) - scan_sbtree(be32_to_cpu(pp[i]), level, agno, - suspect, scan_inobt, 0, magic, priv, - ops); + xfs_agblock_t agbno = be32_to_cpu(pp[i]); + + if (!libxfs_verify_agbno(mp, agno, agbno)) { + do_warn( + _("bad btree pointer (%u) in %sbt block %u/%u\n"), + agbno, name, agno, bno); + suspect++; + return; + } + + scan_sbtree(be32_to_cpu(pp[i]), level, agno, suspect, + scan_inobt, 0, magic, priv, ops); } } From patchwork Tue Jun 2 04:26: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: 11582941 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 4AD2F60D for ; Tue, 2 Jun 2020 04:28:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EF44206C3 for ; Tue, 2 Jun 2020 04:28:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="iBah0MWA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725616AbgFBE2M (ORCPT ); Tue, 2 Jun 2020 00:28:12 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:34950 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgFBE2M (ORCPT ); Tue, 2 Jun 2020 00:28:12 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524HSCc106939; Tue, 2 Jun 2020 04:26:07 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=stoltllz5Iif+4oSu0GDUH7VVUr1HtOCiF/ceWPxmCA=; b=iBah0MWA5P9A6TurH55lzq1OwefmwGZ9XJ8cxC1WJe1a4lYGYkyWmgxC14IOkMVCTOFx ca3GXsUlq2AGglRpqfZqPfqQN9xut/quvR/5mVXXH+u3iLiCB10cpnF0wQWssCHGjUrv 8tu6bfk1aeWQq3883F30ZvR0myw5oqJl1rHDLxjgdLuL8z8DXyMp+14vvc6Pu8IVJn1/ X6MFg/eCdKmEhYl/lDFjsHfRV1lJ0vZoZ78e1D/1KjPu2zZ8/c0DWO6E41GmaTJFIi9G Kwzp2TAIwW3dc29c8EgTBJPtV/VUa6l+N4qisgO/q40l/eAvd27QZ2BU/yqh7v/6aits KQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 31bfem1t93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:26:07 +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 0524JMLf102138; Tue, 2 Jun 2020 04:26:07 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 31c12ng47p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:07 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0524Q6ZN021093; Tue, 2 Jun 2020 04:26:06 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:06 -0700 Subject: [PATCH 10/17] xfs_repair: convert to libxfs_verify_agbno From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:26:05 -0700 Message-ID: <159107196560.313760.8599787478905401609.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=2 spamscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=2 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Convert the homegrown verify_agbno callers to use the libxfs function, as needed. In some places we drop the "bno != 0" checks because those conditionals are checking btree roots; btree roots should never be zero if the corresponding feature bit is set; and repair skips the if clause entirely if the feature bit is disabled. In effect, this strengthens repair to validate that AG btree pointers neither point to the AG headers nor past the end of the AG. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/libxfs_api_defs.h | 1 + repair/dinode.c | 11 ----------- repair/dinode.h | 5 ----- repair/scan.c | 36 +++++++++++++++++++++++------------- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 7b264ff2..c03f0efa 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -20,6 +20,7 @@ #define xfs_agfl_walk libxfs_agfl_walk #define xfs_ag_init_headers libxfs_ag_init_headers +#define xfs_ag_block_count libxfs_ag_block_count #define xfs_alloc_ag_max_usable libxfs_alloc_ag_max_usable #define xfs_allocbt_maxrecs libxfs_allocbt_maxrecs diff --git a/repair/dinode.c b/repair/dinode.c index 1f1cc26b..b343534c 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -255,17 +255,6 @@ verify_dfsbno_range(xfs_mount_t *mp, return (XR_DFSBNORANGE_VALID); } -int -verify_agbno(xfs_mount_t *mp, - xfs_agnumber_t agno, - xfs_agblock_t agbno) -{ - xfs_sb_t *sbp = &mp->m_sb;; - - /* range check ag #, ag block. range-checking offset is pointless */ - return verify_ag_bno(sbp, agno, agbno) == 0; -} - static int process_rt_rec( xfs_mount_t *mp, diff --git a/repair/dinode.h b/repair/dinode.h index 98238357..c8e563b5 100644 --- a/repair/dinode.h +++ b/repair/dinode.h @@ -9,11 +9,6 @@ struct blkmap; struct prefetch_args; -int -verify_agbno(xfs_mount_t *mp, - xfs_agnumber_t agno, - xfs_agblock_t agbno); - int verify_dfsbno(xfs_mount_t *mp, xfs_fsblock_t fsbno); diff --git a/repair/scan.c b/repair/scan.c index 719ad035..8e81c552 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -678,14 +678,14 @@ _("%s freespace btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), len = be32_to_cpu(rp[i].ar_blockcount); end = b + len; - if (b == 0 || !verify_agbno(mp, agno, b)) { + if (!libxfs_verify_agbno(mp, agno, b)) { do_warn( _("invalid start block %u in record %u of %s btree block %u/%u\n"), b, i, name, agno, bno); continue; } if (len == 0 || end <= b || - !verify_agbno(mp, agno, end - 1)) { + !libxfs_verify_agbno(mp, agno, end - 1)) { do_warn( _("invalid length %u in record %u of %s btree block %u/%u\n"), len, i, name, agno, bno); @@ -950,6 +950,16 @@ rmap_in_order( return offset > lastoffset; } +static inline bool +verify_rmap_agbno( + struct xfs_mount *mp, + xfs_agnumber_t agno, + xfs_agblock_t agbno) +{ + return agbno < libxfs_ag_block_count(mp, agno); +} + + static void scan_rmapbt( struct xfs_btree_block *block, @@ -1068,14 +1078,14 @@ _("%s rmap btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), end = key.rm_startblock + key.rm_blockcount; /* Make sure agbno & len make sense. */ - if (!verify_agbno(mp, agno, b)) { + if (!verify_rmap_agbno(mp, agno, b)) { do_warn( _("invalid start block %u in record %u of %s btree block %u/%u\n"), b, i, name, agno, bno); continue; } if (len == 0 || end <= b || - !verify_agbno(mp, agno, end - 1)) { + !verify_rmap_agbno(mp, agno, end - 1)) { do_warn( _("invalid length %u in record %u of %s btree block %u/%u\n"), len, i, name, agno, bno); @@ -1363,14 +1373,14 @@ _("leftover CoW extent has invalid startblock in record %u of %s btree block %u/ } end = agb + len; - if (!verify_agbno(mp, agno, agb)) { + if (!libxfs_verify_agbno(mp, agno, agb)) { do_warn( _("invalid start block %u in record %u of %s btree block %u/%u\n"), b, i, name, agno, bno); continue; } if (len == 0 || end <= agb || - !verify_agbno(mp, agno, end - 1)) { + !libxfs_verify_agbno(mp, agno, end - 1)) { do_warn( _("invalid length %u in record %u of %s btree block %u/%u\n"), len, i, name, agno, bno); @@ -2171,7 +2181,7 @@ scan_agfl( { struct agfl_state *as = priv; - if (verify_agbno(mp, as->agno, bno)) + if (libxfs_verify_agbno(mp, as->agno, bno)) set_bmap(as->agno, bno, XR_E_FREE); else do_warn(_("bad agbno %u in agfl, agno %d\n"), @@ -2244,7 +2254,7 @@ validate_agf( uint32_t magic; bno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]); - if (bno != 0 && verify_agbno(mp, agno, bno)) { + if (libxfs_verify_agbno(mp, agno, bno)) { magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_ABTB_CRC_MAGIC : XFS_ABTB_MAGIC; scan_sbtree(bno, be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]), @@ -2256,7 +2266,7 @@ validate_agf( } bno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]); - if (bno != 0 && verify_agbno(mp, agno, bno)) { + if (libxfs_verify_agbno(mp, agno, bno)) { magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_ABTC_CRC_MAGIC : XFS_ABTC_MAGIC; scan_sbtree(bno, be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]), @@ -2276,7 +2286,7 @@ validate_agf( priv.last_rec.rm_owner = XFS_RMAP_OWN_UNKNOWN; priv.nr_blocks = 0; bno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_RMAP]); - if (bno != 0 && verify_agbno(mp, agno, bno)) { + 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, @@ -2294,7 +2304,7 @@ validate_agf( if (xfs_sb_version_hasreflink(&mp->m_sb)) { bno = be32_to_cpu(agf->agf_refcount_root); - if (bno != 0 && verify_agbno(mp, agno, bno)) { + if (libxfs_verify_agbno(mp, agno, bno)) { struct refc_priv priv; memset(&priv, 0, sizeof(priv)); @@ -2342,7 +2352,7 @@ validate_agi( uint32_t magic; bno = be32_to_cpu(agi->agi_root); - if (bno != 0 && verify_agbno(mp, agno, bno)) { + if (libxfs_verify_agbno(mp, agno, bno)) { magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_IBT_CRC_MAGIC : XFS_IBT_MAGIC; scan_sbtree(bno, be32_to_cpu(agi->agi_level), @@ -2355,7 +2365,7 @@ validate_agi( if (xfs_sb_version_hasfinobt(&mp->m_sb)) { bno = be32_to_cpu(agi->agi_free_root); - if (bno != 0 && verify_agbno(mp, agno, bno)) { + if (libxfs_verify_agbno(mp, agno, bno)) { magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_FIBT_CRC_MAGIC : XFS_FIBT_MAGIC; scan_sbtree(bno, be32_to_cpu(agi->agi_free_level), From patchwork Tue Jun 2 04:26:11 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: 11582945 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 43A34913 for ; Tue, 2 Jun 2020 04:28:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D6C82074B for ; Tue, 2 Jun 2020 04:28:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nJjphJAQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725986AbgFBE2S (ORCPT ); Tue, 2 Jun 2020 00:28:18 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:35016 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbgFBE2S (ORCPT ); Tue, 2 Jun 2020 00:28:18 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524I5H7107526; Tue, 2 Jun 2020 04:26: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=JF690Fqk1VGSWMJI7GfOpQPOFxBM6VRV8xFLfPI5WX4=; b=nJjphJAQ2EqsLgsxAstO5LJqteiouSdyHlfp3jrI9tKeNlWsYC3I9WPC9okCQbC3rIUW a2tY3LSJN+Uvqm7iGpmsLe+b5XniC08aSMslG3eRf5zK7v4AZ2cwaILCHJwS33Yp6m9u LgPxR8k5SEK3/eWm2CAjL4atLvrqZC7xqHVtOkiiE/KQ6hFDnWi3xNCDHXE/nWndy1wD tQ1s+GkXgq8FPTPWaG74BE2tXCWoqKnWSl3i5X2lqpyJjHNkNOEsBF9e9nOc5yWGt3EX PBwL0Qw1k+sXYTxI13/AGmYQa1dC/g6lbOQZnZN0enGu5ZHRv8W6xtQHC+mfWnZKY7Sx XQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 31bfem1t99-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:26:14 +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 0524HwJW040244; Tue, 2 Jun 2020 04:26:13 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 31c18sggpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:13 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524QDYJ020695; Tue, 2 Jun 2020 04:26:13 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:12 -0700 Subject: [PATCH 11/17] xfs_repair: refactor verify_dfsbno_range From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:26:11 -0700 Message-ID: <159107197191.313760.3511623910256790079.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Refactor this function to use libxfs type checking helpers. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/libxfs_api_defs.h | 1 + repair/dinode.c | 26 +++++++++----------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index c03f0efa..69f79a08 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -184,6 +184,7 @@ #define xfs_verify_agbno libxfs_verify_agbno #define xfs_verify_cksum libxfs_verify_cksum #define xfs_verify_dir_ino libxfs_verify_dir_ino +#define xfs_verify_fsbno libxfs_verify_fsbno #define xfs_verify_ino libxfs_verify_ino #define xfs_verify_rtbno libxfs_verify_rtbno #define xfs_zero_extent libxfs_zero_extent diff --git a/repair/dinode.c b/repair/dinode.c index b343534c..135703d9 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -228,31 +228,23 @@ verify_dfsbno(xfs_mount_t *mp, #define XR_DFSBNORANGE_OVERFLOW 3 static __inline int -verify_dfsbno_range(xfs_mount_t *mp, - xfs_fsblock_t fsbno, - xfs_filblks_t count) +verify_dfsbno_range( + struct xfs_mount *mp, + xfs_fsblock_t fsbno, + xfs_filblks_t count) { - xfs_agnumber_t agno; - xfs_agblock_t agbno; - xfs_sb_t *sbp = &mp->m_sb;; - /* the start and end blocks better be in the same allocation group */ - agno = XFS_FSB_TO_AGNO(mp, fsbno); - if (agno != XFS_FSB_TO_AGNO(mp, fsbno + count - 1)) { + if (XFS_FSB_TO_AGNO(mp, fsbno) != + XFS_FSB_TO_AGNO(mp, fsbno + count - 1)) { return XR_DFSBNORANGE_OVERFLOW; } - agbno = XFS_FSB_TO_AGBNO(mp, fsbno); - if (verify_ag_bno(sbp, agno, agbno)) { + if (!libxfs_verify_fsbno(mp, fsbno)) return XR_DFSBNORANGE_BADSTART; - } - - agbno = XFS_FSB_TO_AGBNO(mp, fsbno + count - 1); - if (verify_ag_bno(sbp, agno, agbno)) { + if (!libxfs_verify_fsbno(mp, fsbno + count - 1)) return XR_DFSBNORANGE_BADEND; - } - return (XR_DFSBNORANGE_VALID); + return XR_DFSBNORANGE_VALID; } static int From patchwork Tue Jun 2 04:26: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: 11582969 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 C9452913 for ; Tue, 2 Jun 2020 04:30:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1B8420738 for ; Tue, 2 Jun 2020 04:30:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="jnm0++/g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725919AbgFBEa0 (ORCPT ); Tue, 2 Jun 2020 00:30:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48430 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbgFBEa0 (ORCPT ); Tue, 2 Jun 2020 00:30: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 0524I2J6121433; Tue, 2 Jun 2020 04:28:21 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=txP3NwgyJoEAunm6pAdqdtMEcNC34AmBQ0nS60+YkQI=; b=jnm0++/g2KOwNBfkBXDc+XBKoI4sosHI2YBdn40+ijAkxRO8J7K5COjtrv1NqjCCdPci Fc+BZJ6JavQ3kPtKi2cjtg9NWb2Hs/9PrcM9HKxGYLmLO6Y8JvKv3/9nx4zoVJyPfvGa x0wdwk9u002yUMhGBYtML5OVUYJps9SGScciBDQ97tVbsUN7UYRo7F1WCtoKqHxtWYdX Kre97URJZO/2z2VPODyjw5oAJcLzhFUVfQq6J9qsdXltC1q/ZubDe/1pGPnfawV2Lb39 NFGXBGb6g+r9xhJbV9NuaF4uDaIF9Z13UPYQNg+GYbzLhCPji/7/9fzRfZ83rvA8NPQ9 fg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31d5qr20tf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:28:21 +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 0524Huks126748; Tue, 2 Jun 2020 04:26:20 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 31c25mnh94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:20 +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 0524QK90019890; Tue, 2 Jun 2020 04:26:20 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:20 -0700 Subject: [PATCH 12/17] xfs_repair: remove verify_dfsbno From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:26:18 -0700 Message-ID: <159107197805.313760.6515122377279848689.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=2 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 cotscore=-2147483648 mlxscore=0 lowpriorityscore=0 suspectscore=2 spamscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Replace this homegrown helper with its libxfs equivalent. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/attr_repair.c | 2 +- repair/dinode.c | 21 +-------------------- repair/dinode.h | 4 ---- repair/prefetch.c | 9 +++++---- repair/scan.c | 2 +- 5 files changed, 8 insertions(+), 30 deletions(-) diff --git a/repair/attr_repair.c b/repair/attr_repair.c index 5f884033..6cec0f70 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -1092,7 +1092,7 @@ process_longform_attr( } /* FIX FOR bug 653709 -- EKN */ - if (!xfs_verify_fsbno(mp, bno)) { + if (!libxfs_verify_fsbno(mp, bno)) { do_warn( _("block in attribute fork of inode %" PRIu64 " is not valid\n"), ino); return 1; diff --git a/repair/dinode.c b/repair/dinode.c index 135703d9..67adddd7 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -203,25 +203,6 @@ verify_aginum(xfs_mount_t *mp, return verify_ag_bno(sbp, agno, agbno); } -/* - * return 1 if block number is good, 0 if out of range - */ -int -verify_dfsbno(xfs_mount_t *mp, - xfs_fsblock_t fsbno) -{ - xfs_agnumber_t agno; - xfs_agblock_t agbno; - xfs_sb_t *sbp = &mp->m_sb;; - - /* range check ag #, ag block. range-checking offset is pointless */ - - agno = XFS_FSB_TO_AGNO(mp, fsbno); - agbno = XFS_FSB_TO_AGBNO(mp, fsbno); - - return verify_ag_bno(sbp, agno, agbno) == 0; -} - #define XR_DFSBNORANGE_VALID 0 #define XR_DFSBNORANGE_BADSTART 1 #define XR_DFSBNORANGE_BADEND 2 @@ -835,7 +816,7 @@ _("bad numrecs 0 in inode %" PRIu64 " bmap btree root block\n"), * btree, we'd do it right here. For now, if there's a * problem, we'll bail out and presumably clear the inode. */ - if (!verify_dfsbno(mp, get_unaligned_be64(&pp[i]))) { + if (!libxfs_verify_fsbno(mp, get_unaligned_be64(&pp[i]))) { do_warn( _("bad bmap btree ptr 0x%" PRIx64 " in ino %" PRIu64 "\n"), get_unaligned_be64(&pp[i]), lino); diff --git a/repair/dinode.h b/repair/dinode.h index c8e563b5..4bf7affd 100644 --- a/repair/dinode.h +++ b/repair/dinode.h @@ -9,10 +9,6 @@ struct blkmap; struct prefetch_args; -int -verify_dfsbno(xfs_mount_t *mp, - xfs_fsblock_t fsbno); - void convert_extent( xfs_bmbt_rec_t *rp, diff --git a/repair/prefetch.c b/repair/prefetch.c index 3ac49db1..686bf7be 100644 --- a/repair/prefetch.c +++ b/repair/prefetch.c @@ -188,8 +188,9 @@ pf_read_bmbt_reclist( (irec.br_startoff >= fs_max_file_offset)) goto out_free; - if (!verify_dfsbno(mp, irec.br_startblock) || !verify_dfsbno(mp, - irec.br_startblock + irec.br_blockcount - 1)) + if (!libxfs_verify_fsbno(mp, irec.br_startblock) || + !libxfs_verify_fsbno(mp, irec.br_startblock + + irec.br_blockcount - 1)) goto out_free; if (!args->dirs_only && ((irec.br_startoff + @@ -337,7 +338,7 @@ pf_scanfunc_bmap( for (i = 0; i < numrecs; i++) { dbno = get_unaligned_be64(&pp[i]); - if (!verify_dfsbno(mp, dbno)) + if (!libxfs_verify_fsbno(mp, dbno)) return 0; if (!pf_scan_lbtree(dbno, level, isadir, args, pf_scanfunc_bmap)) return 0; @@ -379,7 +380,7 @@ pf_read_btinode( for (i = 0; i < numrecs; i++) { dbno = get_unaligned_be64(&pp[i]); - if (!verify_dfsbno(mp, dbno)) + if (!libxfs_verify_fsbno(mp, dbno)) break; if (!pf_scan_lbtree(dbno, level, isadir, args, pf_scanfunc_bmap)) break; diff --git a/repair/scan.c b/repair/scan.c index 8e81c552..dcd4864d 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -491,7 +491,7 @@ _("inode %" PRIu64 " bad # of bmap records (%u, min - %u, max - %u)\n"), * we'd do it right here. For now, if there's a problem, * we'll bail out and presumably clear the inode. */ - if (!verify_dfsbno(mp, be64_to_cpu(pp[i]))) { + if (!libxfs_verify_fsbno(mp, be64_to_cpu(pp[i]))) { do_warn( _("bad bmap btree ptr 0x%llx in ino %" PRIu64 "\n"), (unsigned long long) be64_to_cpu(pp[i]), ino); From patchwork Tue Jun 2 04:26:25 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: 11582947 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 7D862913 for ; Tue, 2 Jun 2020 04:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63D702074B for ; Tue, 2 Jun 2020 04:28:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hF5/B/iD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725921AbgFBE2d (ORCPT ); Tue, 2 Jun 2020 00:28:33 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:48780 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbgFBE2c (ORCPT ); Tue, 2 Jun 2020 00:28:32 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524IJor107049; Tue, 2 Jun 2020 04:28:28 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=VN7EVmpkuqUtOud8ZRlSEDNsdrgxcc/DBS+d0OAkSs0=; b=hF5/B/iDPVRa03SP/Of0cF0Y+aWtLgpwF8qTtDwPiEn6dr1IIfWuXnOBBLyVKTQABKfJ GAlYUVNtqHjztZLMstbNEu7t8niJtfqTby5S+Z/ki5Kt8AjdUd9TQXGaeXH6kvE547+N IhpSE3/LiD2rO94nwEC2YWD4kBOxkUeBFcSW0bLJoMh7ctkHGBbMsMXUC6sxCIzY6iCW U6mm4drRR6o4oS+dHR40pTyBw7ubnskIYKsyrBGuNdnfUQ7xDcV65Zs2IjjCpDmMMo2A +fWiuyLw8m/aOFt4r/AX+ukehgiT76bHpMPuSg2HipA2gheOAWVk5nGnwHAIm4+e4g9N 6Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 31bewqswnk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:28:27 +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 0524Hwrg040181; Tue, 2 Jun 2020 04:26:27 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 31c18sggt1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:27 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524QQeX020002; Tue, 2 Jun 2020 04:26:26 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:26 -0700 Subject: [PATCH 13/17] xfs_repair: remove verify_aginum From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:26:25 -0700 Message-ID: <159107198538.313760.17599234824681924862.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 cotscore=-2147483648 lowpriorityscore=0 mlxscore=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Replace this homegrown inode pointer verification function with the libxfs checking helper. This one is a little tricky because this function (unlike all of its verify_* siblings) returned 1 for bad and 0 for good, so we must invert the checking logic. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/libxfs_api_defs.h | 1 + repair/dino_chunks.c | 6 +++-- repair/dinode.c | 51 ---------------------------------------------- repair/dinode.h | 5 ----- repair/scan.c | 4 ++-- 5 files changed, 6 insertions(+), 61 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 69f79a08..be06c763 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -182,6 +182,7 @@ #define xfs_trans_roll libxfs_trans_roll #define xfs_verify_agbno libxfs_verify_agbno +#define xfs_verify_agino libxfs_verify_agino #define xfs_verify_cksum libxfs_verify_cksum #define xfs_verify_dir_ino libxfs_verify_dir_ino #define xfs_verify_fsbno libxfs_verify_fsbno diff --git a/repair/dino_chunks.c b/repair/dino_chunks.c index 6685a4d2..399d4998 100644 --- a/repair/dino_chunks.c +++ b/repair/dino_chunks.c @@ -1124,7 +1124,7 @@ check_uncertain_aginodes(xfs_mount_t *mp, xfs_agnumber_t agno) agino = i + irec->ino_startnum; - if (verify_aginum(mp, agno, agino)) + if (!libxfs_verify_agino(mp, agno, agino)) continue; if (nrec != NULL && nrec->ino_startnum <= agino && @@ -1133,7 +1133,7 @@ check_uncertain_aginodes(xfs_mount_t *mp, xfs_agnumber_t agno) continue; if ((nrec = find_inode_rec(mp, agno, agino)) == NULL) - if (!verify_aginum(mp, agno, agino)) + if (libxfs_verify_agino(mp, agno, agino)) if (verify_aginode_chunk(mp, agno, agino, &start)) got_some = 1; @@ -1215,7 +1215,7 @@ process_uncertain_aginodes(xfs_mount_t *mp, xfs_agnumber_t agno) * good tree), bad inode numbers, and inode numbers * pointing to bogus inodes */ - if (verify_aginum(mp, agno, agino)) + if (!libxfs_verify_agino(mp, agno, agino)) continue; if (nrec != NULL && nrec->ino_startnum <= agino && diff --git a/repair/dinode.c b/repair/dinode.c index 67adddd7..526ecde3 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -152,57 +152,6 @@ clear_dinode(xfs_mount_t *mp, xfs_dinode_t *dino, xfs_ino_t ino_num) * misc. inode-related utility routines */ -/* - * verify_ag_bno is heavily used. In the common case, it - * performs just two number of compares - * Returns 1 for bad ag/bno pair or 0 if it's valid. - */ -static __inline int -verify_ag_bno(xfs_sb_t *sbp, - xfs_agnumber_t agno, - xfs_agblock_t agbno) -{ - if (agno < (sbp->sb_agcount - 1)) - return (agbno >= sbp->sb_agblocks); - if (agno == (sbp->sb_agcount - 1)) - return (agbno >= (sbp->sb_dblocks - - ((xfs_rfsblock_t)(sbp->sb_agcount - 1) * - sbp->sb_agblocks))); - return 1; -} - -/* - * have a separate routine to ensure that we don't accidentally - * lose illegally set bits in the agino by turning it into an FSINO - * to feed to the above routine - */ -int -verify_aginum(xfs_mount_t *mp, - xfs_agnumber_t agno, - xfs_agino_t agino) -{ - xfs_agblock_t agbno; - xfs_sb_t *sbp = &mp->m_sb;; - - /* range check ag #, ag block. range-checking offset is pointless */ - - if (agino == 0 || agino == NULLAGINO) - return(1); - - /* - * agino's can't be too close to NULLAGINO because the min blocksize - * is 9 bits and at most 1 bit of that gets used for the inode offset - * so if the agino gets shifted by the # of offset bits and compared - * to the legal agbno values, a bogus agino will be too large. there - * will be extra bits set at the top that shouldn't be set. - */ - agbno = XFS_AGINO_TO_AGBNO(mp, agino); - if (agbno == 0) - return 1; - - return verify_ag_bno(sbp, agno, agbno); -} - #define XR_DFSBNORANGE_VALID 0 #define XR_DFSBNORANGE_BADSTART 1 #define XR_DFSBNORANGE_BADEND 2 diff --git a/repair/dinode.h b/repair/dinode.h index 4bf7affd..1bd0e0b7 100644 --- a/repair/dinode.h +++ b/repair/dinode.h @@ -68,11 +68,6 @@ verify_uncertain_dinode(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_agino_t ino); -int -verify_aginum(xfs_mount_t *mp, - xfs_agnumber_t agno, - xfs_agino_t agino); - int process_uncertain_aginodes(xfs_mount_t *mp, xfs_agnumber_t agno); diff --git a/repair/scan.c b/repair/scan.c index dcd4864d..76079247 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -1561,7 +1561,7 @@ verify_single_ino_chunk_align( * (NULLAGINO). if it gets closer, the agino number will be illegal as * the agbno will be too large. */ - if (verify_aginum(mp, agno, ino)) { + if (!libxfs_verify_agino(mp, agno, ino)) { do_warn( _("bad starting inode # (%" PRIu64 " (0x%x 0x%x)) in %s rec, skipping rec\n"), lino, agno, ino, inobt_name); @@ -1569,7 +1569,7 @@ _("bad starting inode # (%" PRIu64 " (0x%x 0x%x)) in %s rec, skipping rec\n"), return ++suspect; } - if (verify_aginum(mp, agno, + if (!libxfs_verify_agino(mp, agno, ino + XFS_INODES_PER_CHUNK - 1)) { do_warn( _("bad ending inode # (%" PRIu64 " (0x%x 0x%zx)) in %s rec, skipping rec\n"), From patchwork Tue Jun 2 04:26:31 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: 11582917 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 AC10E913 for ; Tue, 2 Jun 2020 04:26:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94F4520738 for ; Tue, 2 Jun 2020 04:26:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="x5W+CDe/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725835AbgFBE0i (ORCPT ); Tue, 2 Jun 2020 00:26:38 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46628 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgFBE0i (ORCPT ); Tue, 2 Jun 2020 00:26:38 -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 0524I2sh121431; Tue, 2 Jun 2020 04:26:34 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=gb+Z453zpL7t3C5dTwLKsImw5+0qzKmLyD3mrKU/lRA=; b=x5W+CDe/S1nN4MFjcngmebZXQEfuEZUvCgc/ZZI68j93FOD7apquTmGNnFNIEMS6agZ/ EeAOtos+9hztONnrRfxDjYXiN3V5soOW23ZxPWeBtBmZgNqkOlPViYOLsVd+FHh7dp0V 2qfPNPulQ4TVp3K7TlzmRPg149eXvtyPiu2mp0PICv22oiDAwLycxNlglxJRJIfm21Fj jEIoDcyK0yUNOqX+UQhgdSLLkTyH0uwS+kIdFt6xmI4vGyaE4ztSzQVojCFwsjDB9pnK t4DtAg+1y4n3LVVOEbGniYI+UMWts8ujlXYTDRRJ7/n0Hoavd9jbhX9xkZ02/7lGZ2HQ HA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 31d5qr20pn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:26:34 +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 0524Hw5h040208; Tue, 2 Jun 2020 04:26:33 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 31c18sgguq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:33 +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 0524QWIM021303; Tue, 2 Jun 2020 04:26:33 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:32 -0700 Subject: [PATCH 14/17] xfs_repair: mark entire free space btree record as free1 From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:26:31 -0700 Message-ID: <159107199172.313760.3705658346320047281.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=2 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 cotscore=-2147483648 mlxscore=0 lowpriorityscore=0 suspectscore=2 spamscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In scan_allocbt, we iterate each free space btree record (of both bnobt and cntbt) in the hopes of pushing all the free space from UNKNOWN to FREE1 to FREE. Unfortunately, the first time we see a free space record we only set the first block of that record to FREE1, which means that the second time we see the record, the first block will get set to FREE, but the rest of the free space will only make it to FREE1. This is incorrect state, so we need to fix that. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repair/scan.c b/repair/scan.c index 76079247..505cfc53 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -719,7 +719,7 @@ _("%s freespace btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), state = get_bmap_ext(agno, b, end, &blen); switch (state) { case XR_E_UNKNOWN: - set_bmap(agno, b, XR_E_FREE1); + set_bmap_ext(agno, b, blen, XR_E_FREE1); break; case XR_E_FREE1: /* From patchwork Tue Jun 2 04:26:38 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: 11582949 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 4473960D for ; Tue, 2 Jun 2020 04:28:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AE33206C3 for ; Tue, 2 Jun 2020 04:28:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="uLz9R1Zn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725890AbgFBE2p (ORCPT ); Tue, 2 Jun 2020 00:28:45 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:35218 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbgFBE2p (ORCPT ); Tue, 2 Jun 2020 00:28:45 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524IbmZ118597; Tue, 2 Jun 2020 04:26:40 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=9+pig35i9TXg2G0aeBT9F738K+Am4Uu5gLaJi3/0epQ=; b=uLz9R1ZnP2LFq0h2O4TFz0jYUjRfF6LTB+Req2ayh18Cz2gBzOVZUoiB69h2P/3PX8CM b6fTrpS3a1d8S3T3VxXLJiybvqfMeB6h2Yp/wch/POaApCbtuPimTKRaL4ShlQ6ElSDb x+SVfbQ7fZjBn4qE27SEFK3+ULjWdafrBRjRicg2T10dQ4andN7Qg7LglEyVbKwBoHdy op4p3UmUBvE1XZb8wy2CKnfW4ill7iW20bQUj6fsYwqKHd9ne9n+rLNLYfP94qnldkoF S2Sygf/NCJ0X9r+esSPplAcbdTlqPcdSTwKxxeZGc9jWgtpWrA5+/Wq5UHXBE9WMxKYJ hA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 31bfem1t9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:26:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524JDh1091096; Tue, 2 Jun 2020 04:26:40 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 31c1dwgeuy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:40 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524Qdx9020808; Tue, 2 Jun 2020 04:26:39 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:38 -0700 Subject: [PATCH 15/17] xfs_repair: complain about free space only seen by one btree From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:26:38 -0700 Message-ID: <159107199799.313760.13799578994778490839.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 suspectscore=2 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=2 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong During the free space btree walk, scan_allocbt claims in a comment that we'll catch FREE1 blocks (i.e. blocks that were seen by only one free space btree) later. This never happens, with the result that xfs_repair in dry-run mode can return 0 on a filesystem with corrupt free space btrees. Found by fuzzing xfs/358 with numrecs = middlebit (or sub). Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/phase4.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/repair/phase4.c b/repair/phase4.c index 8197db06..a43413c7 100644 --- a/repair/phase4.c +++ b/repair/phase4.c @@ -306,6 +306,12 @@ phase4(xfs_mount_t *mp) for (j = ag_hdr_block; j < ag_end; j += blen) { bstate = get_bmap_ext(i, j, ag_end, &blen); switch (bstate) { + case XR_E_FREE1: + if (no_modify) + do_warn( + _("free space (%u,%u-%u) only seen by one free space btree\n"), + i, j, j + blen - 1); + break; case XR_E_BAD_STATE: default: do_warn( @@ -313,7 +319,6 @@ phase4(xfs_mount_t *mp) i, j); /* fall through .. */ case XR_E_UNKNOWN: - case XR_E_FREE1: case XR_E_FREE: case XR_E_INUSE: case XR_E_INUSE_FS: From patchwork Tue Jun 2 04:26:44 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: 11582919 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 6E47B913 for ; Tue, 2 Jun 2020 04:26:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56867206C3 for ; Tue, 2 Jun 2020 04:26:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="K5XQYbVa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725919AbgFBE0w (ORCPT ); Tue, 2 Jun 2020 00:26:52 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47900 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgFBE0v (ORCPT ); Tue, 2 Jun 2020 00:26:51 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524I0YH106856; Tue, 2 Jun 2020 04:26:46 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=RMFQAbDdo2mLJdpwQ4FdK+pZ0nXHokJNuOU3Mxskuso=; b=K5XQYbVa1PJIN1S8zMSIvYUvAA2jMhyC27IeHpbt6InS0t339sz+Jrk+V3M2IfuelgzQ Zd2GS6Em8ZGSlH8Q2BadUBiH9hOKZJ2eZ8vK7CmQQ56rYkXiEw4RlgvuAXxV70g/K5O0 746bxCRWz2SF2X7vnQSRmZfCKTMxM4IQ94HbdkhM3SHGOqtgzaDbmMb8XflYOQBl6FbQ ZWP8Tqx/8kZium8BbRpRTp+n+B7mSw+UvuOkNlvkn7QXtCcbHnjdW13kOzbIhjed856J TF90FZr6LzzIBedolguBUN5gEEYayFV8I1gMwfmkIiw/MwTNGvEyilTAxQ/JpZwv9dhi zA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 31bewqswjc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:26:46 +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 0524JM4m102166; Tue, 2 Jun 2020 04:26:46 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 31c12ng4je-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:46 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0524QjUN021541; Tue, 2 Jun 2020 04:26:45 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:45 -0700 Subject: [PATCH 16/17] xfs_repair: complain about extents in unknown state From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:26:44 -0700 Message-ID: <159107200446.313760.9591682884362621614.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=2 spamscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 bulkscore=0 phishscore=0 suspectscore=2 impostorscore=0 cotscore=-2147483648 lowpriorityscore=0 mlxscore=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong During phase 4, if we find any extents that are unaccounted for, report the entire extent, not just the first block. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/phase4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repair/phase4.c b/repair/phase4.c index a43413c7..191b4842 100644 --- a/repair/phase4.c +++ b/repair/phase4.c @@ -315,8 +315,8 @@ phase4(xfs_mount_t *mp) case XR_E_BAD_STATE: default: do_warn( - _("unknown block state, ag %d, block %d\n"), - i, j); + _("unknown block state, ag %d, blocks %u-%u\n"), + i, j, j + blen - 1); /* fall through .. */ case XR_E_UNKNOWN: case XR_E_FREE: From patchwork Tue Jun 2 04:26:50 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: 11582951 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 0EC1660D for ; Tue, 2 Jun 2020 04:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB78120738 for ; Tue, 2 Jun 2020 04:28:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="mUWBHksk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725995AbgFBE24 (ORCPT ); Tue, 2 Jun 2020 00:28:56 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:35352 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbgFBE24 (ORCPT ); Tue, 2 Jun 2020 00:28:56 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0524GwoA106536; Tue, 2 Jun 2020 04:26:53 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=0ZVCYD4IqGRONGG59xgnbMM7CNqAoH5JJ3lnDYSKaPs=; b=mUWBHksk5VUBx8inddBlFZi1CSZ2PriD9ab5ZexJYmMjY5SyIZRG39t8NccnX5Qy8+oU Gpq7Xtsk8IDA/tp8B3EkG5iexggDLOh5gs+TXR23H0h7UHlcvZcIaNaaJD0W8+F8nYPm kqv4jrRZ+MZW83/EItOie4EJ24ovVuCM5Yk+On9KsbckWj4WG8ZQ8E9G463u3hxPlxmf T/xSVvHmbuy44ziVYBirSgnvzPchyOauF1vRx81a6+hDhER6fKtuk73OLlk9t6zVSwdw laIkCpPcrUHRt5QOReDHhYE07neHUBGtkjtijA5ydu0TFhVUu/GmgV9EOF4lWdptSXaS BQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 31bfem1ta8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 02 Jun 2020 04:26:53 +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 0524Hu3E126673; Tue, 2 Jun 2020 04:26:53 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 31c25mnj78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jun 2020 04:26:53 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0524QpKc020940; Tue, 2 Jun 2020 04:26:52 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jun 2020 21:26:51 -0700 Subject: [PATCH 17/17] xfs_repair: complain about any nonzero inprogress value, not just 1 From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 01 Jun 2020 21:26:50 -0700 Message-ID: <159107201063.313760.4770169703246824898.stgit@magnolia> In-Reply-To: <159107190111.313760.8056083399475334567.stgit@magnolia> References: <159107190111.313760.8056083399475334567.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9639 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006020024 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Complain about the primary superblock having any non-zero sb_inprogress value, not just 1. This brings repair's behavior into alignment with xfs_check and the kernel. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/sb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/repair/sb.c b/repair/sb.c index 91a36dd3..17ce43cc 100644 --- a/repair/sb.c +++ b/repair/sb.c @@ -369,8 +369,7 @@ verify_sb(char *sb_buf, xfs_sb_t *sb, int is_primary_sb) return(XR_BAD_VERSION); /* does sb think mkfs really finished ? */ - - if (is_primary_sb && sb->sb_inprogress == 1) + if (is_primary_sb && sb->sb_inprogress) return(XR_BAD_INPROGRESS); /*