From patchwork Tue Nov 10 18:03:09 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: 11894977 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 9D89D15E6 for ; Tue, 10 Nov 2020 18:03:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76D6C20829 for ; Tue, 10 Nov 2020 18:03:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qb9tw7Sz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbgKJSDY (ORCPT ); Tue, 10 Nov 2020 13:03:24 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57258 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgKJSDY (ORCPT ); Tue, 10 Nov 2020 13:03:24 -0500 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 0AAHxGjV018619; Tue, 10 Nov 2020 18:03: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=WWO0Txw5hyJURRBE0yZMOS8cpMVROxYR/z3Bu3bDYnA=; b=qb9tw7SzjSj1xe4/EEYkVefCYYRJ5xuo4+XfXrywZZEAm6ZzaCu9hGNDzuqHbO8zD1CF ZPR5ms7BRJLa6vIfWKTQTsNhnhyGm0qyrKo99ywt5YUZ+BOvDnaYBcVeDfKG2Sy0ggfO XZxYLVM4uXYUmoAKWP6o6NGCn9rsqCeyB87oQ6UO3fU6+DSAFR952w7EWxLVimJvmpYB /q2MAN5lQz8WiCV3VXvGd5F1Cr8mdBbaD4XY2M7ZSE1x237wqp6oMAT74Q392JNob++B Wo8fNFOM3q9qoNLZwMGhIfqaYLreQJp8NWYoLPfgQQPzvGx3hMKO/MEtMbcGre1+COpa oQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 34p72ek8jn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:03:14 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AAI15sJ092574; Tue, 10 Nov 2020 18:03:14 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 34qgp76kq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:03:14 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0AAI3BpC021102; Tue, 10 Nov 2020 18:03:12 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:03:10 -0800 Subject: [PATCH 1/9] mkfs: allow users to specify rtinherit=0 From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Allison Henderson , Eric Sandeen , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:03:09 -0800 Message-ID: <160503138929.1201232.16637882579026265131.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong mkfs has quite a few boolean options that can be specified in several ways: "option=1" (turn it on), "option" (turn it on), or "option=0" (turn it off). For whatever reason, rtinherit sticks out as the only mkfs parameter that doesn't behave that way. Let's make it behave the same as all the other boolean variables. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Eric Sandeen Reviewed-by: Christoph Hellwig --- mkfs/xfs_mkfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 8fe149d74b0a..908d520df909 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -349,7 +349,7 @@ static struct opt_params dopts = { }, { .index = D_RTINHERIT, .conflicts = { { NULL, LAST_CONFLICT } }, - .minval = 1, + .minval = 0, .maxval = 1, .defaultval = 1, }, @@ -1429,6 +1429,8 @@ data_opts_parser( case D_RTINHERIT: if (getnum(value, opts, subopt)) cli->fsx.fsx_xflags |= FS_XFLAG_RTINHERIT; + else + cli->fsx.fsx_xflags &= ~FS_XFLAG_RTINHERIT; break; case D_PROJINHERIT: cli->fsx.fsx_projid = getnum(value, opts, subopt); From patchwork Tue Nov 10 18:03:16 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: 11894975 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 63F54138B for ; Tue, 10 Nov 2020 18:03:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B41E20829 for ; Tue, 10 Nov 2020 18:03:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Gt3CNBv6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbgKJSDY (ORCPT ); Tue, 10 Nov 2020 13:03:24 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:52026 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbgKJSDY (ORCPT ); Tue, 10 Nov 2020 13:03:24 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AAHxq9o048718; Tue, 10 Nov 2020 18:03:19 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=EVrXdoZSwNoNa76nTzoL+175i3eg2OULFkT2ao3Ru8g=; b=Gt3CNBv6iZ7ph2PiXn3NJszxotqQA2mTdXFMK+yK4TmPU4272W/Ms2Ji9CYAJfI8BNMn HPN06d5Oy6ToC5NHPkSH0vaGMY7vqeu3pNFXLl235VSErVmz+WmDM2sSaMq8SGv0MWVq c/TngNQ75WJ6R+OPg7Zvt7mShUsGqOa8H682uVN426IZGb312ANchmQFDNIrayXzg5KB iE4+hjrxOYFfU5Fl1tfndJf/jqZWJq0IOkW7tsyBXn/25DL70v1/ef3z2XE5J+BwBpYB nhgOt6CyrKtrXpigss0YYr2wWfTb0omsKvj/42JCs7RJb7ecg6NuGI36NnB1wgItiP/s kA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 34nh3aw957-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:03:19 +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 0AAI1Ebb175653; Tue, 10 Nov 2020 18:03:19 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 34p55nx4hv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:03:19 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0AAI3Iha021161; Tue, 10 Nov 2020 18:03:18 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:03:17 -0800 Subject: [PATCH 2/9] mkfs: clarify valid "inherit" option values From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Eric Sandeen , linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:03:16 -0800 Message-ID: <160503139674.1201232.14186191797913715969.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1011 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Eric Sandeen Clarify which values are valid for the various *inherit= mkfs options. Signed-off-by: Eric Sandeen Reviewed-by: Darrick J. Wong [darrick: fix a few nits] Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- man/man8/mkfs.xfs.8 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8 index 0a7858748457..692daf2a9050 100644 --- a/man/man8/mkfs.xfs.8 +++ b/man/man8/mkfs.xfs.8 @@ -378,31 +378,40 @@ without stripe geometry alignment even if the underlying storage device provides this information. .TP .BI rtinherit= value -If set, all inodes created by +If +.I value +is set to 1, all inodes created by .B mkfs.xfs will be created with the realtime flag set. +The default is 0. Directories will pass on this flag to newly created regular files and directories. .TP .BI projinherit= value All inodes created by .B mkfs.xfs -will be assigned this project quota id. +will be assigned the project quota id provided in +.I value. Directories will pass on the project id to newly created regular files and directories. .TP .BI extszinherit= value All inodes created by .B mkfs.xfs -will have this extent size hint applied. +will have this +.I value +extent size hint applied. The value must be provided in units of filesystem blocks. Directories will pass on this hint to newly created regular files and directories. .TP .BI daxinherit= value -If set, all inodes created by +If +.I value +is set to 1, all inodes created by .B mkfs.xfs will be created with the DAX flag set. +The default is 0. Directories will pass on this flag to newly created regular files and directories. By default, From patchwork Tue Nov 10 18:03:22 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: 11894981 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 E23CB697 for ; Tue, 10 Nov 2020 18:03:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD2BC20781 for ; Tue, 10 Nov 2020 18:03:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="jTSKG9F7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726428AbgKJSD1 (ORCPT ); Tue, 10 Nov 2020 13:03:27 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57310 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbgKJSD1 (ORCPT ); Tue, 10 Nov 2020 13:03:27 -0500 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 0AAHxG3Y018668; Tue, 10 Nov 2020 18:03: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=sFzbgxO4uAdIzX90wlQXEWYw5GpnsTHh+AXiZZftmAc=; b=jTSKG9F7fH+JZPUKCXkgaJgydOBoxWY5PXuNiWmp3Tx1uW5ZYAFfsxhc6Np+QYX2WgXt qPybjB8/ybKlCy5l9vBZJ8SvJGAbzDm+nUuuTx7EJ0EGfzB6neNZyMum2WUes5QkSwfs ByR6wP29+NXL/VD2XoELq35rbu2QSrq0U2cceMNQTQ/rKbEeD988p3FJlV4j7iE2gzyq iZ1vgNW1L4SNodz2FGBT4j5zNIXAAoC+y5LE+2oBoOyRm6yKKKeNGhcC8rwi8DdfxVFl ahJlO2qjiT/tHf3Pm2G7LQ/C8xSF5CHyZ5NPJQIkqHir7RT8KduUY/qPfqaZrwr31j5S bg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 34p72ek8kw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:03:25 +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 0AAI0qPq081448; Tue, 10 Nov 2020 18:03:24 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 34p5g0p25n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:03:24 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0AAI3Oec004711; Tue, 10 Nov 2020 18:03:24 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:03:23 -0800 Subject: [PATCH 3/9] mkfs: don't pass on extent size inherit flags when extent size is zero From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:03:22 -0800 Message-ID: <160503140288.1201232.14448155271122385848.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=913 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=923 mlxscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong If the caller passes in an extent size hint of zero, clear the inherit flags because a hint value of zero is treated as not a hint. Otherwise, you get stupid stuff like: $ mkfs.xfs -d cowextsize=0 /tmp/a.img -f illegal CoW extent size hint 0, must be less than 9600. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- mkfs/xfs_mkfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 908d520df909..9989cf57c295 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1438,11 +1438,17 @@ data_opts_parser( break; case D_EXTSZINHERIT: cli->fsx.fsx_extsize = getnum(value, opts, subopt); - cli->fsx.fsx_xflags |= FS_XFLAG_EXTSZINHERIT; + if (cli->fsx.fsx_extsize) + cli->fsx.fsx_xflags |= FS_XFLAG_EXTSZINHERIT; + else + cli->fsx.fsx_xflags &= ~FS_XFLAG_EXTSZINHERIT; break; case D_COWEXTSIZE: cli->fsx.fsx_cowextsize = getnum(value, opts, subopt); - cli->fsx.fsx_xflags |= FS_XFLAG_COWEXTSIZE; + if (cli->fsx.fsx_cowextsize) + cli->fsx.fsx_xflags |= FS_XFLAG_COWEXTSIZE; + else + cli->fsx.fsx_xflags &= ~FS_XFLAG_COWEXTSIZE; break; case D_DAXINHERIT: if (getnum(value, opts, subopt)) From patchwork Tue Nov 10 18:03:29 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: 11894991 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 51C7F138B for ; Tue, 10 Nov 2020 18:05:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BD0E20781 for ; Tue, 10 Nov 2020 18:05:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="TPoHAs1Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbgKJSFg (ORCPT ); Tue, 10 Nov 2020 13:05:36 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:53946 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726557AbgKJSFg (ORCPT ); Tue, 10 Nov 2020 13:05:36 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AAHxvD2048936; Tue, 10 Nov 2020 18:05:32 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=yHilT37ysKKSl2UrqKLjocbCMkhcZdbTrl9pEBxAkgE=; b=TPoHAs1Q40HjgeGa2QkEkkO0ix88EwEoleqwUukV/UUVCpwHJjDdxw4J+Vh+N7coLHnt MgXx3U+JD9SesvjsCDuJEJEkVU+/NswKpo+r6RlER3pWlnvRtTlAg4bghblJcZQ3Xo8U lSQcWGErq98mt34HiN0WhY0lsxTcXWg9gdJU8nC54iO2BvnEV7yGKQiQqR1kQni5P4V0 PyQX6R9pQxx4Nt0cC5G7glSM6i91h5X/dz2p6Bdx51j/4l+QmgtZRjN6U7oWls5XAd66 4WnHHZWtZUeaOnSv9/1l2PUAVjYmNaheHniJ3d+tYhRScQJCXRmZskdRxNxYtMTrRN9P JA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 34nh3aw9g1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:05:32 +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 0AAI16Y9092659; Tue, 10 Nov 2020 18:03:31 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 34qgp76m07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:03:31 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0AAI3US2004782; Tue, 10 Nov 2020 18:03:30 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:03:30 -0800 Subject: [PATCH 4/9] xfs: remove unnecessary parameter from scrub_scan_estimate_blocks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Allison Henderson , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:03:29 -0800 Message-ID: <160503140903.1201232.5218288641888297738.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=2 mlxlogscore=999 impostorscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The only caller that cares about the file counts uses it to compute the number of files used, so return that and save a parameter. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig --- scrub/fscounters.c | 8 +++----- scrub/fscounters.h | 2 +- scrub/phase6.c | 7 +++---- scrub/phase7.c | 5 +---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/scrub/fscounters.c b/scrub/fscounters.c index e9901fcdf6df..9a240d49477b 100644 --- a/scrub/fscounters.c +++ b/scrub/fscounters.c @@ -116,7 +116,7 @@ scrub_count_all_inodes( } /* - * Estimate the number of blocks and inodes in the filesystem. Returns 0 + * Estimate the number of blocks and used inodes in the filesystem. Returns 0 * or a positive error number. */ int @@ -126,8 +126,7 @@ scrub_scan_estimate_blocks( unsigned long long *d_bfree, unsigned long long *r_blocks, unsigned long long *r_bfree, - unsigned long long *f_files, - unsigned long long *f_free) + unsigned long long *f_files_used) { struct xfs_fsop_counts fc; int error; @@ -141,8 +140,7 @@ scrub_scan_estimate_blocks( *d_bfree = fc.freedata; *r_blocks = ctx->mnt.fsgeom.rtblocks; *r_bfree = fc.freertx; - *f_files = fc.allocino; - *f_free = fc.freeino; + *f_files_used = fc.allocino - fc.freeino; return 0; } diff --git a/scrub/fscounters.h b/scrub/fscounters.h index 1fae58a6b287..13bd9967f004 100644 --- a/scrub/fscounters.h +++ b/scrub/fscounters.h @@ -9,7 +9,7 @@ int scrub_scan_estimate_blocks(struct scrub_ctx *ctx, unsigned long long *d_blocks, unsigned long long *d_bfree, unsigned long long *r_blocks, unsigned long long *r_bfree, - unsigned long long *f_files, unsigned long long *f_free); + unsigned long long *f_files_used); int scrub_count_all_inodes(struct scrub_ctx *ctx, uint64_t *count); #endif /* XFS_SCRUB_FSCOUNTERS_H_ */ diff --git a/scrub/phase6.c b/scrub/phase6.c index 8d976732d8e1..87828b60fbed 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -719,12 +719,11 @@ phase6_estimate( unsigned long long d_bfree; unsigned long long r_blocks; unsigned long long r_bfree; - unsigned long long f_files; - unsigned long long f_free; + unsigned long long dontcare; int ret; - ret = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, - &r_blocks, &r_bfree, &f_files, &f_free); + ret = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, &r_blocks, + &r_bfree, &dontcare); if (ret) { str_liberror(ctx, ret, _("estimating verify work")); return ret; diff --git a/scrub/phase7.c b/scrub/phase7.c index 96876f7c0596..bc652ab6f44a 100644 --- a/scrub/phase7.c +++ b/scrub/phase7.c @@ -111,8 +111,6 @@ phase7_func( unsigned long long d_bfree; unsigned long long r_blocks; unsigned long long r_bfree; - unsigned long long f_files; - unsigned long long f_free; bool complain; int ip; int error; @@ -160,7 +158,7 @@ phase7_func( } error = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, &r_blocks, - &r_bfree, &f_files, &f_free); + &r_bfree, &used_files); if (error) { str_liberror(ctx, error, _("estimating verify work")); return error; @@ -177,7 +175,6 @@ phase7_func( /* Report on what we found. */ used_data = cvt_off_fsb_to_b(&ctx->mnt, d_blocks - d_bfree); used_rt = cvt_off_fsb_to_b(&ctx->mnt, r_blocks - r_bfree); - used_files = f_files - f_free; stat_data = totalcount.dbytes; stat_rt = totalcount.rbytes; From patchwork Tue Nov 10 18:03:35 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: 11894983 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 2A5E9138B for ; Tue, 10 Nov 2020 18:03:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF89920797 for ; Tue, 10 Nov 2020 18:03:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="R38r6jF2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726467AbgKJSDl (ORCPT ); Tue, 10 Nov 2020 13:03:41 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:52302 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbgKJSDl (ORCPT ); Tue, 10 Nov 2020 13:03:41 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AAHxrkU048755; Tue, 10 Nov 2020 18:03: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=n5gua1aNZh11/qooSP2gzXWLdEBShhM785D9AwVkc0Y=; b=R38r6jF2MoBfjzg1hl/PznpzINvEkw9xZ56C81XQPi7B49lD6Z/jSas5a8KW1usCea6f hQdtvZ3DVrgfBvR26rrpKdO1Ubxof3//cb/0dVyF/Dq6NuVrUmDJk0hI7ZsjUIK0CPnc JTL3Fo5WgFfPg0nox4F/gYCCUr+8j9M/dOtVOpifGfM7rQ1reKslELdzCq2qv50seowm asQSCv2xOv7xlxEeNRDVRHb2suoTIG7xbFZ0DyUGpCWJ7kU26mentfU0K6GzF5S6jvpI D7vQs6HRNzB1TTIA+670c9SswQIwL85GtH6hKnV92t1KDrHcfDbEUd20slm7s9Pg1ciX KA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 34nh3aw96g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:03: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 0AAI0r0J081485; Tue, 10 Nov 2020 18:03:37 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 34p5g0p2bj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:03:37 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0AAI3a28004847; Tue, 10 Nov 2020 18:03:36 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:03:36 -0800 Subject: [PATCH 5/9] xfs_db: report ranges of invalid rt blocks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Allison Henderson , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:03:35 -0800 Message-ID: <160503141525.1201232.11579138078872600002.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Copy-pasta the block range reporting code from check_range into check_rrange so that we don't flood stdout with a ton of low value messages when a bit flips somewhere in rt metadata. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig --- db/check.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/db/check.c b/db/check.c index 553249dc9a41..5aede6cca15c 100644 --- a/db/check.c +++ b/db/check.c @@ -1569,19 +1569,46 @@ check_rootdir(void) } } +static inline void +report_rrange( + xfs_rfsblock_t low, + xfs_rfsblock_t high) +{ + if (low == high) + dbprintf(_("rtblock %llu out of range\n"), low); + else + dbprintf(_("rtblocks %llu..%llu out of range\n"), low, high); +} + static int check_rrange( xfs_rfsblock_t bno, xfs_extlen_t len) { xfs_extlen_t i; + xfs_rfsblock_t low = 0; + xfs_rfsblock_t high = 0; + bool valid_range = false; + int cur, prev = 0; if (bno + len - 1 >= mp->m_sb.sb_rblocks) { for (i = 0; i < len; i++) { - if (!sflag || CHECK_BLIST(bno + i)) - dbprintf(_("rtblock %llu out of range\n"), - bno + i); + cur = !sflag || CHECK_BLIST(bno + i) ? 1 : 0; + if (cur == 1 && prev == 0) { + low = high = bno + i; + valid_range = true; + } else if (cur == 0 && prev == 0) { + /* Do nothing */ + } else if (cur == 0 && prev == 1) { + report_rrange(low, high); + valid_range = false; + } else if (cur == 1 && prev == 1) { + high = bno + i; + } + prev = cur; } + if (valid_range) + report_rrange(low, high); error++; return 0; } From patchwork Tue Nov 10 18:03:41 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: 11894985 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 0E5FA697 for ; Tue, 10 Nov 2020 18:03:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEC2B207D3 for ; Tue, 10 Nov 2020 18:03:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="g2SyRqnJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbgKJSDs (ORCPT ); Tue, 10 Nov 2020 13:03:48 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57620 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbgKJSDs (ORCPT ); Tue, 10 Nov 2020 13:03:48 -0500 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 0AAHxGGv018638; Tue, 10 Nov 2020 18:03: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=zSSxh/JZ8Nt2nN6WaBm0QxRrw6WvA29Svi2OAulv8A8=; b=g2SyRqnJrW/kOfiyuIxmcQ8kCsUQrLPNQwdAO4ujBiJLD9NPBg/6obDRg+hWkMq2aufn DLB8YapLwOqX8fKAeTSs8gLLlvtvxDJg4qlulPMkhGjRjxCsIuA+l+u5z/2FZpcg4Xt2 zP+q9PbvBDXhjJXgRLY6ueC2UFfsFI4eIVUetFIHAYFXvpqIjpoBFJsUuF0qot+16hLR Llda3jp32veluehOpByJOAuaennFokDFHdjCz333fF3Gqn7NaXA5ZHZw1hbFtfeOqnXt tK4ugIOXZWFzc4QTFHF0WBhGFgmsOTjqkZ/wWZ023kocUkcNF4/uOZ2SDhrhTc6shVXi SQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 34p72ek8n4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:03:44 +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 0AAI16mc092721; Tue, 10 Nov 2020 18:03:43 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 34qgp76m86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:03:43 +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 0AAI3g1N012592; Tue, 10 Nov 2020 18:03:42 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:03:42 -0800 Subject: [PATCH 6/9] xfs_repair: skip the rmap and refcount btree checks when the levels are garbage From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Allison Henderson , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:03:41 -0800 Message-ID: <160503142152.1201232.17430855751236887491.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In validate_ag[fi], we should check that the levels of the rmap and refcount btrees are valid. If they aren't, we need to tell phase4 to skip the comparison between the existing and incore rmap and refcount data. The comparison routines use libxfs btree cursors, which assume that the caller validated bc_nlevels and will corrupt memory if we load a btree cursor with a garbage level count. This was found by examing a core dump from a failed xfs/086 invocation. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig --- repair/scan.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/repair/scan.c b/repair/scan.c index 42b299f75067..2a38ae5197c6 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -2279,23 +2279,31 @@ validate_agf( if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { struct rmap_priv priv; + unsigned int levels; memset(&priv.high_key, 0xFF, sizeof(priv.high_key)); priv.high_key.rm_blockcount = 0; priv.agcnts = agcnts; priv.last_rec.rm_owner = XFS_RMAP_OWN_UNKNOWN; priv.nr_blocks = 0; + + levels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]); + if (levels >= XFS_BTREE_MAXLEVELS) { + do_warn(_("bad levels %u for rmapbt root, agno %d\n"), + levels, agno); + rmap_avoid_check(); + } + bno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_RMAP]); if (libxfs_verify_agbno(mp, agno, bno)) { - scan_sbtree(bno, - be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]), - agno, 0, scan_rmapbt, 1, XFS_RMAP_CRC_MAGIC, - &priv, &xfs_rmapbt_buf_ops); + scan_sbtree(bno, levels, agno, 0, scan_rmapbt, 1, + XFS_RMAP_CRC_MAGIC, &priv, + &xfs_rmapbt_buf_ops); if (be32_to_cpu(agf->agf_rmap_blocks) != priv.nr_blocks) do_warn(_("bad rmapbt block count %u, saw %u\n"), priv.nr_blocks, be32_to_cpu(agf->agf_rmap_blocks)); - } else { + } else { do_warn(_("bad agbno %u for rmapbt root, agno %d\n"), bno, agno); rmap_avoid_check(); @@ -2303,20 +2311,28 @@ validate_agf( } if (xfs_sb_version_hasreflink(&mp->m_sb)) { + unsigned int levels; + + levels = be32_to_cpu(agf->agf_refcount_level); + if (levels >= XFS_BTREE_MAXLEVELS) { + do_warn(_("bad levels %u for refcountbt root, agno %d\n"), + levels, agno); + refcount_avoid_check(); + } + bno = be32_to_cpu(agf->agf_refcount_root); if (libxfs_verify_agbno(mp, agno, bno)) { struct refc_priv priv; memset(&priv, 0, sizeof(priv)); - scan_sbtree(bno, - be32_to_cpu(agf->agf_refcount_level), - agno, 0, scan_refcbt, 1, XFS_REFC_CRC_MAGIC, - &priv, &xfs_refcountbt_buf_ops); + scan_sbtree(bno, levels, agno, 0, scan_refcbt, 1, + XFS_REFC_CRC_MAGIC, &priv, + &xfs_refcountbt_buf_ops); if (be32_to_cpu(agf->agf_refcount_blocks) != priv.nr_blocks) do_warn(_("bad refcountbt block count %u, saw %u\n"), priv.nr_blocks, be32_to_cpu(agf->agf_refcount_blocks)); - } else { + } else { do_warn(_("bad agbno %u for refcntbt root, agno %d\n"), bno, agno); refcount_avoid_check(); From patchwork Tue Nov 10 18:03:47 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: 11894987 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 F371E138B for ; Tue, 10 Nov 2020 18:03:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD2AE207D3 for ; Tue, 10 Nov 2020 18:03:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="m6qwFRtT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726984AbgKJSD4 (ORCPT ); Tue, 10 Nov 2020 13:03:56 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:44212 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726706AbgKJSD4 (ORCPT ); Tue, 10 Nov 2020 13:03:56 -0500 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 0AAHxx66119657; Tue, 10 Nov 2020 18:03:51 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=YZu/M8AjjhTpEM04zYHY1t+TM74AstFK37Z7bGd6tjA=; b=m6qwFRtT45oRLwXG45E+1ilO+gYtdF/38OcDukiXpsChiglJePuLY8hu5deOH78YpbJy 7hrpRutHaS70HVmoEQBGUGrhNlLCi5T6YGYcyo+8UeG6w+kMF+ecAErLVXN/mrK7tkbG UxBje0ZmgRSWZq2Z1XSOVtksP2JwylSpwzKl0EousGSG7XrJOtr9sgAB0AyfCKzNQlDW FZwY7e1I1hJbWgyxwhe4/e4y2esDzLvLHdM/FwMWKNmIuGKjAfBXObzw2C33vtRlwcx6 rlUyOZk+aMeelXXtpWqKD2C4d/PJzDnqCCXrFFKIZSRmCs3jLrmsH5bwNs81AGtdp4NP bQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 34nkhkw1ud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:03:51 +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 0AAI17Nb092801; Tue, 10 Nov 2020 18:03:50 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 34qgp76me7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:03:50 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0AAI3n8c012655; Tue, 10 Nov 2020 18:03:49 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:03:48 -0800 Subject: [PATCH 7/9] xfs_repair: correctly detect partially written extents From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: Allison Henderson , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:03:47 -0800 Message-ID: <160503142782.1201232.6736994012975595971.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=2 mlxlogscore=999 lowpriorityscore=0 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Recently, I was able to create a realtime file with a 16b extent size and the following data fork mapping: data offset 0 startblock 144 (0/144) count 3 flag 0 data offset 3 startblock 147 (0/147) count 3 flag 1 data offset 6 startblock 150 (0/150) count 10 flag 0 Notice how we have a written extent, then an unwritten extent, and then another written extent. The current code in process_rt_rec trips over that third extent, because repair only knows not to complain about inuse extents if the mapping was unwritten. This loop logic is confusing, because it tries to do too many things. Move the phase3 and phase4 code to separate helper functions, then isolate the code that handles a mapping that starts in the middle of an rt extent so that it's clearer what's going on. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig --- repair/dinode.c | 180 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 112 insertions(+), 68 deletions(-) diff --git a/repair/dinode.c b/repair/dinode.c index c89f21e08373..028a23cd5c8c 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -176,76 +176,69 @@ verify_dfsbno_range( return XR_DFSBNORANGE_VALID; } + static int -process_rt_rec( +process_rt_rec_dups( struct xfs_mount *mp, - struct xfs_bmbt_irec *irec, xfs_ino_t ino, - xfs_rfsblock_t *tot, - int check_dups) + struct xfs_bmbt_irec *irec) { - xfs_fsblock_t b, lastb; + xfs_fsblock_t b; xfs_rtblock_t ext; - int state; - int pwe; /* partially-written extent */ - /* - * check numeric validity of the extent - */ - if (!libxfs_verify_rtbno(mp, irec->br_startblock)) { - do_warn( -_("inode %" PRIu64 " - bad rt extent start block number %" PRIu64 ", offset %" PRIu64 "\n"), - ino, - irec->br_startblock, - irec->br_startoff); - return 1; - } - - lastb = irec->br_startblock + irec->br_blockcount - 1; - if (!libxfs_verify_rtbno(mp, lastb)) { - do_warn( -_("inode %" PRIu64 " - bad rt extent last block number %" PRIu64 ", offset %" PRIu64 "\n"), - ino, - lastb, - irec->br_startoff); - return 1; - } - if (lastb < irec->br_startblock) { - do_warn( -_("inode %" PRIu64 " - bad rt extent overflows - start %" PRIu64 ", " - "end %" PRIu64 ", offset %" PRIu64 "\n"), - ino, - irec->br_startblock, - lastb, - irec->br_startoff); - return 1; - } - - /* - * set the appropriate number of extents - * this iterates block by block, this can be optimised using extents - */ - for (b = irec->br_startblock; b < irec->br_startblock + - irec->br_blockcount; b += mp->m_sb.sb_rextsize) { + for (b = rounddown(irec->br_startblock, mp->m_sb.sb_rextsize); + b < irec->br_startblock + irec->br_blockcount; + b += mp->m_sb.sb_rextsize) { ext = (xfs_rtblock_t) b / mp->m_sb.sb_rextsize; - pwe = irec->br_state == XFS_EXT_UNWRITTEN && - (b % mp->m_sb.sb_rextsize != 0); - - if (check_dups == 1) { - if (search_rt_dup_extent(mp, ext) && !pwe) { - do_warn( + if (search_rt_dup_extent(mp, ext)) { + do_warn( _("data fork in rt ino %" PRIu64 " claims dup rt extent," - "off - %" PRIu64 ", start - %" PRIu64 ", count %" PRIu64 "\n"), - ino, - irec->br_startoff, - irec->br_startblock, - irec->br_blockcount); - return 1; - } - continue; +"off - %" PRIu64 ", start - %" PRIu64 ", count %" PRIu64 "\n"), + ino, + irec->br_startoff, + irec->br_startblock, + irec->br_blockcount); + return 1; } + } + return 0; +} + +static int +process_rt_rec_state( + struct xfs_mount *mp, + xfs_ino_t ino, + struct xfs_bmbt_irec *irec) +{ + xfs_fsblock_t b = irec->br_startblock; + xfs_rtblock_t ext; + int state; + + do { + ext = (xfs_rtblock_t)b / mp->m_sb.sb_rextsize; state = get_rtbmap(ext); + + if ((b % mp->m_sb.sb_rextsize) != 0) { + /* + * We are midway through a partially written extent. + * If we don't find the state that gets set in the + * other clause of this loop body, then we have a + * partially *mapped* rt extent and should complain. + */ + if (state != XR_E_INUSE) + do_error( +_("data fork in rt inode %" PRIu64 " found invalid rt extent %"PRIu64" state %d at rt block %"PRIu64"\n"), + ino, ext, state, b); + b = roundup(b, mp->m_sb.sb_rextsize); + continue; + } + + /* + * This is the start of an rt extent. Set the extent state if + * nobody else has claimed the extent, or complain if there are + * conflicting states. + */ switch (state) { case XR_E_FREE: case XR_E_UNKNOWN: @@ -253,32 +246,83 @@ _("data fork in rt ino %" PRIu64 " claims dup rt extent," break; case XR_E_BAD_STATE: do_error( -_("bad state in rt block map %" PRIu64 "\n"), +_("bad state in rt extent map %" PRIu64 "\n"), ext); case XR_E_FS_MAP: case XR_E_INO: case XR_E_INUSE_FS: do_error( -_("data fork in rt inode %" PRIu64 " found metadata block %" PRIu64 " in rt bmap\n"), +_("data fork in rt inode %" PRIu64 " found rt metadata extent %" PRIu64 " in rt bmap\n"), ino, ext); case XR_E_INUSE: - if (pwe) - break; - /* fall through */ case XR_E_MULT: set_rtbmap(ext, XR_E_MULT); do_warn( -_("data fork in rt inode %" PRIu64 " claims used rt block %" PRIu64 "\n"), - ino, ext); +_("data fork in rt inode %" PRIu64 " claims used rt extent %" PRIu64 "\n"), + ino, b); return 1; case XR_E_FREE1: default: do_error( -_("illegal state %d in rt block map %" PRIu64 "\n"), - state, b); +_("illegal state %d in rt extent %" PRIu64 "\n"), + state, ext); } + b += mp->m_sb.sb_rextsize; + } while (b < irec->br_startblock + irec->br_blockcount); + + return 0; +} + +static int +process_rt_rec( + struct xfs_mount *mp, + struct xfs_bmbt_irec *irec, + xfs_ino_t ino, + xfs_rfsblock_t *tot, + int check_dups) +{ + xfs_fsblock_t lastb; + int bad; + + /* + * check numeric validity of the extent + */ + if (!libxfs_verify_rtbno(mp, irec->br_startblock)) { + do_warn( +_("inode %" PRIu64 " - bad rt extent start block number %" PRIu64 ", offset %" PRIu64 "\n"), + ino, + irec->br_startblock, + irec->br_startoff); + return 1; } + lastb = irec->br_startblock + irec->br_blockcount - 1; + if (!libxfs_verify_rtbno(mp, lastb)) { + do_warn( +_("inode %" PRIu64 " - bad rt extent last block number %" PRIu64 ", offset %" PRIu64 "\n"), + ino, + lastb, + irec->br_startoff); + return 1; + } + if (lastb < irec->br_startblock) { + do_warn( +_("inode %" PRIu64 " - bad rt extent overflows - start %" PRIu64 ", " + "end %" PRIu64 ", offset %" PRIu64 "\n"), + ino, + irec->br_startblock, + lastb, + irec->br_startoff); + return 1; + } + + if (check_dups) + bad = process_rt_rec_dups(mp, ino, irec); + else + bad = process_rt_rec_state(mp, ino, irec); + if (bad) + return bad; + /* * bump up the block counter */ From patchwork Tue Nov 10 18:03: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: 11894989 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 1D2D2697 for ; Tue, 10 Nov 2020 18:03:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9DE720797 for ; Tue, 10 Nov 2020 18:03:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="VfhiZhHe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729183AbgKJSD6 (ORCPT ); Tue, 10 Nov 2020 13:03:58 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57770 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726706AbgKJSD6 (ORCPT ); Tue, 10 Nov 2020 13:03:58 -0500 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 0AAHxGHo018036; Tue, 10 Nov 2020 18:03: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=E8jgLWq7yjXaMTZ8Vl8v3fCYOhF6ayx0xinO/KWHRgI=; b=VfhiZhHea9OQnEg12QhRDAwBzTL8R/aSdOZEjBK7h7mB6mD8X8E5XHqreTDkKdAJl91v zZeeobG4Na4VszphQS+h2zcuItDpDp15EvpdLUgTWpE3tpvmmVaXIOBdG6Nw9NNhee5Z dUDXbP/vl63CNd1IsEdx3TaQ2UTqW2qogxj1ngV0D6cO5ElvrjZ91zZanUEp3UTFoqIW Ugp1o8n8ej2hFHBPo+Tphs2e1ycA2qRRBsxgejcd6w1IZgaupun0mmJCoxHLAXe9RJXp fQX7azJ+wyMce5Ox41uT+2/kyLXoc/vz10c3vWCU3IWyw3txJhS4me3e1yDewheTC5bN Ew== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 34p72ek8p4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:03:56 +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 0AAI0ss5081611; Tue, 10 Nov 2020 18:03:55 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 34p5g0p2sf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:03:55 +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 0AAI3tCF012779; Tue, 10 Nov 2020 18:03:55 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:03:55 -0800 Subject: [PATCH 8/9] xfs_repair: directly compare refcount records From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:03:54 -0800 Message-ID: <160503143411.1201232.10096865635977108103.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Check that our observed refcount records have exact matches for what's in the ondisk refcount btree, since they're supposed to match exactly. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/rmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repair/rmap.c b/repair/rmap.c index a4cc6a4937c9..54451a7e262d 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -1402,8 +1402,8 @@ _("Missing reference count record for (%u/%u) len %u count %u\n"), /* Compare each refcount observation against the btree's */ if (tmp.rc_startblock != rl_rec->rc_startblock || - tmp.rc_blockcount < rl_rec->rc_blockcount || - tmp.rc_refcount < rl_rec->rc_refcount) + tmp.rc_blockcount != rl_rec->rc_blockcount || + tmp.rc_refcount != rl_rec->rc_refcount) do_warn( _("Incorrect reference count: saw (%u/%u) len %u nlinks %u; should be (%u/%u) len %u nlinks %u\n"), agno, tmp.rc_startblock, tmp.rc_blockcount, From patchwork Tue Nov 10 18:04: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: 11894993 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 1A2AE697 for ; Tue, 10 Nov 2020 18:06:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E436320781 for ; Tue, 10 Nov 2020 18:06:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="k1mQJlWS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730833AbgKJSGF (ORCPT ); Tue, 10 Nov 2020 13:06:05 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:46106 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730805AbgKJSGF (ORCPT ); Tue, 10 Nov 2020 13:06:05 -0500 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 0AAHxoxf119596; Tue, 10 Nov 2020 18:06: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=fDoXWcSJMPZIsqi7t8fb4TJkxNxeWLUck/vrCWHVz1s=; b=k1mQJlWS+3Zp0hfJR2Y4Zi8zlY7jW+HU1xiomjrob3Tjseq/0VvOkJNA6HSS0ag7KJfe C3t9FT5HaA3hYjYOKpCJ6HO++fp6E1xNenAovtpW4tRDFrbcZR+zoK4XtZZ3FcAJhbHH VufHqAQfnIIMXSK46ZqWF+T2gJM1Ppg+12L4qLPkiAdRjcCvCm5kXKIASVAVTMNqf/3S 4P+lR78OCLG6S+xS7UI4Q2o9jYbpTRvtCrxViZ/WZOmvk+4GS3lftzO+Urg8E1TY0M9M d2kA5CGajwkMNJ67NLDbq/EEaxOy+Vx/iJDfzrPyU6jO3ucwHex830fr/Akb3Xzsu2/q vQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 34nkhkw275-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 18:06:03 +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 0AAI178d092870; Tue, 10 Nov 2020 18:04:02 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 34qgp76mrp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 18:04:02 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0AAI41Sj021944; Tue, 10 Nov 2020 18:04:01 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 10:04:01 -0800 Subject: [PATCH 9/9] libxfs-apply: don't add duplicate headers From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Tue, 10 Nov 2020 10:04:00 -0800 Message-ID: <160503144025.1201232.11112616423278752638.stgit@magnolia> In-Reply-To: <160503138275.1201232.927488386999483691.stgit@magnolia> References: <160503138275.1201232.927488386999483691.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100126 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong When we're backporting patches from libxfs, don't add a S-o-b header if there's already one in the patch being ported. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- tools/libxfs-apply | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/libxfs-apply b/tools/libxfs-apply index 3258272d6189..35cdb9c3449b 100755 --- a/tools/libxfs-apply +++ b/tools/libxfs-apply @@ -193,6 +193,14 @@ filter_xfsprogs_patch() rm -f $_libxfs_files } +add_header() +{ + local hdr="$1" + local hdrfile="$2" + + grep -q "^${hdr}$" "$hdrfile" || echo "$hdr" >> "$hdrfile" +} + fixup_header_format() { local _source=$1 @@ -280,13 +288,13 @@ fixup_header_format() sed -i '${/^[[:space:]]*$/d;}' $_hdr.new # Add Signed-off-by: header if specified - if [ ! -z ${SIGNED_OFF_BY+x} ]; then - echo "Signed-off-by: $SIGNED_OFF_BY" >> $_hdr.new + if [ ! -z ${SIGNED_OFF_BY+x} ]; then + add_header "Signed-off-by: $SIGNED_OFF_BY" $_hdr.new else # get it from git config if present SOB_NAME=`git config --get user.name` SOB_EMAIL=`git config --get user.email` if [ ! -z ${SOB_NAME+x} ]; then - echo "Signed-off-by: $SOB_NAME <$SOB_EMAIL>" >> $_hdr.new + add_header "Signed-off-by: $SOB_NAME <$SOB_EMAIL>" $_hdr.new fi fi