From patchwork Tue Feb 9 04:10:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077153 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 4457EC433DB for ; Tue, 9 Feb 2021 04:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 065EE64EB9 for ; Tue, 9 Feb 2021 04:19:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229866AbhBIESv (ORCPT ); Mon, 8 Feb 2021 23:18:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:48558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbhBIEPq (ORCPT ); Mon, 8 Feb 2021 23:15:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3DA5964EBD; Tue, 9 Feb 2021 04:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843810; bh=8afJyPp9xTxAEmiZ0k/3umEdYcDe0sowGQQ76U+dY4Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=kcu3uJJtIkqoKk80DRQPRfKfdOEcbjVVvgP+zQnCgeA5dg5Hb8z0lkltJJqedC+83 7XfAf5L6ZdaawdZz7+mAK8LyLH1a5K/Ts7jS33J7hn/Nq1UF2wYlh1ChI9iXHO5qK+ QxC9Yp1mNLqA6JSk9UAXMF/9xZgy+9qn6x22IYFTCmXfKZDCMdLIbgzIXSaaBWmpfO +DgMuCVocmN6pMpwdN2tsySwXIiFO7cE+6eTpvVVkaKVyKP9zMPQFZbjgeQfcyv/L3 xbMWDWMnXLNB/2QJfp3Nlj7B8MKdLSnn6ddktJDd93ZEmVExQMH7V0CKTErcWDFBu6 Ii7ecsoELT9JQ== Subject: [PATCH 01/10] xfs_admin: clean up string quoting From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Brian Foster , linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:09 -0800 Message-ID: <161284380981.3057868.13051897080577307586.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Clean up the string quoting in this script so that we don't trip over users feeding us arguments like "/dev/sd ha ha ha lol". Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig --- db/xfs_admin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh index bd325da2..71a9aa98 100755 --- a/db/xfs_admin.sh +++ b/db/xfs_admin.sh @@ -43,7 +43,7 @@ case $# in if [ -n "$DB_OPTS" ] then - eval xfs_db -x -p xfs_admin $DB_OPTS $1 + eval xfs_db -x -p xfs_admin $DB_OPTS "$1" status=$? fi if [ -n "$REPAIR_OPTS" ] @@ -53,7 +53,7 @@ case $# in # running xfs_admin. # Ideally, we need to improve the output behaviour # of repair for this purpose (say a "quiet" mode). - eval xfs_repair $REPAIR_OPTS $1 2> /dev/null + eval xfs_repair $REPAIR_OPTS "$1" 2> /dev/null status=`expr $? + $status` if [ $status -ne 0 ] then From patchwork Tue Feb 9 04:10:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077117 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 9577FC433E0 for ; Tue, 9 Feb 2021 04:14:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4644564EB8 for ; Tue, 9 Feb 2021 04:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbhBIEOM (ORCPT ); Mon, 8 Feb 2021 23:14:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:48452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbhBIENF (ORCPT ); Mon, 8 Feb 2021 23:13:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DFD2064EBC; Tue, 9 Feb 2021 04:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843816; bh=yQTbNdRFGWEXudNzBgFNRDCB1wpwNeJZIvGXZ/tCFvA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ckIRpLxPLtze3ho/pC5YVhM0weroqPMAmlmVcPjlbQFS9vmsogrjut7mFK9mYvWlu esk5wg87RDsOluwH8+gTJe56d3yFPTIvnmPiIPRWtBWHo/G/Broma/QjXur5ixhlIU 3jBcxgInjhiq81CyXb3DCMbx1fu+FbBNC9+0B8EzzdbKOXOfSQtVY+5qLK9fdqyBDh nTBxVfKPAtkcFE6whLFpNHrjnh4mUzFPBe+jBfL7Nlr+yBPgisG5z+MctA7StyN0H3 khqH1a3d/x6XQw6WELDwVvoFy8bvL9MIHsPk4Pot9+8oBoZif9BSx8Y0GN4uJW0f7k n7T/onFqg0AJg== Subject: [PATCH 02/10] xfs_admin: support filesystems with realtime devices From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:15 -0800 Message-ID: <161284381548.3057868.17951198536217853244.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Add a -r option to xfs_admin so that we can pass the name of the realtime device to xfs_repair. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- db/xfs_admin.sh | 11 ++++++----- man/man8/xfs_admin.8 | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh index 71a9aa98..430872ef 100755 --- a/db/xfs_admin.sh +++ b/db/xfs_admin.sh @@ -7,9 +7,10 @@ status=0 DB_OPTS="" REPAIR_OPTS="" -USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-U uuid] device [logdev]" +REPAIR_DEV_OPTS="" +USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-r rtdev] [-U uuid] device [logdev]" -while getopts "efjlpuc:L:U:V" c +while getopts "c:efjlL:pr:uU:V" c do case $c in c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;; @@ -19,6 +20,7 @@ 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'";; + r) REPAIR_DEV_OPTS=" -r '$OPTARG'";; u) DB_OPTS=$DB_OPTS" -r -c uuid";; U) DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";; V) xfs_db -p xfs_admin -V @@ -37,8 +39,7 @@ case $# in # Pick up the log device, if present if [ -n "$2" ]; then DB_OPTS=$DB_OPTS" -l '$2'" - test -n "$REPAIR_OPTS" && \ - REPAIR_OPTS=$REPAIR_OPTS" -l '$2'" + REPAIR_DEV_OPTS=$REPAIR_DEV_OPTS" -l '$2'" fi if [ -n "$DB_OPTS" ] @@ -53,7 +54,7 @@ case $# in # running xfs_admin. # Ideally, we need to improve the output behaviour # of repair for this purpose (say a "quiet" mode). - eval xfs_repair $REPAIR_OPTS "$1" 2> /dev/null + eval xfs_repair $REPAIR_DEV_OPTS $REPAIR_OPTS "$1" 2> /dev/null status=`expr $? + $status` if [ $status -ne 0 ] then diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8 index 8afc873f..cccbb224 100644 --- a/man/man8/xfs_admin.8 +++ b/man/man8/xfs_admin.8 @@ -13,6 +13,9 @@ xfs_admin \- change parameters of an XFS filesystem ] [ .B \-U .I uuid +] [ +.B \-r +.I rtdev ] .I device [ @@ -123,6 +126,11 @@ not be able to mount the filesystem. To remove this incompatible flag, use which will restore the original UUID and remove the incompatible feature flag as needed. .TP +.BI \-r " rtdev" +Specifies the device special file where the filesystem's realtime section +resides. +Only for those filesystems which use a realtime section. +.TP .B \-V Prints the version number and exits. .PP From patchwork Tue Feb 9 04:10:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077123 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 5D6B5C433DB for ; Tue, 9 Feb 2021 04:15:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C85864EB8 for ; Tue, 9 Feb 2021 04:15:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbhBIEPa (ORCPT ); Mon, 8 Feb 2021 23:15:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:48454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230209AbhBIEN0 (ORCPT ); Mon, 8 Feb 2021 23:13:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A1A4464EBE; Tue, 9 Feb 2021 04:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843821; bh=HxErr6O2CBXeEaKjbw8yiGnWJn+VmI0G+Hu9dn9eriQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Tu7HNwXENF4EU0zN++dUSfoYQ3z5V4d8LTV/mK8hT4cJJuX6vpVZXts28nVWyeh1B WkTjeTXn89iCjF7kUGB0tqLUsk2XmU5RQOC38Tdu5u6kYAmQRXNhT2TeO8V6jZBwQ3 8OPpiDcVTDLLq6eeW7G0YhXLGV6TlbhgQtPyYiJQNxM06M9a2iCSiAeTlE7JdaLje4 FMKrHw8Ho9HyVnPxCRAqWYeHcDWT4Fn3xs0VBD9tuxf+PWFnhmsSomW9mMkMYhUN6a 9LfSd/pREp0rt6e1rRu1tF0G/TNuVXzyg/5CRT2ly3ZMEisEf3xzXSgay3cIFoFMvk 0Oo5GX/zylZ7Q== Subject: [PATCH 03/10] xfs_db: support the needsrepair feature flag in the version command From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:21 -0800 Message-ID: <161284382116.3057868.4021834592988203500.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 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 Reviewed-by: Brian Foster --- db/check.c | 5 +++++ db/sb.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/db/check.c b/db/check.c index 33736e33..485e855e 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 d09f653d..cec7dce9 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); @@ -543,6 +548,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) { @@ -691,6 +702,8 @@ 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; } From patchwork Tue Feb 9 04:10:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077121 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 13886C433E6 for ; Tue, 9 Feb 2021 04:15:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C42FB64EBC for ; Tue, 9 Feb 2021 04:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbhBIEOy (ORCPT ); Mon, 8 Feb 2021 23:14:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:48464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbhBIEN0 (ORCPT ); Mon, 8 Feb 2021 23:13:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D5B364EBF; Tue, 9 Feb 2021 04:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843827; bh=wth1mPw6zDUfJmHmaklJbpm4fEomTnWcWyStpH68IP8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=aDwxM1+BuAFRUPPZ8UongACsk91z2dl2ibF8xWk4/XjdEVyRMy+Gw4L+IwWnebpwN Ce8L9EqRaX1Z/+WhTIjCXQMM3g9YJYrcYFNrvUu/vAAKC6eESiWWPxq8rE9M+rYDPD 5g9CEIT3zAlmdiZ+zOqLUGwmpEsC19fjukzkFESQMKs+IclFz/8bm7N8ulD1tE4aez yY/ztLeHsO0ug5KsDQP0Sv47cpk39vLu3Mv0evufhG7hdDfPU5GGL3xFR2zn0ARJcb 3Cycp63ivddGeZAhfSE0FT846Zmr8QdMM0J32olJZhiYRg9YzM5F1Z1mnyVUmNxtm/ vW7fpZEbFOyyQ== Subject: [PATCH 04/10] xfs_repair: fix unmount error message to have a newline From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Brian Foster , linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:26 -0800 Message-ID: <161284382691.3057868.2014492091458444565.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Add a newline so that this is consistent with the other error messages. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig --- repair/xfs_repair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 724661d8..9409f0d8 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -1136,7 +1136,7 @@ _("Note - stripe unit (%d) and width (%d) were copied from a backup superblock.\ error = -libxfs_umount(mp); if (error) do_error( - _("File system metadata writeout failed, err=%d. Re-run xfs_repair."), + _("File system metadata writeout failed, err=%d. Re-run xfs_repair.\n"), error); libxfs_destroy(&x); From patchwork Tue Feb 9 04:10:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077125 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 DA1D5C433DB for ; Tue, 9 Feb 2021 04:16:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95D0D64EB8 for ; Tue, 9 Feb 2021 04:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230171AbhBIEPf (ORCPT ); Mon, 8 Feb 2021 23:15:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:48466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbhBIEN1 (ORCPT ); Mon, 8 Feb 2021 23:13:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 096E664EC2; Tue, 9 Feb 2021 04:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843833; bh=aAmzJf18ktp3SedQLpPnsnauEZAbPBZYRg1zo7DJOBg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AxDtHxycYitSEcimM2gqRWnJJjwMcpQl2Jyg4LHspVJ2mLnTRZu2f+H84P9puh37l hKsOGlPMiVvOl++68G/CRiSfsziUeBxsS4QApBgQORxEMEWKyx33M/OjrpB1Rm+b0f DQXiUJVpMl8TqZ93VH5IL/9vPzDe4F/8BL86iBdpdtuR4c9AaaWmVD+1BQ0wvyx0V/ KikshYDXcbxSPk9KyDQ8OGIJiecTaJidNh8G1Z3z49D2myehROIhg8QogbELFxPgLP 9IlX3Xgl+SCV1jAFGr7eTdGV5ChA/LHe2urP9RLCm8VIxfKMwa4G8H6cf7etBdxxb6 3JrTArNfBvNMQ== Subject: [PATCH 05/10] xfs_repair: clear quota CHKD flags on the incore superblock too From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:32 -0800 Message-ID: <161284383258.3057868.6167060787728229726.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong At the end of a repair run, xfs_repair clears the superblock's quota checked flags if it found mistakes in the quota accounting to force a quotacheck at the next mount. This is currently the last time repair modifies the primary superblock, so it is sufficient to update the ondisk buffer and not the incore mount structure. However, we're about to introduce code to clear the needsrepair feature at the very end of repair, after all metadata blocks have been written to disk and all disk caches flush. Since the convention everywhere else in xfs is to update the incore superblock, call libxfs_sb_to_disk to translate that into the ondisk buffer, and then write the buffer to disk, switch the quota CHKD code to use this mechanism too. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- repair/xfs_repair.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 9409f0d8..32755821 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -1108,10 +1108,9 @@ _("Warning: project quota information would be cleared.\n" if ((mp->m_sb.sb_qflags & XFS_ALL_QUOTA_CHKD) != quotacheck_results()) { do_warn(_("Note - quota info will be regenerated on next " "quota mount.\n")); - dsb->sb_qflags &= cpu_to_be16(~(XFS_UQUOTA_CHKD | - XFS_GQUOTA_CHKD | - XFS_PQUOTA_CHKD | - XFS_OQUOTA_CHKD)); + mp->m_sb.sb_qflags &= ~(XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | + XFS_PQUOTA_CHKD | XFS_OQUOTA_CHKD); + libxfs_sb_to_disk(sbp->b_addr, &mp->m_sb); } if (copied_sunit) { From patchwork Tue Feb 9 04:10:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077139 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 2550DC43381 for ; Tue, 9 Feb 2021 04:17:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E631764EC8 for ; Tue, 9 Feb 2021 04:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbhBIERZ (ORCPT ); Mon, 8 Feb 2021 23:17:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:48550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbhBIENr (ORCPT ); Mon, 8 Feb 2021 23:13:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C1DA964EC3; Tue, 9 Feb 2021 04:10:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843838; bh=AwAzJCERb3Y7dbFUNVbtIH+XXe+qJ2iDTTeFTrB7g5E=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=nWjdgJ9x8kwX/p51De4DThOec6SBcSQLrwDVuIv767cNqt49b5DUUS2BIXxen+pv2 pf95VpJRxb9DafY76Yk2GT+gLx7tlzWJ6MNfFFjV6hzwB77kGJAJETlD7EC3i0HK+b pXH6O2NuGDcjNgBJxpKdoKPWMLpQcYYBBS+CMFHYTM8e7Onz1gN3Qj0LyxW2iixaOM GO5mBa9IA9VPco2lveqJw7+WaHdo2Mkp9BHWmx0vxmtg8k8H1k9mIXzZakfErt5l1N HgXbHxCf0DONXDkIMMLaxyy25Xc3DjeBDSCn83k6XY7ocZn4jAxX0WmM4+p8Mp52HV 23GMFXgLYFPjA== Subject: [PATCH 06/10] xfs_repair: clear the needsrepair flag From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:38 -0800 Message-ID: <161284383828.3057868.1762356472271947821.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 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. We only do this if we make it to the end of repair with a non-zero error code, and all the rebuilt indices and corrected metadata are persisted correctly. Note that we cannot combine clearing needsrepair with clearing the quota checked flags because we need to clear the quota flags even if reformatting the log fails, whereas we can't clear needsrepair if the log reformat fails. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- include/xfs_mount.h | 1 + libxfs/init.c | 25 +++++++++++++------------ repair/agheader.c | 21 +++++++++++++++++++++ repair/xfs_repair.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 12 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 36594643..75230ca5 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -181,6 +181,7 @@ xfs_perag_resv( extern xfs_mount_t *libxfs_mount (xfs_mount_t *, xfs_sb_t *, dev_t, dev_t, dev_t, int); +int libxfs_flush_mount(struct xfs_mount *mp); int libxfs_umount(struct xfs_mount *mp); extern void libxfs_rtmount_destroy (xfs_mount_t *); diff --git a/libxfs/init.c b/libxfs/init.c index 9fe13b8d..98057b78 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -867,25 +867,17 @@ _("%s: Flushing the %s failed, err=%d!\n"), } /* - * Flush all dirty buffers to stable storage and report on writes that didn't - * make it to stable storage. + * Persist all disk write caches and report on writes that didn't make it to + * stable storage. Callers should flush (or purge) the libxfs buffer caches + * before calling this function. */ -static int +int libxfs_flush_mount( struct xfs_mount *mp) { int error = 0; int err2; - /* - * Purge the buffer cache to write all dirty buffers to disk and free - * all incore buffers. Buffers that fail write verification will cause - * the CORRUPT_WRITE flag to be set in the buftarg. Buffers that - * cannot be written will cause the LOST_WRITE flag to be set in the - * buftarg. - */ - libxfs_bcache_purge(); - /* Flush all kernel and disk write caches, and report failures. */ if (mp->m_ddev_targp) { err2 = libxfs_flush_buftarg(mp->m_ddev_targp, _("data device")); @@ -923,6 +915,15 @@ libxfs_umount( libxfs_rtmount_destroy(mp); + /* + * Purge the buffer cache to write all dirty buffers to disk and free + * all incore buffers. Buffers that fail write verification will cause + * the CORRUPT_WRITE flag to be set in the buftarg. Buffers that + * cannot be written will cause the LOST_WRITE flag to be set in the + * buftarg. Once that's done, instruct the disks to persist their + * write caches. + */ + libxfs_bcache_purge(); error = libxfs_flush_mount(mp); for (agno = 0; agno < mp->m_maxagi; agno++) { diff --git a/repair/agheader.c b/repair/agheader.c index 8bb99489..2af24106 100644 --- a/repair/agheader.c +++ b/repair/agheader.c @@ -452,6 +452,27 @@ secondary_sb_whack( rval |= XR_AG_SB_SEC; } + if (xfs_sb_version_needsrepair(sb)) { + if (i == 0) { + if (!no_modify) + do_warn( + _("clearing needsrepair flag and regenerating metadata\n")); + else + do_warn( + _("would clear needsrepair flag and regenerate metadata\n")); + } else { + /* + * Quietly clear needsrepair on the secondary supers as + * part of ensuring them. If needsrepair is set on the + * primary, it will be cleared at the end of repair + * once we've flushed all other dirty blocks to disk. + */ + sb->sb_features_incompat &= + ~XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; + rval |= XR_AG_SB_SEC; + } + } + return(rval); } diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 32755821..f607afcb 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -712,6 +712,48 @@ check_fs_vs_host_sectsize( } } +/* Clear needsrepair after a successful repair run. */ +void +clear_needsrepair( + struct xfs_mount *mp) +{ + struct xfs_buf *bp; + int error; + + /* + * If we're going to clear NEEDSREPAIR, we need to make absolutely sure + * that everything is ok with the ondisk filesystem. At this point + * we've flushed the filesystem metadata out of the buffer cache and + * possibly rewrote the log, but we haven't forced the disks to persist + * the writes to stable storage. Do that now, and if anything goes + * wrong, leave NEEDSREPAIR in place. Don't purge the buffer cache + * here since we're not done yet. + */ + libxfs_bcache_flush(); + error = -libxfs_flush_mount(mp); + if (error) { + do_warn( + _("Cannot clear needsrepair due to flush failure, err=%d.\n"), + error); + return; + } + + /* Clear needsrepair from the superblock. */ + bp = libxfs_getsb(mp); + if (!bp || bp->b_error) { + do_warn( + _("Cannot clear needsrepair from primary super, err=%d.\n"), + bp ? bp->b_error : ENOMEM); + } else { + mp->m_sb.sb_features_incompat &= + ~XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; + libxfs_sb_to_disk(bp->b_addr, &mp->m_sb); + libxfs_buf_mark_dirty(bp); + } + if (bp) + libxfs_buf_relse(bp); +} + int main(int argc, char **argv) { @@ -1131,6 +1173,9 @@ _("Note - stripe unit (%d) and width (%d) were copied from a backup superblock.\ libxfs_bcache_flush(); format_log_max_lsn(mp); + if (xfs_sb_version_needsrepair(&mp->m_sb)) + clear_needsrepair(mp); + /* Report failure if anything failed to get written to our fs. */ error = -libxfs_umount(mp); if (error) From patchwork Tue Feb 9 04:10:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077131 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 A6B63C433E0 for ; Tue, 9 Feb 2021 04:17:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59D4E64E4F for ; Tue, 9 Feb 2021 04:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230270AbhBIEQf (ORCPT ); Mon, 8 Feb 2021 23:16:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:48552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbhBIENq (ORCPT ); Mon, 8 Feb 2021 23:13:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 59E5964EC4; Tue, 9 Feb 2021 04:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843844; bh=BobK22ALq2mAE0XGYr7SJs943WVxlEAnJyutLwMQaak=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=aobLEQPD1rFwj4Av2puHoWsX4Huxp6JClcnOD3Xkqq65lDJ4uhqOJUohbANLqEQZN 8qBxMRY5AdaistlVDekitj8d765pX39Z3fgNcjqGE8gjAuFWchWcm4nsUk73qYNRHX OSWTkQLSSGBU+p9HUURsReTUjsKtsRyUhf0ZjUNoFMyWXQ1xyz0btbNlb+i56HTURF gabGMtr+p4lyUFtrGUmrBd/AQ3humWfnWzyZnXEv9ensQUEPIM7CY05UVYgcGr783Q 0O8segsilybxNl/CGXut/Re4Y4nR78gqlq6aWvncA8BDIxx+QS/0c2JvhtLscKEf5K byZIGrkuVRfyw== Subject: [PATCH 07/10] xfs_repair: set NEEDSREPAIR when we deliberately corrupt directories From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:44 -0800 Message-ID: <161284384405.3057868.8114203697655713495.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong There are a few places in xfs_repair's directory checking code where we deliberately corrupt a directory entry as a sentinel to trigger a correction in later repair phase. In the mean time, the filesystem is inconsistent, so set the needsrepair flag to force a re-run of repair if the system goes down. Signed-off-by: Darrick J. Wong --- repair/agheader.h | 2 ++ repair/dir2.c | 3 +++ repair/phase6.c | 7 +++++++ repair/xfs_repair.c | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/repair/agheader.h b/repair/agheader.h index a63827c8..fa6fe596 100644 --- a/repair/agheader.h +++ b/repair/agheader.h @@ -82,3 +82,5 @@ typedef struct fs_geo_list { #define XR_AG_AGF 0x2 #define XR_AG_AGI 0x4 #define XR_AG_SB_SEC 0x8 + +void force_needsrepair(struct xfs_mount *mp); diff --git a/repair/dir2.c b/repair/dir2.c index eabdb4f2..922b8a3e 100644 --- a/repair/dir2.c +++ b/repair/dir2.c @@ -15,6 +15,7 @@ #include "da_util.h" #include "prefetch.h" #include "progress.h" +#include "agheader.h" /* * Known bad inode list. These are seen when the leaf and node @@ -774,6 +775,7 @@ _("entry at block %u offset %" PRIdPTR " in directory inode %" PRIu64 do_warn( _("\tclearing inode number in entry at offset %" PRIdPTR "...\n"), (intptr_t)ptr - (intptr_t)d); + force_needsrepair(mp); dep->name[0] = '/'; *dirty = 1; } else { @@ -914,6 +916,7 @@ _("entry \"%*.*s\" in directory inode %" PRIu64 " points to self: "), */ if (junkit) { if (!no_modify) { + force_needsrepair(mp); dep->name[0] = '/'; *dirty = 1; do_warn(_("clearing entry\n")); diff --git a/repair/phase6.c b/repair/phase6.c index 14464bef..5ecbe9b2 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -1649,6 +1649,7 @@ longform_dir2_entry_check_data( if (entry_junked( _("entry \"%s\" in directory inode %" PRIu64 " points to non-existent inode %" PRIu64 ""), fname, ip->i_ino, inum)) { + force_needsrepair(mp); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1666,6 +1667,7 @@ longform_dir2_entry_check_data( if (entry_junked( _("entry \"%s\" in directory inode %" PRIu64 " points to free inode %" PRIu64), fname, ip->i_ino, inum)) { + force_needsrepair(mp); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1684,6 +1686,7 @@ longform_dir2_entry_check_data( if (entry_junked( _("%s (ino %" PRIu64 ") in root (%" PRIu64 ") is not a directory"), ORPHANAGE, inum, ip->i_ino)) { + force_needsrepair(mp); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1706,6 +1709,7 @@ longform_dir2_entry_check_data( if (entry_junked( _("entry \"%s\" (ino %" PRIu64 ") in dir %" PRIu64 " is a duplicate name"), fname, inum, ip->i_ino)) { + force_needsrepair(mp); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1737,6 +1741,7 @@ longform_dir2_entry_check_data( if (entry_junked( _("entry \"%s\" (ino %" PRIu64 ") in dir %" PRIu64 " is not in the the first block"), fname, inum, ip->i_ino)) { + force_needsrepair(mp); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1764,6 +1769,7 @@ longform_dir2_entry_check_data( if (entry_junked( _("entry \"%s\" in dir %" PRIu64 " is not the first entry"), fname, inum, ip->i_ino)) { + force_needsrepair(mp); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1852,6 +1858,7 @@ _("entry \"%s\" in dir inode %" PRIu64 " inconsistent with .. value (%" PRIu64 " orphanage_ino = 0; nbad++; if (!no_modify) { + force_needsrepair(mp); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); if (verbose) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index f607afcb..9dc73854 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -754,6 +754,43 @@ clear_needsrepair( libxfs_buf_relse(bp); } +/* + * Mark the filesystem as needing repair. This should only be called by code + * that deliberately sets invalid sentinel values in the on-disk metadata to + * trigger a later reconstruction, and only after we've settled the primary + * super contents (i.e. after phase 1). + */ +void +force_needsrepair( + struct xfs_mount *mp) +{ + struct xfs_buf *bp; + int error; + + if (!xfs_sb_version_hascrc(&mp->m_sb) || + xfs_sb_version_needsrepair(&mp->m_sb)) + return; + + bp = libxfs_getsb(mp); + if (!bp || bp->b_error) { + do_log( + _("couldn't get superblock to set needsrepair, err=%d\n"), + bp ? bp->b_error : ENOMEM); + return; + } else { + mp->m_sb.sb_features_incompat |= + XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; + libxfs_sb_to_disk(bp->b_addr, &mp->m_sb); + + /* Force the primary super to disk immediately. */ + error = -libxfs_bwrite(bp); + if (error) + do_log(_("couldn't force needsrepair, err=%d\n"), error); + } + if (bp) + libxfs_buf_relse(bp); +} + int main(int argc, char **argv) { From patchwork Tue Feb 9 04:10:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077129 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 589BEC433E0 for ; Tue, 9 Feb 2021 04:16:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1880464EB4 for ; Tue, 9 Feb 2021 04:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbhBIEQC (ORCPT ); Mon, 8 Feb 2021 23:16:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:48554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbhBIENr (ORCPT ); Mon, 8 Feb 2021 23:13:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E494E64EC5; Tue, 9 Feb 2021 04:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843850; bh=p3U1n34LGkCg7mepWUQRZ+MZXo7Vw+SF37k0522MAso=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AoVSAjCsRPg5U8eINz4LUuyrtqBkXnlccj8UHJvzO63vK9Ppexesc7Z1G1WaQ6PJe tmdGiTpPqjZh2mTnACek9CrXbxc9/CMe2ZEyUbyllX5Ko9l/o7nZhNKCJanOCFWv1f 4rzGlcoo/Ydyr8PrlSNyNmdkcqnfD8wSoahNzYJ1GifuUnrTR4l4OmAA/B8FSMwKZF 39Ou0MXAHt5oWrAnywDGU6IZLbVN2PPrmzE5eYrCLlLDLDz/vFc2sY/kQt3KMUjbN+ trbR3RD24mILJ1Dm6+pfHv1CxVGf0+12U44kUFFanHV42tX/X9lxfDwUpVNgQTrhhD paKPBwkO3rtIQ== Subject: [PATCH 08/10] xfs_repair: allow setting the needsrepair flag From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:49 -0800 Message-ID: <161284384955.3057868.8076509276356847362.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Quietly set up the ability to tell xfs_repair to set NEEDSREPAIR at program start and (presumably) clear it by the end of the run. This code isn't terribly useful to users; it's mainly here so that fstests can exercise the functionality. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- repair/globals.c | 2 ++ repair/globals.h | 2 ++ repair/phase1.c | 23 +++++++++++++++++++++++ repair/xfs_repair.c | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/repair/globals.c b/repair/globals.c index 110d98b6..699a96ee 100644 --- a/repair/globals.c +++ b/repair/globals.c @@ -49,6 +49,8 @@ int rt_spec; /* Realtime dev specified as option */ int convert_lazy_count; /* Convert lazy-count mode on/off */ int lazy_count; /* What to set if to if converting */ +bool add_needsrepair; /* forcibly set needsrepair while repairing */ + /* misc status variables */ int primary_sb_modified; diff --git a/repair/globals.h b/repair/globals.h index 1d397b35..043b3e8e 100644 --- a/repair/globals.h +++ b/repair/globals.h @@ -90,6 +90,8 @@ extern int rt_spec; /* Realtime dev specified as option */ extern int convert_lazy_count; /* Convert lazy-count mode on/off */ extern int lazy_count; /* What to set if to if converting */ +extern bool add_needsrepair; + /* misc status variables */ extern int primary_sb_modified; diff --git a/repair/phase1.c b/repair/phase1.c index 00b98584..b26d25f8 100644 --- a/repair/phase1.c +++ b/repair/phase1.c @@ -30,6 +30,26 @@ alloc_ag_buf(int size) return(bp); } +static void +set_needsrepair( + struct xfs_sb *sb) +{ + if (!xfs_sb_version_hascrc(sb)) { + printf( + _("needsrepair flag only supported on V5 filesystems.\n")); + exit(0); + } + + if (xfs_sb_version_needsrepair(sb)) { + printf(_("Filesystem already marked as needing repair.\n")); + return; + } + + printf(_("Marking filesystem in need of repair.\n")); + primary_sb_modified = 1; + sb->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; +} + /* * this has got to be big enough to hold 4 sectors */ @@ -126,6 +146,9 @@ _("Cannot disable lazy-counters on V5 fs\n")); } } + if (add_needsrepair) + set_needsrepair(sb); + /* shared_vn should be zero */ if (sb->sb_shared_vn) { do_warn(_("resetting shared_vn to zero\n")); diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 9dc73854..ee377e8a 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -65,11 +65,13 @@ static char *o_opts[] = { */ enum c_opt_nums { CONVERT_LAZY_COUNT = 0, + CONVERT_NEEDSREPAIR, C_MAX_OPTS, }; static char *c_opts[] = { [CONVERT_LAZY_COUNT] = "lazycount", + [CONVERT_NEEDSREPAIR] = "needsrepair", [C_MAX_OPTS] = NULL, }; @@ -302,6 +304,13 @@ process_args(int argc, char **argv) lazy_count = (int)strtol(val, NULL, 0); convert_lazy_count = 1; break; + case CONVERT_NEEDSREPAIR: + if (!val) + do_abort( + _("-c needsrepair requires a parameter\n")); + if (strtol(val, NULL, 0) == 1) + add_needsrepair = true; + break; default: unknown('c', val); break; From patchwork Tue Feb 9 04:10:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077133 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 DEFC8C433E0 for ; Tue, 9 Feb 2021 04:17:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98EFB64E4F for ; Tue, 9 Feb 2021 04:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230253AbhBIEQy (ORCPT ); Mon, 8 Feb 2021 23:16:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:48556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230320AbhBIENr (ORCPT ); Mon, 8 Feb 2021 23:13:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A446064EC6; Tue, 9 Feb 2021 04:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843855; bh=7/HQ9xhCLOMhJSCaFz7ZOmPJ5lxK46e95CihtSZ4pbI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=iBPBHK7B7ih7GguIKB2pK7l4q3cqj3b8kz+GDtLADLzGdRrq6Nva5zgGp2jP/PGRm bXD85E4BQjWFXUXhuVCrcqasFp74CbI22UBbe2uXuSBWROaAtsYUwQWOh8B6y+jWVB ZQ1XOMn46CKDykQEHTHpF0vi8gF+KE89IaSfNKiVNV59sPYAINYBPHsAsg0RNzSR9i J0YAM7HFm64ABFkO3hJhDUedIhq5vUlwBqO6bQvI5bPzyhHisUP1/kcZxWD8Znoh0Y RhxmU948tsXYORjss8xJBpelU9m2erZkH0md3AN3DaaEx/xSYwKt48gzK/3gWbiWdV tkaInvLXyuyEQ== Subject: [PATCH 09/10] xfs_repair: add a testing hook for NEEDSREPAIR From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:10:55 -0800 Message-ID: <161284385516.3057868.355176047687079022.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Simulate a crash when anyone calls force_needsrepair. This is a debug knob so that we can test that the kernel won't mount after setting needsrepair and that a re-run of xfs_repair will clear the flag. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/globals.c | 1 + repair/globals.h | 2 ++ repair/phase1.c | 5 +++++ repair/xfs_repair.c | 7 +++++++ 4 files changed, 15 insertions(+) diff --git a/repair/globals.c b/repair/globals.c index 699a96ee..b0e23864 100644 --- a/repair/globals.c +++ b/repair/globals.c @@ -40,6 +40,7 @@ int dangerously; /* live dangerously ... fix ro mount */ int isa_file; int zap_log; int dumpcore; /* abort, not exit on fatal errs */ +bool abort_after_force_needsrepair; int force_geo; /* can set geo on low confidence info */ int assume_xfs; /* assume we have an xfs fs */ char *log_name; /* Name of log device */ diff --git a/repair/globals.h b/repair/globals.h index 043b3e8e..9fa73b2c 100644 --- a/repair/globals.h +++ b/repair/globals.h @@ -82,6 +82,8 @@ extern int isa_file; extern int zap_log; extern int dumpcore; /* abort, not exit on fatal errs */ extern int force_geo; /* can set geo on low confidence info */ +/* Abort after forcing NEEDSREPAIR to test its functionality */ +extern bool abort_after_force_needsrepair; extern int assume_xfs; /* assume we have an xfs fs */ extern char *log_name; /* Name of log device */ extern int log_spec; /* Log dev specified as option */ diff --git a/repair/phase1.c b/repair/phase1.c index b26d25f8..57f72cd0 100644 --- a/repair/phase1.c +++ b/repair/phase1.c @@ -170,5 +170,10 @@ _("Cannot disable lazy-counters on V5 fs\n")); */ sb_ifree = sb_icount = sb_fdblocks = sb_frextents = 0; + /* Simulate a crash after setting needsrepair. */ + if (primary_sb_modified && add_needsrepair && + abort_after_force_needsrepair) + exit(55); + free(sb); } diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index ee377e8a..ae7106a6 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -44,6 +44,7 @@ enum o_opt_nums { BLOAD_LEAF_SLACK, BLOAD_NODE_SLACK, NOQUOTA, + FORCE_NEEDSREPAIR_ABORT, O_MAX_OPTS, }; @@ -57,6 +58,7 @@ static char *o_opts[] = { [BLOAD_LEAF_SLACK] = "debug_bload_leaf_slack", [BLOAD_NODE_SLACK] = "debug_bload_node_slack", [NOQUOTA] = "noquota", + [FORCE_NEEDSREPAIR_ABORT] = "debug_force_needsrepair_abort", [O_MAX_OPTS] = NULL, }; @@ -282,6 +284,9 @@ process_args(int argc, char **argv) _("-o debug_bload_node_slack requires a parameter\n")); bload_node_slack = (int)strtol(val, NULL, 0); break; + case FORCE_NEEDSREPAIR_ABORT: + abort_after_force_needsrepair = true; + break; case NOQUOTA: quotacheck_skip(); break; @@ -795,6 +800,8 @@ force_needsrepair( error = -libxfs_bwrite(bp); if (error) do_log(_("couldn't force needsrepair, err=%d\n"), error); + if (abort_after_force_needsrepair) + exit(55); } if (bp) libxfs_buf_relse(bp); From patchwork Tue Feb 9 04:11:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12077135 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=-16.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 0D900C433E6 for ; Tue, 9 Feb 2021 04:17:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEC2164EB4 for ; Tue, 9 Feb 2021 04:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbhBIERE (ORCPT ); Mon, 8 Feb 2021 23:17:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:48558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbhBIENr (ORCPT ); Mon, 8 Feb 2021 23:13:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 512FB64EC8; Tue, 9 Feb 2021 04:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612843861; bh=BE0Xuc6MpJBj7P96gIU9iko52AIbq+5qJW2aRKUIXGc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Ic627t3GZcZb5PId+JmWVbMuizXimQb5ATuB5bcMPuhtMh46SGRYwbryqIwEURUUy y33MO/NWz8kFpcoUu1LedHZVT0qt3GvX9BAmVcVSkGhxNIgQ2gxhJ6p/QRqCMhMzY6 pDBhN2tD5IJhuwO6JM28/OtEtNsNPWU5/mjaHW5oKGTRVOLT6VVy9jPcsXLvtKpByn NT68Av5CEIK5znwpxfgQGMNTC3vwlf0qUeifsKSOLJrZZow/ezWuRdToXhZgq1aVNv As0JSCmLhl9uVlWu5VchwG/rQ9CCokWdt7Mqq0c/cTykUIilKmIXzXX133xuYhhZ5n i+B1AYudIRwUQ== Subject: [PATCH 10/10] xfs_admin: support adding features to V5 filesystems From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Mon, 08 Feb 2021 20:11:00 -0800 Message-ID: <161284386088.3057868.16559496991921219277.stgit@magnolia> In-Reply-To: <161284380403.3057868.11153586180065627226.stgit@magnolia> References: <161284380403.3057868.11153586180065627226.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Teach the xfs_admin script how to add features to V5 filesystems. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- db/xfs_admin.sh | 6 ++++-- man/man8/xfs_admin.8 | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh index 430872ef..7a467dbe 100755 --- a/db/xfs_admin.sh +++ b/db/xfs_admin.sh @@ -8,9 +8,10 @@ status=0 DB_OPTS="" REPAIR_OPTS="" REPAIR_DEV_OPTS="" -USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-r rtdev] [-U uuid] device [logdev]" +DB_LOG_OPTS="" +USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]" -while getopts "c:efjlL:pr:uU:V" c +while getopts "c:efjlL:O:pr:uU:V" c do case $c in c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;; @@ -19,6 +20,7 @@ do j) DB_OPTS=$DB_OPTS" -c 'version log2'";; l) DB_OPTS=$DB_OPTS" -r -c label";; L) DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";; + O) REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG=1";; p) DB_OPTS=$DB_OPTS" -c 'version projid32bit'";; r) REPAIR_DEV_OPTS=" -r '$OPTARG'";; u) DB_OPTS=$DB_OPTS" -r -c uuid";; diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8 index cccbb224..3f3aeea8 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 " featurelist" +] [ .BR "\-c 0" | 1 ] [ .B \-L @@ -106,6 +108,26 @@ The filesystem label can be cleared using the special "\c " value for .IR label . .TP +.BI \-O " feature1" = "status" , "feature2" = "status..." +Add or remove features on an existing a V5 filesystem. +The features should be specified as a comma-separated list. +.I status +should be either 0 to disable the feature or 1 to enable the feature. +Note, however, that most features cannot be disabled. +.IP +.B NOTE: +Administrators must ensure the filesystem is clean by running +.B xfs_repair -n +to inspect the filesystem before performing the upgrade. +If corruption is found, recovery procedures (e.g. reformat followed by +restoration from backup; or running +.B xfs_repair +without the +.BR -n ) +must be followed to clean the filesystem. +.IP +There are currently no feature options. +.TP .BI \-U " uuid" Set the UUID of the filesystem to .IR uuid .