From patchwork Tue Dec 1 03:37:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11941809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC77EC71156 for ; Tue, 1 Dec 2020 03:38:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99F6E20796 for ; Tue, 1 Dec 2020 03:38:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="J4pEmyLI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727767AbgLADiK (ORCPT ); Mon, 30 Nov 2020 22:38:10 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:60062 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727719AbgLADiK (ORCPT ); Mon, 30 Nov 2020 22:38:10 -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 0B13Stlx065761; Tue, 1 Dec 2020 03:37: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=5+2M8DidoMXwzBumheTOauduYlG2/kr4cmaArnwHRLo=; b=J4pEmyLI2FCDn5wPXmlpoo9Lj/rhrVF4/nZKIkjk5iEkZBECFABp2nqhiCa5yhKAX64D YkppnaBUVtMlxiS/VdCmoByxpo6nwtXK4sKWo/eTfpehDEavjGn2mjMrrmY9eG/P1T9H hDbx9feyJfCq0L6otXbqhmTRQYfi1hWPQPV460n3fi8PeLWaebc2mwDhrNIvRI3asVCt IgZbd0MjSuirye7+/Xk1V5gdfC/tE/n/sHt8cnQWOq1+R2pjOvmXSStpiYYWCQScAuRu dB7B/Os8cEqTvc8ncb8wGdwMDPG/fzGQfdR2iGd7lwFjowrUyqyv6ktADp54pZhm1ikm KQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 353c2arhk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 01 Dec 2020 03:37:28 +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 0B13UIP2181296; Tue, 1 Dec 2020 03:37:27 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 3540arh7qv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Dec 2020 03:37:27 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0B13bQHs004979; Tue, 1 Dec 2020 03:37:26 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 30 Nov 2020 19:37:26 -0800 Subject: [PATCH 1/3] xfs: move kernel-specific superblock validation out of libxfs From: "Darrick J. Wong" To: darrick.wong@oracle.com, sandeen@sandeen.net Cc: linux-xfs@vger.kernel.org Date: Mon, 30 Nov 2020 19:37:25 -0800 Message-ID: <160679384513.447856.3675245763779550446.stgit@magnolia> In-Reply-To: <160679383892.447856.12907477074923729733.stgit@magnolia> References: <160679383892.447856.12907477074923729733.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9821 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012010023 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9821 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012010023 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong A couple of the superblock validation checks apply only to the kernel, so move them to xfs_mount.c before we start changing sb_inprogress. This also reduces the diff between kernel and userspace libxfs. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_sb.c | 23 ++++------------------- fs/xfs/libxfs/xfs_sb.h | 3 +++ fs/xfs/xfs_mount.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 5aeafa59ed27..a2c43fe38f64 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -223,6 +223,7 @@ xfs_validate_sb_common( struct xfs_dsb *dsb = bp->b_addr; uint32_t agcount = 0; uint32_t rem; + int error; if (!xfs_verify_magic(bp, dsb->sb_magicnum)) { xfs_warn(mp, "bad magic number"); @@ -382,16 +383,9 @@ xfs_validate_sb_common( return -EFSCORRUPTED; } - /* - * Until this is fixed only page-sized or smaller data blocks work. - */ - if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) { - xfs_warn(mp, - "File system with blocksize %d bytes. " - "Only pagesize (%ld) or less will currently work.", - sbp->sb_blocksize, PAGE_SIZE); - return -ENOSYS; - } + error = xfs_sb_validate_mount(mp, bp, sbp); + if (error) + return error; /* * Currently only very few inode sizes are supported. @@ -415,15 +409,6 @@ xfs_validate_sb_common( return -EFBIG; } - /* - * Don't touch the filesystem if a user tool thinks it owns the primary - * superblock. mkfs doesn't clear the flag from secondary supers, so - * we don't check them at all. - */ - if (XFS_BUF_ADDR(bp) == XFS_SB_DADDR && sbp->sb_inprogress) { - xfs_warn(mp, "Offline file system operation in progress!"); - return -EFSCORRUPTED; - } return 0; } diff --git a/fs/xfs/libxfs/xfs_sb.h b/fs/xfs/libxfs/xfs_sb.h index 92465a9a5162..ee0a5858dd47 100644 --- a/fs/xfs/libxfs/xfs_sb.h +++ b/fs/xfs/libxfs/xfs_sb.h @@ -42,4 +42,7 @@ extern int xfs_sb_get_secondary(struct xfs_mount *mp, struct xfs_trans *tp, xfs_agnumber_t agno, struct xfs_buf **bpp); +int xfs_sb_validate_mount(struct xfs_mount *mp, struct xfs_buf *bp, + struct xfs_sb *sbp); + #endif /* __XFS_SB_H__ */ diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 7110507a2b6b..7bc7901d648d 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -259,6 +259,37 @@ xfs_initialize_perag( return error; } +/* Validate the superblock is compatible with this mount. */ +int +xfs_sb_validate_mount( + struct xfs_mount *mp, + struct xfs_buf *bp, + struct xfs_sb *sbp) +{ + /* + * Don't touch the filesystem if a user tool thinks it owns the primary + * superblock. mkfs doesn't clear the flag from secondary supers, so + * we don't check them at all. + */ + if (XFS_BUF_ADDR(bp) == XFS_SB_DADDR && sbp->sb_inprogress) { + xfs_warn(mp, "Offline file system operation in progress!"); + return -EFSCORRUPTED; + } + + /* + * Until this is fixed only page-sized or smaller data blocks work. + */ + if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) { + xfs_warn(mp, + "File system with blocksize %d bytes. " + "Only pagesize (%ld) or less will currently work.", + sbp->sb_blocksize, PAGE_SIZE); + return -ENOSYS; + } + + return 0; +} + /* * xfs_readsb * From patchwork Tue Dec 1 03:37:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11941813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA7EC83011 for ; Tue, 1 Dec 2020 03:38:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E74C207FF for ; Tue, 1 Dec 2020 03:38:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Z4xomTVt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727771AbgLADiP (ORCPT ); Mon, 30 Nov 2020 22:38:15 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:60100 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727719AbgLADiO (ORCPT ); Mon, 30 Nov 2020 22:38:14 -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 0B13TjIl066001; Tue, 1 Dec 2020 03:37: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=LfH7ML5hvF37a0vB3N3W8myAMXUEs0/WbOa+YC/I5EU=; b=Z4xomTVtKA3ncnTmlf914esE7OWXNGtqmajZaZJHnCQpHSXAJ6xlvXOX31lIGukWIX2q 2pgCi9Bs/yJbCrgUR40qu6DZ1T52o8pafmosgJ6Z4Rs/CrnDjzqQ4u1UKrdH+T3YEtCC HNQyPmv6OXbCl/dQyoiLMouNUGb4JcimQwioij0tsjscVduGZxm1g6ktPkQalY4Wxv/A ZqXKUC3aB4c5U0xbWvJyPqiZXM3VIsvbWBQkfdG2MIrwWW2wy/23NZp7ruPEyGfs0cw2 PDNavtMMBmAxAYXXofivt1zGEBV7UZ/ZpUhoDZUcY0bbGHKdz7N1jU/yeo4ICbhTSxHm vA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 353c2arhkb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 01 Dec 2020 03:37:33 +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 0B13UOF6160869; Tue, 1 Dec 2020 03:37:32 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 35404mbvnw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Dec 2020 03:37:32 +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 0B13bW1V004991; Tue, 1 Dec 2020 03:37:32 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 30 Nov 2020 19:37:32 -0800 Subject: [PATCH 2/3] xfs: define a new "needrepair" feature From: "Darrick J. Wong" To: darrick.wong@oracle.com, sandeen@sandeen.net Cc: linux-xfs@vger.kernel.org Date: Mon, 30 Nov 2020 19:37:31 -0800 Message-ID: <160679385127.447856.3129099457617444604.stgit@magnolia> In-Reply-To: <160679383892.447856.12907477074923729733.stgit@magnolia> References: <160679383892.447856.12907477074923729733.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9821 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012010023 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9821 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012010023 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Define an incompat feature flag to indicate that the filesystem needs to be repaired. While libxfs will recognize this feature, the kernel will refuse to mount if the feature flag is set, and only xfs_repair will be able to clear the flag. The goal here is to force the admin to run xfs_repair to completion after upgrading the filesystem, or if we otherwise detect anomalies. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_format.h | 7 +++++++ fs/xfs/xfs_mount.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index dd764da08f6f..5d8ba609ac0b 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -468,6 +468,7 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ #define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ +#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \ @@ -584,6 +585,12 @@ static inline bool xfs_sb_version_hasinobtcounts(struct xfs_sb *sbp) (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT); } +static inline bool xfs_sb_version_needsrepair(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR); +} + /* * end of superblock version macros */ diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 7bc7901d648d..2853ad49b27d 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -266,6 +266,12 @@ xfs_sb_validate_mount( struct xfs_buf *bp, struct xfs_sb *sbp) { + /* Filesystem claims it needs repair, so refuse the mount. */ + if (xfs_sb_version_needsrepair(&mp->m_sb)) { + xfs_warn(mp, "Filesystem needs repair. Please run xfs_repair."); + return -EFSCORRUPTED; + } + /* * Don't touch the filesystem if a user tool thinks it owns the primary * superblock. mkfs doesn't clear the flag from secondary supers, so From patchwork Tue Dec 1 03:37:37 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: 11941811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AA87C83013 for ; Tue, 1 Dec 2020 03:38:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2212A20855 for ; Tue, 1 Dec 2020 03:38:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="P72HQJXZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgLADiV (ORCPT ); Mon, 30 Nov 2020 22:38:21 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:39176 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727719AbgLADiV (ORCPT ); Mon, 30 Nov 2020 22:38:21 -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 0B13TnfP147426; Tue, 1 Dec 2020 03:37:39 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=eBhwj7IBc6uVXCtwWcVcrmh0CBWahvtDgw8dO33diQQ=; b=P72HQJXZHIrWCwpPXAXiTw2KFggy59+pFquOeWnf0DPgoEKdik5d7ABEgUhLNMO0evPh RIRql8bG3fZ25Aa2FMEAyiyFNEg+c9k5seYLDq5tos0NxhjP0sxwRK0KozM7tdPT3PeO LjT1CNGQ5OipjrcxyuQ3gQgycPkEE9EmjpCihNQStt7iuunaIel7uxkpCb1HnAZkhj4T XrIUiN4z+Z2k5COM51JWLRlBIjcLdMT5gfkhslryqz/um0hMeN1NVa9EjmKFmVZCuggn onN7Cp/PSOca8WYe1Y99HHXl+Ig4onlUSy1s38nYJ+bVgsZZ+fO28XaoAoAOegOSXjir CA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 353egkgcqu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 01 Dec 2020 03:37:39 +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 0B13UNHx160699; Tue, 1 Dec 2020 03:37:38 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 35404mbvqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Dec 2020 03:37:38 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0B13bcHI013729; Tue, 1 Dec 2020 03:37:38 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 30 Nov 2020 19:37:38 -0800 Subject: [PATCH 3/3] xfs: enable the needsrepair feature From: "Darrick J. Wong" To: darrick.wong@oracle.com, sandeen@sandeen.net Cc: linux-xfs@vger.kernel.org Date: Mon, 30 Nov 2020 19:37:37 -0800 Message-ID: <160679385732.447856.1039349578089907881.stgit@magnolia> In-Reply-To: <160679383892.447856.12907477074923729733.stgit@magnolia> References: <160679383892.447856.12907477074923729733.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9821 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012010023 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9821 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012010023 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Make it so that libxfs recognizes the needsrepair feature. Note that the kernel will still refuse to mount these. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Eric Sandeen --- fs/xfs/libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 5d8ba609ac0b..f64eed3ccfed 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -473,7 +473,8 @@ xfs_sb_has_ro_compat_feature( (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \ XFS_SB_FEAT_INCOMPAT_META_UUID| \ - XFS_SB_FEAT_INCOMPAT_BIGTIME) + XFS_SB_FEAT_INCOMPAT_BIGTIME| \ + XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR) #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool From patchwork Fri Dec 4 01:13: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: 11950349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4ACFEC4361A for ; Fri, 4 Dec 2020 01:16:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2223224BE for ; Fri, 4 Dec 2020 01:16:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727293AbgLDBQR (ORCPT ); Thu, 3 Dec 2020 20:16:17 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:49064 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgLDBQR (ORCPT ); Thu, 3 Dec 2020 20:16:17 -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 0B4192Ec014328; Fri, 4 Dec 2020 01:15:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=A/1OlJc7GQyU6jX5fIqyztqAarUqmHY9XK9N8+JkOvQ=; b=pZsZguwKcCGCtBecYpFD3YrUF+QbFRYAV+/cpdjj3XD0BW6IAd5JHJtdUxCuHQycQ87G 4gf869fYab1i4Wkze8jHWCWnx0jTikrJ/EvrCjAqDdet8045NSBFNiHJxT+fMc0AuiOV Ah8/jvs1Ii/lhTD742HenmSHTDdm+O++JsclwqLY6CwW0GqOABNMkloz8QmASwBcGBzI 2IkUk/iPlgC7vkS9VTBkC9I35ljNF2N/f1LgVGKnIgY+AwwjnVeyBZtbciaw+uGxAtfU zifBxWc5j7wTMDBu8RSzmQ1Tye4Svw0hk6X1CuZsJEUIuvrcgpvLFyPLic8sqds/7vpT Pw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 353egm0ysv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 04 Dec 2020 01:15:32 +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 0B41BSQF157310; Fri, 4 Dec 2020 01:13:32 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 3540g2swuy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Dec 2020 01:13:31 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0B41DVHc025714; Fri, 4 Dec 2020 01:13:31 GMT Received: from localhost (/10.159.242.140) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 03 Dec 2020 17:13:30 -0800 Date: Thu, 3 Dec 2020 17:13:30 -0800 From: "Darrick J. Wong" To: sandeen@sandeen.net Cc: linux-xfs@vger.kernel.org Subject: [PATCH 4/3] xfs_db: support the needsrepair feature flag in the version command Message-ID: <20201204011330.GC629293@magnolia> References: <160679383892.447856.12907477074923729733.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <160679383892.447856.12907477074923729733.stgit@magnolia> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9824 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=3 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012040003 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9824 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 suspectscore=3 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012040003 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Teach the xfs_db version command about the 'needsrepair' flag, which can be used to force the system administrator to repair the filesystem with xfs_repair. Signed-off-by: Darrick J. Wong --- db/check.c | 5 ++ db/sb.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++++-- db/xfs_admin.sh | 6 ++ man/man8/xfs_admin.8 | 15 +++++ man/man8/xfs_db.8 | 5 ++ 5 files changed, 182 insertions(+), 8 deletions(-) diff --git a/db/check.c b/db/check.c index 33736e33e833..485e855e8b78 100644 --- a/db/check.c +++ b/db/check.c @@ -3970,6 +3970,11 @@ scan_ag( dbprintf(_("mkfs not completed successfully\n")); error++; } + if (xfs_sb_version_needsrepair(sb)) { + if (!sflag) + dbprintf(_("filesystem needs xfs_repair\n")); + error++; + } set_dbmap(agno, XFS_SB_BLOCK(mp), 1, DBM_SB, agno, XFS_SB_BLOCK(mp)); if (sb->sb_logstart && XFS_FSB_TO_AGNO(mp, sb->sb_logstart) == agno) set_dbmap(agno, XFS_FSB_TO_AGBNO(mp, sb->sb_logstart), diff --git a/db/sb.c b/db/sb.c index d09f653dcedf..2c13d44d9954 100644 --- a/db/sb.c +++ b/db/sb.c @@ -379,6 +379,11 @@ uuid_f( progname); return 0; } + if (xfs_sb_version_needsrepair(&mp->m_sb)) { + dbprintf(_("%s: filesystem needs xfs_repair\n"), + progname); + return 0; + } if (!strcasecmp(argv[1], "generate")) { platform_uuid_generate(&uu); @@ -501,6 +506,7 @@ do_label(xfs_agnumber_t agno, char *label) memcpy(&lbl[0], &tsb.sb_fname, sizeof(tsb.sb_fname)); return &lbl[0]; } + /* set label */ if ((len = strlen(label)) > sizeof(tsb.sb_fname)) { if (agno == 0) @@ -543,6 +549,12 @@ label_f( return 0; } + if (xfs_sb_version_needsrepair(&mp->m_sb)) { + dbprintf(_("%s: filesystem needs xfs_repair\n"), + progname); + return 0; + } + dbprintf(_("writing all SBs\n")); for (ag = 0; ag < mp->m_sb.sb_agcount; ag++) if ((p = do_label(ag, argv[1])) == NULL) { @@ -584,6 +596,7 @@ version_help(void) " 'version attr1' - enable v1 inline extended attributes\n" " 'version attr2' - enable v2 inline extended attributes\n" " 'version log2' - enable v2 log format\n" +" 'version needsrepair' - flag filesystem as requiring repair\n" "\n" "The version function prints currently enabled features for a filesystem\n" "according to the version field of its primary superblock.\n" @@ -620,6 +633,118 @@ do_version(xfs_agnumber_t agno, uint16_t version, uint32_t features) return 1; } +struct v5feat { + uint32_t compat; + uint32_t ro_compat; + uint32_t incompat; + uint32_t log_incompat; +}; + +static void +get_v5_features( + struct xfs_mount *mp, + struct v5feat *feat) +{ + feat->compat = mp->m_sb.sb_features_compat; + feat->ro_compat = mp->m_sb.sb_features_ro_compat; + feat->incompat = mp->m_sb.sb_features_incompat; + feat->log_incompat = mp->m_sb.sb_features_log_incompat; +} + +static bool +set_v5_features( + struct xfs_mount *mp, + const struct v5feat *upgrade) +{ + struct xfs_sb tsb; + struct v5feat old; + xfs_agnumber_t agno = 0; + xfs_agnumber_t revert_agno = 0; + + if (upgrade->compat == mp->m_sb.sb_features_compat && + upgrade->ro_compat == mp->m_sb.sb_features_ro_compat && + upgrade->incompat == mp->m_sb.sb_features_incompat && + upgrade->log_incompat == mp->m_sb.sb_features_log_incompat) + return true; + + /* Upgrade primary superblock. */ + if (!get_sb(agno, &tsb)) + goto fail; + + dbprintf(_("Upgrading V5 filesystem\n")); + + /* Save old values */ + old.compat = tsb.sb_features_compat; + old.ro_compat = tsb.sb_features_ro_compat; + old.incompat = tsb.sb_features_incompat; + old.log_incompat = tsb.sb_features_log_incompat; + + /* Update feature flags and force user to run repair before mounting. */ + tsb.sb_features_compat |= upgrade->compat; + tsb.sb_features_ro_compat |= upgrade->ro_compat; + tsb.sb_features_incompat |= upgrade->incompat; + tsb.sb_features_log_incompat |= upgrade->log_incompat; + tsb.sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; + libxfs_sb_to_disk(iocur_top->data, &tsb); + + /* Write new primary superblock */ + write_cur(); + if (!iocur_top->bp || iocur_top->bp->b_error) + goto fail; + + /* Update the secondary superblocks, or revert. */ + for (agno = 1; agno < mp->m_sb.sb_agcount; agno++) { + if (!get_sb(agno, &tsb)) { + agno--; + goto revert; + } + + /* Set features on secondary suepr. */ + tsb.sb_features_compat |= upgrade->compat; + tsb.sb_features_ro_compat |= upgrade->ro_compat; + tsb.sb_features_incompat |= upgrade->incompat; + tsb.sb_features_log_incompat |= upgrade->log_incompat; + libxfs_sb_to_disk(iocur_top->data, &tsb); + write_cur(); + + /* Write or abort. */ + if (!iocur_top->bp || iocur_top->bp->b_error) + goto revert; + } + + /* All superblocks updated, update the incore values. */ + mp->m_sb.sb_features_compat |= upgrade->compat; + mp->m_sb.sb_features_ro_compat |= upgrade->ro_compat; + mp->m_sb.sb_features_incompat |= upgrade->incompat; + mp->m_sb.sb_features_log_incompat |= upgrade->log_incompat; + mp->m_sb.sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; + + dbprintf(_("Upgraded V5 filesystem. Please run xfs_repair.\n")); + return true; + +revert: + /* + * Try to revert feature flag changes, and don't worry if we fail. + * We're probably in a mess anyhow, and the admin will have to run + * repair anyways. + */ + for (revert_agno = 0; revert_agno <= agno; revert_agno++) { + if (!get_sb(revert_agno, &tsb)) + continue; + + tsb.sb_features_compat = old.compat; + tsb.sb_features_ro_compat = old.ro_compat; + tsb.sb_features_incompat = old.incompat; + tsb.sb_features_log_incompat = old.log_incompat; + libxfs_sb_to_disk(iocur_top->data, &tsb); + write_cur(); + } +fail: + dbprintf( +_("Failed to upgrade V5 filesystem at AG %d, please run xfs_repair.\n"), agno); + return false; +} + static char * version_string( xfs_sb_t *sbp) @@ -691,15 +816,12 @@ version_string( strcat(s, ",INOBTCNT"); if (xfs_sb_version_hasbigtime(sbp)) strcat(s, ",BIGTIME"); + if (xfs_sb_version_needsrepair(sbp)) + strcat(s, ",NEEDSREPAIR"); return s; } -/* - * XXX: this only supports reading and writing to version 4 superblock fields. - * V5 superblocks always define certain V4 feature bits - they are blocked from - * being changed if a V5 sb is detected, but otherwise v5 superblock features - * are not handled here. - */ +/* Upgrade a superblock to support a feature. */ static int version_f( int argc, @@ -710,6 +832,9 @@ version_f( xfs_agnumber_t ag; if (argc == 2) { /* WRITE VERSION */ + struct v5feat v5features; + + get_v5_features(mp, &v5features); if ((x.isreadonly & LIBXFS_ISREADONLY) || !expert_mode) { dbprintf(_("%s: not in expert mode, writing disabled\n"), @@ -717,8 +842,23 @@ version_f( return 0; } + if (xfs_sb_version_needsrepair(&mp->m_sb)) { + dbprintf(_("%s: filesystem needs xfs_repair\n"), + progname); + return 0; + } + /* Logic here derived from the IRIX xfs_chver(1M) script. */ - if (!strcasecmp(argv[1], "extflg")) { + if (!strcasecmp(argv[1], "needsrepair")) { + if (!xfs_sb_version_hascrc(&mp->m_sb)) { + dbprintf( + _("needsrepair flag cannot be enabled on pre-V5 filesystems\n")); + exitcode = 1; + return 1; + } + + v5features.incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; + } else if (!strcasecmp(argv[1], "extflg")) { switch (XFS_SB_VERSION_NUM(&mp->m_sb)) { case XFS_SB_VERSION_1: version = 0x0004 | XFS_SB_VERSION_EXTFLGBIT; @@ -809,6 +949,11 @@ version_f( mp->m_sb.sb_versionnum = version; mp->m_sb.sb_features2 = features; } + + if (!set_v5_features(mp, &v5features)) { + exitcode = 1; + return 1; + } } if (argc == 3) { /* VERSIONNUM + FEATURES2 */ diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh index bd325da2f776..41a14d4521ba 100755 --- a/db/xfs_admin.sh +++ b/db/xfs_admin.sh @@ -9,7 +9,7 @@ DB_OPTS="" REPAIR_OPTS="" USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-U uuid] device [logdev]" -while getopts "efjlpuc:L:U:V" c +while getopts "efjlpuc:L:O:U:V" c do case $c in c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;; @@ -19,6 +19,9 @@ do l) DB_OPTS=$DB_OPTS" -r -c label";; L) DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";; p) DB_OPTS=$DB_OPTS" -c 'version projid32bit'";; + O) DB_OPTS=$DB_OPTS" -c 'version "$OPTARG"'"; + # Force repair to run by adding a single space to REPAIR_OPTS + REPAIR_OPTS="$REPAIR_OPTS ";; u) DB_OPTS=$DB_OPTS" -r -c uuid";; U) DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";; V) xfs_db -p xfs_admin -V @@ -48,6 +51,7 @@ case $# in fi if [ -n "$REPAIR_OPTS" ] then + echo "Running xfs_repair to ensure filesystem consistency." # Hide normal repair output which is sent to stderr # assuming the filesystem is fine when a user is # running xfs_admin. diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8 index 8afc873fb50a..b423981d8049 100644 --- a/man/man8/xfs_admin.8 +++ b/man/man8/xfs_admin.8 @@ -6,6 +6,8 @@ xfs_admin \- change parameters of an XFS filesystem [ .B \-eflpu ] [ +.BI \-O " feature" +] [ .BR "\-c 0" | 1 ] [ .B \-L @@ -103,6 +105,19 @@ The filesystem label can be cleared using the special "\c " value for .IR label . .TP +.BI \-O " feature" +Add a new feature to the filesystem. +Only one feature can be specified at a time. +Features are as follows: +.RS 0.7i +.TP +.B needsrepair +If this is a V5 filesystem, flag the filesystem as needing repairs. +Until +.BR xfs_repair (8) +is run, the filesystem will not be mountable. +.RE +.TP .BI \-U " uuid" Set the UUID of the filesystem to .IR uuid . diff --git a/man/man8/xfs_db.8 b/man/man8/xfs_db.8 index 587274957de3..7331cf196bb0 100644 --- a/man/man8/xfs_db.8 +++ b/man/man8/xfs_db.8 @@ -971,6 +971,11 @@ may toggle between and .B attr2 at will (older kernels may not support the newer version). +The filesystem can be flagged as requiring a run through +.BR xfs_repair (8) +if the +.B needsrepair +option is specified and the filesystem is formatted with the V5 format. .IP If no argument is given, the current version and feature bits are printed. With one argument, this command will write the updated version number From patchwork Fri Dec 4 01:13:53 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: 11950309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0195EC433FE for ; Fri, 4 Dec 2020 01:14:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE6B5224B8 for ; Fri, 4 Dec 2020 01:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727852AbgLDBOh (ORCPT ); Thu, 3 Dec 2020 20:14:37 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:59028 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgLDBOh (ORCPT ); Thu, 3 Dec 2020 20:14:37 -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 0B419me6187996; Fri, 4 Dec 2020 01:13:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=ulWXev5TBEd1S3H5yWykDQzR/xZAKtBBuPazZ74mL0k=; b=AD1mtLfblLbJQv1DuQ/Sz1pw+WZeSKyH6J+OBr0gE2ucEk4Gn7gDRFRp8YOVbakw2Oyt X/Q+Ohcl7lIP2TSNGh8jV1jKX8bTmhZ6JY3kiBKjHpecyAAQt8YWDvXZt39/IFwqZKIj udZqFBw/Cu4Z2bEykEqXLl9Kbu1h/SP4LAQqmWxJySMo232nWlDO71GgLN34gsl12mnT wfdHjCdXlP6hDKUpOQ1RV1pNrkRbLuL3q2gU9Bt8mUyZYboQPED0rdGw6k3QoPuucIte SbU3ey1aNrvmfm5rSIb2C3m3AtEYsn9aGgzQqcrj6fChjU4sfnVSctMQPayQwO6rD9p6 Mw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 353c2b939h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 04 Dec 2020 01:13:55 +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 0B41AXP0093339; Fri, 4 Dec 2020 01:13:54 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 35404rn887-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Dec 2020 01:13:54 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0B41DrRG016996; Fri, 4 Dec 2020 01:13:53 GMT Received: from localhost (/10.159.242.140) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 03 Dec 2020 17:13:53 -0800 Date: Thu, 3 Dec 2020 17:13:53 -0800 From: "Darrick J. Wong" To: sandeen@sandeen.net Cc: linux-xfs@vger.kernel.org Subject: [PATCH 5/3] xfs_repair: clear the needsrepair flag Message-ID: <20201204011353.GD629293@magnolia> References: <160679383892.447856.12907477074923729733.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <160679383892.447856.12907477074923729733.stgit@magnolia> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9824 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012040003 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9824 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 lowpriorityscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012040003 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Clear the needsrepair flag, since it's used to prevent mounting of an inconsistent filesystem. Signed-off-by: Darrick J. Wong --- repair/agheader.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/repair/agheader.c b/repair/agheader.c index f28d8a7bb0de..53f541d4a53a 100644 --- a/repair/agheader.c +++ b/repair/agheader.c @@ -452,6 +452,17 @@ secondary_sb_whack( rval |= XR_AG_SB_SEC; } + if (xfs_sb_version_needsrepair(sb)) { + if (!no_modify) + sb->sb_features_incompat &= + ~XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; + if (!do_bzero) { + rval |= XR_AG_SB; + do_warn(_("needsrepair flag set in sb %d\n"), i); + } else + rval |= XR_AG_SB_SEC; + } + return(rval); }