From patchwork Sat May 9 16:29: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: 11538377 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 65682186E for ; Sat, 9 May 2020 16:30:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48EB52063A for ; Sat, 9 May 2020 16:30:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qrhSu/xo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728433AbgEIQaC (ORCPT ); Sat, 9 May 2020 12:30:02 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37002 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQaC (ORCPT ); Sat, 9 May 2020 12:30:02 -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 049GOnLU065426; Sat, 9 May 2020 16:30:00 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=BMArBvVwY8+92epLm2Hj7Lav0ew0sb6EjqdzAn2eKJY=; b=qrhSu/xoQQxqXmOe5ODk1pWJVFOdxGIChK8IMUnE14mGQpxoji2QUHzzk+8N3mQ3Wgmm tEabVCuqzccl3RpAu5i61RIdY9ZnVf7s9e3Km2Q77JwvzpqnwMhcCQgWp5N91GEMlMf0 f+CLZz4vru13D6PGBcyjUf8cFbTI5iTLpuVuHqnUzXIQJjfqnMOgdJvqWKQhnR8+CLq3 +OtYmPCXu8mYwSmuQggnuh0Cm+g2Zs4/v4vGNSF/bYJv7ZNGqrUVkQqDyWwFtDn8gGyu 4RJfQghX1H7FjYoAuQGSqPmJJWa/tcO1EC2JxopoqcsDCEfaHSgH8GNxxPriqNPS0dmF gw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30wx8n86mc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:00 +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 049GTuiM112505; Sat, 9 May 2020 16:29:59 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 30wx11cu46-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:29:59 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 049GTxoM020280; Sat, 9 May 2020 16:29:59 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:29:58 -0700 Subject: [PATCH 01/16] xfs_repair: fix missing dir buffer corruption checks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:29:58 -0700 Message-ID: <158904179840.982941.17275782452712518850.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=966 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=993 phishscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090140 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Both callers of da_read_buf do not adequately check for verifier failures in the (salvage mode) buffer that gets returned. This leads to repair sometimes failing to complain about corrupt directories when run with -n, which leads to an incorrect return value of 0 (all clean). Found by running xfs/496 against lhdr.stale = middlebit. Signed-off-by: Darrick J. Wong --- repair/da_util.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/repair/da_util.c b/repair/da_util.c index 5061880f..92c04337 100644 --- a/repair/da_util.c +++ b/repair/da_util.c @@ -140,11 +140,24 @@ _("can't read %s block %u for inode %" PRIu64 "\n"), if (whichfork == XFS_DATA_FORK && (nodehdr.magic == XFS_DIR2_LEAFN_MAGIC || nodehdr.magic == XFS_DIR3_LEAFN_MAGIC)) { + int bad = 0; + if (i != -1) { do_warn( _("found non-root LEAFN node in inode %" PRIu64 " bno = %u\n"), da_cursor->ino, bno); + bad++; } + + /* corrupt leafn node; rebuild the dir. */ + if (!bad && + (bp->b_error == -EFSBADCRC || + bp->b_error == -EFSCORRUPTED)) { + do_warn( +_("corrupt %s LEAFN block %u for inode %" PRIu64 "\n"), + FORKNAME(whichfork), bno, da_cursor->ino); + } + *rbno = 0; libxfs_buf_relse(bp); return 1; @@ -599,6 +612,14 @@ _("bad level %d in %s block %u for inode %" PRIu64 "\n"), dabno, cursor->ino); bad++; } + if (!bad && + (bp->b_error == -EFSCORRUPTED || + bp->b_error == -EFSBADCRC)) { + do_warn( +_("corruption error reading %s block %u for inode %" PRIu64 "\n"), + FORKNAME(whichfork), dabno, cursor->ino); + bad++; + } if (bad) { #ifdef XR_DIR_TRACE fprintf(stderr, "verify_da_path returns 1 (bad) #4\n"); From patchwork Sat May 9 16:30: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: 11538379 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 A94ED14B4 for ; Sat, 9 May 2020 16:30:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FFF42184D for ; Sat, 9 May 2020 16:30:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RiuyQ/6w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbgEIQaI (ORCPT ); Sat, 9 May 2020 12:30:08 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:37260 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQaH (ORCPT ); Sat, 9 May 2020 12:30:07 -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 049GRVLL196448; Sat, 9 May 2020 16:30:06 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=DyqNSYDZ1JSnuUr1b0wnR+zVBqN1cxVp3ocfAR6K3L8=; b=RiuyQ/6wAmPrQ6qMJ2yt5yaSAvAX0Syty76g61/4cHbFiNs2y/3AfUvzXujY6fGe7XAE GWbTYske5WwD6hKAagldCW86+9fR+jsCO5mUyLDDJWneNh80HL4LBkoq3841ODakc8yC h3TiK4FM/6Ofqy0FRNGR5x649w+llj+4p4RRGbKs/w0BAot10iMKZPlL/2II1mVOHRCj D0DQOR56ljg5pT+haUetEOysSgp7gbw6QqE2Ln1bAPFqaLoGD3qt0d/EF6Q5XZYHiUyp 9s5yH0LxjWp/gmhgGovGz0/Cdr45dwOJhvbWg3R2DiAlMfeJ8funM7kEMSeqkVaPCazA bg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 30wmfm14yy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:06 +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 049GTIJW097759; Sat, 9 May 2020 16:30:05 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 30wx1857fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:05 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 049GU5X0020315; Sat, 9 May 2020 16:30:05 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:30:04 -0700 Subject: [PATCH 02/16] xfs_repair: warn when we would have rebuilt a directory From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:30:05 -0700 Message-ID: <158904180502.982941.12047148158523698696.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=977 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090140 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 a938e802..75e273c8 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -2426,6 +2426,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 Sat May 9 16:30: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: 11538423 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 DEFA215AB for ; Sat, 9 May 2020 16:32:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C73EF2184D for ; Sat, 9 May 2020 16:32:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="IugF8J5Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728410AbgEIQct (ORCPT ); Sat, 9 May 2020 12:32:49 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50822 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728323AbgEIQcp (ORCPT ); Sat, 9 May 2020 12:32:45 -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 049GMgWj072358; Sat, 9 May 2020 16:32:44 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=f++7BFIHVMBNgLAEB8a0e8OUHCMIqY5TfZTmLGsT4CM=; b=IugF8J5ZOdEADyYSEp4JA6NGCnv4JNv+ThjH7a+zAa+KCIiiMPnV3UagV/su48pI9+Ph 3f/F0jnFcoKbJHysYbq3sAZD3KIUFdw2gAF2TCWksoCxVeCQLB0dBDHiu6tIpYlCFSw5 Z06qM+qO/tji31n5hX66jYfKfJB0RuPc2UMaFpLep4xi0gUMYcTjvZMYPA5NCzuZjVDg vBnzQu23nHpU0MWCRUDBHgUnpTVhRU+w6G4nbbAiMhhQ8bmcDQP8ltWzX+AsZJRvo18b dFBnd4w7BS3DZjgnmSX0EzFgMYbcey/lmaz0DkT/FwJJd9Nglc/gifNfsC7z84xRo5u7 RA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 30wkxqs6jk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:43 +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 049GWaN1118560; Sat, 9 May 2020 16:32:43 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 30wwwpnjdf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:42 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 049GUBFM020319; Sat, 9 May 2020 16:30:11 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:30:11 -0700 Subject: [PATCH 03/16] xfs_repair: check for AG btree records that would wrap around From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:30:11 -0700 Message-ID: <158904181121.982941.11919205494567354626.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090139 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 Sat May 9 16:30:17 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: 11538407 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 62808912 for ; Sat, 9 May 2020 16:32:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49EE220735 for ; Sat, 9 May 2020 16:32:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="kDgxyjUE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728065AbgEIQce (ORCPT ); Sat, 9 May 2020 12:32:34 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38874 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728053AbgEIQce (ORCPT ); Sat, 9 May 2020 12:32:34 -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 049GRVKB196418; Sat, 9 May 2020 16:32:33 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=Iu8vn0gwJmpVl6FBPO7HEUlXZJazdRsBWNbbNCO+XO0=; b=kDgxyjUEfh2tlEqlqwt3l5EJl/JZkO4Ou8n5f2x2IUOitg+Dcuqus/KQzGZwrUrrDbnV TWfmyexpe8yFm4ZF9calOHYEaymAqiXa072RIVUM8oIyVBQwthwn+hN9W8ZGlhIddHzd 6MLJtVIQB2vhuh/9cdioph8QRMT1xrqNg3frgIGG22+zIVbUyzkWA3bwAp9Cv3qDHawh n0LawoywTdyvjHB7dGXDlt+tksBUA5eEVazlf4a4EkfAYCBAZE3mpfMBJvH3KVYAfSh4 Y4M8KK0oXGAtULkP6wNtltpHKXKKvP/fMAMJeAt4Y1IkCWvzi6+tkinq+6RL/IB1sB5x CQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 30wmfm1540-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:33 +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 049GWU32117376; Sat, 9 May 2020 16:32:32 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 30wwwpnjh2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:30 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 049GUIG5020462; Sat, 9 May 2020 16:30:18 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:30:17 -0700 Subject: [PATCH 04/16] xfs_repair: fix bnobt and refcountbt record order checks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:30:17 -0700 Message-ID: <158904181736.982941.3404117959961230293.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090140 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 Sat May 9 16:30:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11538381 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 660D6912 for ; Sat, 9 May 2020 16:30:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DD7020735 for ; Sat, 9 May 2020 16:30:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ePN9jUxu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728005AbgEIQa1 (ORCPT ); Sat, 9 May 2020 12:30:27 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:49344 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQa1 (ORCPT ); Sat, 9 May 2020 12:30:27 -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 049GMgq6072468; Sat, 9 May 2020 16:30:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=V4PTRXsPW6H9tFpKgl1/9RL1RSD94gFHz5PqHdB8qJk=; b=ePN9jUxuqHOvJQE+Jht4scwNOe63CkHU1t5hpdmNfsy8CXS/N69JmqCxpctHhsGZc1sC CRG5S1vYsss5p1IUxo81GuLq0twAoPbNvbof1NFN2A8RjQ+qWOjnl1hdzETNnTfy5FX0 3JnJgtwVloxQLzuxOlBtNHurLpD2vDkMpbyS6rSvHObxWss25ghfTHxn1o0onF3rJL56 8bLB8N7kJgXFRtoHO7nS+rWgFbIH72IzXojytJUi2KIL704zPmtlcY3p4AYrnrTtuzRH 1u3C9baFXDx9zNHlUBXM8HQ8sbR4EUxt8Pu3A07kfUmDVrvPDl3lbz3VmH5uxFmd2Mom KQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30wkxqs6ed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:25 +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 049GTurh112443; Sat, 9 May 2020 16:30:25 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 30wx11cutv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:25 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 049GUOmp025757; Sat, 9 May 2020 16:30:24 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:30:24 -0700 Subject: [PATCH 05/16] xfs_repair: check for out-of-order inobt records From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:30:24 -0700 Message-ID: <158904182463.982941.12723858451786554882.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090139 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 Sat May 9 16:30:30 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: 11538383 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 55F5214B4 for ; Sat, 9 May 2020 16:30:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D86F2184D for ; Sat, 9 May 2020 16:30:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="k4htYjNh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728447AbgEIQai (ORCPT ); Sat, 9 May 2020 12:30:38 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:37580 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQai (ORCPT ); Sat, 9 May 2020 12:30:38 -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 049GRVQ8196372; Sat, 9 May 2020 16:30:37 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=yLSkf1XjnC0SCOr9oGqevu2jBGt+Mo2b7FRJ5P0p0LM=; b=k4htYjNhAxtrh3nTRBrmNnRfunPq/fxKftMSpwhmsWT9gKH1yDFqveqf8Q6YohDkjZ8o OEQPMhB11LB9H2nzqAqcO5ds9k1U0ry0Y97y+BzC43cRTWzqXalQ3/xqvIjMkzXtHxfF i+hyznEBzJw0sWUBJpxXOzjKz2g4BCaCztB+fUi6bthSaKQ3lUpJgylXdS7Xs7c9sLdF eEhWXuHNkcOxYTnxfNqgrKB3B56FdDASxDDiAlm2987qkR8xkHr2JLVcmyl+asa1vzWc maX+sg2RJdHn/eyfq7j6UwBvMQnxfAIcO6maB6KWMlidcaRNQ+YVJueMfNRmx6TQjp4b 3Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 30wmfm150m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:36 +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 049GTJrc097801; Sat, 9 May 2020 16:30:36 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 30wx1857wm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:36 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 049GUal6020499; Sat, 9 May 2020 16:30:36 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:30:35 -0700 Subject: [PATCH 06/16] xfs_repair: fix rmapbt record order check From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:30:30 -0700 Message-ID: <158904183079.982941.15948246247495283555.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090140 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 Sat May 9 16:30:42 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: 11538421 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 9952415AB for ; Sat, 9 May 2020 16:32:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 811EF20735 for ; Sat, 9 May 2020 16:32:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="kYXG2hd+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728348AbgEIQcp (ORCPT ); Sat, 9 May 2020 12:32:45 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50814 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727863AbgEIQco (ORCPT ); Sat, 9 May 2020 12:32:44 -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 049GMgTs072385; Sat, 9 May 2020 16:32: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=CeG4LjkC8zgOjL5UIuqXmW6sr/ZBjbyNImx/p/ZlNhk=; b=kYXG2hd+lW7qLTtwTgYo8sORMHJEd5kq1NSmcebwdI5O1NGQY8Upr7FcYci+M+sUin4x g3daHrdVP1pPdBHFF6pOQTuU0aQat5wGsycvpz62cxzBj4kETNg1Gee8ylOKXlDy2WpY bBMDn/0t1fGq+Gaf3ihTtoBALrS1wMqemkvF306ZrsTLkT6lKfclJ3bN4t0dLohiCDcM xRuyvZnTu4Cv9dogqdD2ivI4jMmTlYleLujX1N1OwPMJsgYUj+KZjwRK0a1UaDm+fV2d 40dJMcqOnH1yRIMjoLdzmKAAQ/7+7RxEsbfoCSVQRF989yf9cIOOBHUUORFrH7PuyDX7 Yg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 30wkxqs6jj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:43 +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 049GRdtk132601; Sat, 9 May 2020 16:30:42 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 30wwxb5hmr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30: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 049GUgS0025865; Sat, 9 May 2020 16:30:42 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:30:41 -0700 Subject: [PATCH 07/16] xfs_repair: tag inobt vs finobt errors properly From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:30:42 -0700 Message-ID: <158904184198.982941.18130519450590388566.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090139 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 Sat May 9 16:30:48 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: 11538419 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 2240F912 for ; Sat, 9 May 2020 16:32:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09BBC2063A for ; Sat, 9 May 2020 16:32:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="I2ui8v9W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728244AbgEIQcn (ORCPT ); Sat, 9 May 2020 12:32:43 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38922 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727863AbgEIQcn (ORCPT ); Sat, 9 May 2020 12:32:43 -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 049GODwC064954; Sat, 9 May 2020 16:32:41 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=v5VFNryt1NupKWD/nU4TADy/N80IJVBueKidb1F+n9M=; b=I2ui8v9WbphELprwfPx9Zh/9T4krxPJVZsQoY3/2TWStxU6fgRzx0Y1U6r41gKczE+Cd bLRzam4XiuOhtLKhywPEUS2/eP6ImSIgT2xc2nVoI8JhGgV0R+BGzBYXlzaGN+sfMzUi IFN1tOZd9SEkC3G9q3SDFPhI0NZRzFus/0ePlWyrS9zfrWazs6z5RUP69XM/WEBtXv7D JD0GOyIE/kND8DYGlQFHgSLj4cvWWN1lZW/LMoBh2S0sH9E32wLovToNRaxFUPRes+G+ 7OY0HpeRKs4RKaniUtQIztjuxqNG1FxhetTyD4R2WhLkpYgMVeiCGE61OumjWQ7qsFyT oQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 30wx8n86rk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:41 +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 049GWVPA117431; Sat, 9 May 2020 16:32:40 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 30wwwpnjsc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:32 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 049GUmHD025272; Sat, 9 May 2020 16:30:48 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:30:48 -0700 Subject: [PATCH 08/16] xfs_repair: complain about bad interior btree pointers From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:30:48 -0700 Message-ID: <158904184818.982941.1861210055263598397.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090140 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 Sat May 9 16:30:54 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: 11538385 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 E826715AB for ; Sat, 9 May 2020 16:30:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CACA92063A for ; Sat, 9 May 2020 16:30:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="AGblrWiQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728451AbgEIQa6 (ORCPT ); Sat, 9 May 2020 12:30:58 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37648 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQa6 (ORCPT ); Sat, 9 May 2020 12:30:58 -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 049GO5VA064951; Sat, 9 May 2020 16:30:56 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=rAj1LsSlIP0qV7s64OtGwWZqQvR8hJiJ+de/nhpE7LM=; b=AGblrWiQrp9i5VbHKWOcyV9Y/4QjMhUhiFpK97UY0TryPFOolyOPgQsNUIUuqSn/uQ1k Lru5PqO6pEtmYa9XscahU4hqB5ZZPb3XTr6Loj8dFcWNpnfKct1xTDXTLe6082xRC2sZ OYhl2eYtP/OLsTtHCoSbJkB8O1YNoT6jovCORdrDSz+nhQ+PYtx511UeJ3zYXK5m9327 irqRzjmA5K3IaJIknjEBuh6diVq3TUkx09QfWCZpYy4KZyG8tisP0NKUWBkwQSamTpTM BE8k64OFKntO6Wc41VrqIlHWxm96YK3ZiBc7BWftEAuCnGRhCGdlMlzKTw9BvJp51QGP 5w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30wx8n86nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:56 +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 049GRdQl132594; Sat, 9 May 2020 16:30:55 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 30wwxb5hrk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:30:55 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 049GUski025275; Sat, 9 May 2020 16:30:54 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:30:54 -0700 Subject: [PATCH 09/16] xfs_repair: convert to libxfs_verify_agbno From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:30:54 -0700 Message-ID: <158904185435.982941.16817943726460132539.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=2 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=2 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090140 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. 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 Sat May 9 16:31:00 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: 11538387 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 E8795912 for ; Sat, 9 May 2020 16:31:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D15D42184D for ; Sat, 9 May 2020 16:31:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="eHaJAYUq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728454AbgEIQbF (ORCPT ); Sat, 9 May 2020 12:31:05 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37762 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQbF (ORCPT ); Sat, 9 May 2020 12:31:05 -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 049GPSev065598; Sat, 9 May 2020 16:31:03 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/8p2pSeNLN8oDv4pZtCefxvMMy0j4OvXk/HXcJH2lk=; b=eHaJAYUqJcpRCb4Tl8rvyv9JRLQYOCNKaJ6rQ7GL0HFuNcCDQod+kH+TrgYNE8tOsarg tRATmEEsprIncIu0gzGSrbF5cwvzue2KbagJRxB3YpvOd8CvF1EtaKxPK1saD37e1FiU xUjaJ+rD8Xop6VUECLDAkSgmQM4XQShWNW/yqli5myuIWBdkQy+Z2Zr6aCZDidHRByWd PrM9H++fnqNMyOPuSybx0fRIOTU0qCZFzTIqQ66A9Fz4UFt+6Zjf+SE9qt5QUoQl3HFb WhwXrP3zlgA1uHiJB6Plh+6X2QrcHdI5gP7ez91s2xmsKb6Mm5gTAudPZShBKVqvP5C9 aQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30wx8n86pa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:03 +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 049GRcFv132516; Sat, 9 May 2020 16:31:02 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 30wwxb5hux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:02 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 049GV1xU004762; Sat, 9 May 2020 16:31:01 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:31:01 -0700 Subject: [PATCH 10/16] xfs_repair: refactor verify_dfsbno_range From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:31:00 -0700 Message-ID: <158904186058.982941.7156787817804393560.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090140 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 Sat May 9 16:31: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: 11538389 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 A2FF6912 for ; Sat, 9 May 2020 16:31:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BF012184D for ; Sat, 9 May 2020 16:31:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="b8lxfkMv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728461AbgEIQbL (ORCPT ); Sat, 9 May 2020 12:31:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:49862 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQbK (ORCPT ); Sat, 9 May 2020 12:31:10 -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 049GMgwi072397; Sat, 9 May 2020 16:31:09 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=CiA2b95hoQaB/sQS5G8YbHsKYaCHbPAeA56x08MD670=; b=b8lxfkMvmK+KH3TgJ/HbB8Ln8/eQxPiJpbC1hk4WYS226JPDL1AAxzK7gL4zdCVUAeqo wXVp907NFuegUeQHTfPi+AR0Cw/+DjRAXdxWohfnDX9p7jC+NM0NTPRdMixQ+q8YKI/F iJ4xPhfvHSJ+jHqCjQtHm6NviXYnV3QlnK9eKCiaZf/q0QSK60Sel8NiS9IidiA1pUC3 UMfa6jXEmxiVoBZEC0DMIFnDciS7VigX8QoHao5n9jmkPH/6pmwW6hw6VMR/dXLu/XlP SkP8e5EEGXdj6sT9Pw7IrjCrl4FpplVxdIT5YPnPeYcXXcV+CgbdlY/5XKbGU6xOv8Sj /Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 30wkxqs6fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:09 +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 049GRcoc132545; Sat, 9 May 2020 16:31:08 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 30wwxb5hww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:08 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 049GV8ud025342; Sat, 9 May 2020 16:31:08 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:31:07 -0700 Subject: [PATCH 11/16] xfs_repair: remove verify_dfsbno From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:31:07 -0700 Message-ID: <158904186786.982941.13402008407746781785.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=2 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=2 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090139 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 Sat May 9 16:31:14 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: 11538391 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 5289D15AB for ; Sat, 9 May 2020 16:31:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 395772063A for ; Sat, 9 May 2020 16:31:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="TTiam2tD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728463AbgEIQbR (ORCPT ); Sat, 9 May 2020 12:31:17 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:49948 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQbR (ORCPT ); Sat, 9 May 2020 12:31:17 -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 049GMgk3072364; Sat, 9 May 2020 16:31:15 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=yWBFdkd+DNqSoqE0nFsLFgOqVs3wQ2lUD7iFo+mXkU0=; b=TTiam2tDhAYfiY1cfUZicC5YinVz9ZPG7aC3Y75SXqNXXMjdC3OZt+L2GPUpmTWN8/jB 8fISRLCYPioF5ujIPWOzo+hcGChvtrEmgh4jrvqPgBw2r5UnQ8BytWiolSqh1zX7GISF DVfxYIV7KkgwQVvtKhjjZz+lq8tQWNoOGbTUZS7UOvQcFjx2gFtw9Q+e3cPkyYXMmV4d 72v2qcDextL0NTHupJaoceoQP4tl617iPG4kMmsA+NZughwwSMQr8USYHQARQh3Oc9JY 7OcZZubZcykfl7saXmjdedRVzUVHDA6ZWRxa0ew+oYQznEwLqzSNwF4Z/eFprN1pB3rs KA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30wkxqs6fq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:15 +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 049GTu8w112530; Sat, 9 May 2020 16:31:14 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 30wx11cvcv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:14 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 049GVERp026015; Sat, 9 May 2020 16:31:14 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:31:13 -0700 Subject: [PATCH 12/16] xfs_repair: remove verify_aginum From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:31:14 -0700 Message-ID: <158904187403.982941.11165171953121545705.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090139 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 Sat May 9 16:31:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11538415 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 D3B4115AB for ; Sat, 9 May 2020 16:32:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEB0B2184D for ; Sat, 9 May 2020 16:32:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hSVAeicv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgEIQcj (ORCPT ); Sat, 9 May 2020 12:32:39 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50736 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727863AbgEIQcj (ORCPT ); Sat, 9 May 2020 12:32:39 -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 049GMgq1072390; Sat, 9 May 2020 16:32:37 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=Y3JLv4WzXAz0sZTCbqLX8b5a8FGWgnaMYxqrtjCtXmQ=; b=hSVAeicveZnCGmY9oFWJ4v76u1Us6CrmYsyHxe7ukEH4S6p1BYIhf4A4wedocT3sSCBC Mx8vKBmCzr8JVNP3TyvkXMAuuFwu3UGK96DUYgcIrfLzMjrqVNawxaUbc31bOJwcuHqZ 9addo0zqGgeC0bi4jS24SciPmnKCrZ34OJexvVvSbBP0T07ANuVS4Z1hYxmjlomvCovF KbCsUaAmEF0Xk45crnxmaHYszVmhIVCDYrXZw/K/b5Ow97ZP7KxHMjEAdEOC0gAv2UvE VIF29RFNT+T0A169vZ5o+uyMuvrj7rItxyQIp2NinGQmBzcqvRiHMkjxL7GhKFRMIYAV Xg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 30wkxqs6j6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:37 +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 049GWVob117487; Sat, 9 May 2020 16:32:36 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 30wwwpnk3g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:31 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 049GVKEV025464; Sat, 9 May 2020 16:31:20 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:31:20 -0700 Subject: [PATCH 13/16] xfs_repair: mark entire free space btree record as free1 From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:31:20 -0700 Message-ID: <158904188022.982941.11510270346760102443.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=2 malwarescore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=2 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090139 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 Sat May 9 16:31:26 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: 11538393 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 246B615AB for ; Sat, 9 May 2020 16:31:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C14A20735 for ; Sat, 9 May 2020 16:31:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="IA9TNS8e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728467AbgEIQba (ORCPT ); Sat, 9 May 2020 12:31:30 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50046 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728371AbgEIQba (ORCPT ); Sat, 9 May 2020 12:31:30 -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 049GMgWi072358; Sat, 9 May 2020 16:31: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=93kcITJPBGmsmP93nLZWoLRoycKunbQGeMuqK6ma1p0=; b=IA9TNS8eizA0NChTk4wHpIvZHB/stxG8LUZtPOn4op8woe9VZV1zppe59A4uFn0nFmaZ PN4fir0ykVVwlBFZ9y/pUfYQJ7zOYCCtK3S2ICnmr9i04StlFpV1moc7gNlgLdJbX79i bkg4+eniQrB/9QM1hKMQ1+WICEkRKhR7oFW0KLTWwqQG6C/BC5albWVcIQBuFUNbQ7Ae o6MvttgLc1rt4LsAATObH62rP2fllhcc/VUCGCVQnOJP9qvMt9F8GokTfX6pFBGFZDf0 mvebmt7JO7pAeY+uesQcp16kw/Er4z9j8t6zNLGanOnHJbiEdMl1g+AG+lbM3hAbH8y/ UQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 30wkxqs6fx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:28 +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 049GTIVU097742; Sat, 9 May 2020 16:31:27 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 30wx18589h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:27 +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 049GVQpI026021; Sat, 9 May 2020 16:31:26 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:31:26 -0700 Subject: [PATCH 14/16] xfs_repair: complain about free space only seen by one btree From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:31:26 -0700 Message-ID: <158904188639.982941.5408652247371014933.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=2 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=2 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090139 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 Sat May 9 16:31:32 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: 11538427 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 CE74B912 for ; Sat, 9 May 2020 16:34:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4FE5206D6 for ; Sat, 9 May 2020 16:34:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="q9Hq8Yzf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbgEIQeg (ORCPT ); Sat, 9 May 2020 12:34:36 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:40118 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727790AbgEIQeg (ORCPT ); Sat, 9 May 2020 12:34:36 -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 049GRVrm196495; Sat, 9 May 2020 16:34: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=Fdf52R4FgDG8+87NbjhQUrm6qxcxC2rdXAbHCCmuCDI=; b=q9Hq8YzfII5rbdtb+1XNYbcWCkKUxEAAT5X1/llbvOHYyjH+jrOKzU6p6jjKO7LCYzs/ Ngkb+IvRbXuJKR6B2k2U0liK/h3NM9ZDmFlR9boU3nMjsQ17ag70awBJIf+aem8OqSX+ FkV6J3FnrtvMbrOIaWuRODehaH/NzmF7ld9gvA/PY5T9+E9lIV800TF3kv4slq+WdIXh JkiWeAfYkwlFXrkcR5qjP/M/dhNTb8c3XDbwMYxVXwaLmdfqk4LgThD7fxY0GhW91Ped rbi3AB1+WnY4P8tB0ENodUq5Xh7A+Yf+yPXUCnAoukTMiSLhzMMV4EtraSUXFC6X75xR ig== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 30wmfm157k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:34:34 +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 049GWUNc117316; Sat, 9 May 2020 16:32:34 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 30wwwpnk5y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:32:32 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 049GVWgU020810; Sat, 9 May 2020 16:31:32 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:31:32 -0700 Subject: [PATCH 15/16] xfs_repair: complain about extents in unknown state From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:31:32 -0700 Message-ID: <158904189253.982941.5576924652917825655.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=2 malwarescore=0 mlxlogscore=996 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=2 clxscore=1015 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090140 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 Sat May 9 16:31: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: 11538395 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 011A5912 for ; Sat, 9 May 2020 16:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDE4A20735 for ; Sat, 9 May 2020 16:31:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="yPLeu53o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728073AbgEIQbm (ORCPT ); Sat, 9 May 2020 12:31:42 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50154 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727953AbgEIQbm (ORCPT ); Sat, 9 May 2020 12:31:42 -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 049GMgTp072385; Sat, 9 May 2020 16:31: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=0Qtg7UjJxFWWTPtNUYmwhjV+9UYKWURXZ/RAYms1+QE=; b=yPLeu53owU+KaXgaa1jomSo8ymnaf9f+VAdGc6tnCqZ9Vw/KcqQ3G4sgeq7gjR21sCjv 6MOFULoeD1SaExmy6W/QmaDsqLJSoTfBEkkCeo21AFV2COjk2yANGsafxtxw2BRiVTGU pXAlDmbtB2RPNh6jnFKdBDwe//1PoGCqtzXOa8PpG3AOJqcleAu7IyfCFa4hdbQhmEg+ cuedMuuOQ8TjBf9CJKK7hbmviAU0QTjBx1sE8rP6nhiOsqnHNN+QAP050TMi1DbkgbCg OhONeEX2ErKYHdN37YJ+rbxC4z8lHgz4jzwV7iPo3BPNgfVQscuSrIOOOvEO/iwvXLAH Zg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30wkxqs6g6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:40 +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 049GTuGp112434; Sat, 9 May 2020 16:31:39 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 30wx11cvnp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 May 2020 16:31:39 +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 049GVcHX005052; Sat, 9 May 2020 16:31:38 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 May 2020 09:31:38 -0700 Subject: [PATCH 16/16] xfs_repair: complain about any nonzero inprogress value, not just 1 From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sat, 09 May 2020 09:31:38 -0700 Message-ID: <158904189872.982941.14116905127710550275.stgit@magnolia> In-Reply-To: <158904179213.982941.9666913277909349291.stgit@magnolia> References: <158904179213.982941.9666913277909349291.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9616 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005090139 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); /*