linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: sandeen@sandeen.net, djwong@kernel.org
Cc: Brian Foster <bfoster@redhat.com>,
	linux-xfs@vger.kernel.org, hch@lst.de, bfoster@redhat.com
Subject: [PATCH 2/5] xfs_repair: allow upgrades to v5 filesystems
Date: Mon, 22 Feb 2021 19:01:36 -0800	[thread overview]
Message-ID: <161404929660.425731.17886982949516193444.stgit@magnolia> (raw)
In-Reply-To: <161404928523.425731.7157248967184496592.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

Add some helper functions so that we can allow users to upgrade V5
filesystems in a sane manner.  This just lands the boilerplate; the
actual feature validation and whatnot will land in the next patches.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
---
 repair/phase2.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)


diff --git a/repair/phase2.c b/repair/phase2.c
index 952ac4a5..f654edcc 100644
--- a/repair/phase2.c
+++ b/repair/phase2.c
@@ -131,6 +131,40 @@ zero_log(
 		libxfs_max_lsn = log->l_last_sync_lsn;
 }
 
+/* Perform the user's requested upgrades on filesystem. */
+static void
+upgrade_filesystem(
+	struct xfs_mount	*mp)
+{
+	struct xfs_buf		*bp;
+	bool			dirty = false;
+	int			error;
+
+        if (no_modify || !dirty)
+                return;
+
+        bp = libxfs_getsb(mp);
+        if (!bp || bp->b_error) {
+                do_error(
+	_("couldn't get superblock for feature upgrade, err=%d\n"),
+                                bp ? bp->b_error : ENOMEM);
+        } else {
+                libxfs_sb_to_disk(bp->b_addr, &mp->m_sb);
+
+                /*
+		 * Write the primary super to disk immediately so that
+		 * needsrepair will be set if repair doesn't complete.
+		 */
+                error = -libxfs_bwrite(bp);
+                if (error)
+                        do_error(
+	_("filesystem feature upgrade failed, err=%d\n"),
+                                        error);
+        }
+        if (bp)
+                libxfs_buf_relse(bp);
+}
+
 /*
  * ok, at this point, the fs is mounted but the root inode may be
  * trashed and the ag headers haven't been checked.  So we have
@@ -235,4 +269,10 @@ phase2(
 				do_warn(_("would correct\n"));
 		}
 	}
+
+	/*
+	 * Upgrade the filesystem now that we've done a preliminary check of
+	 * the superblocks, the AGs, the log, and the metadata inodes.
+	 */
+	upgrade_filesystem(mp);
 }


  parent reply	other threads:[~2021-02-23  3:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23  3:01 [PATCHSET v6.1 0/5] xfs_admin: support upgrading v5 filesystems Darrick J. Wong
2021-02-23  3:01 ` [PATCH 1/5] man: mark all deprecated V4 format options Darrick J. Wong
2021-02-24  0:26   ` Eric Sandeen
2021-02-24  2:07     ` Darrick J. Wong
2021-02-23  3:01 ` Darrick J. Wong [this message]
2021-02-23  3:01 ` [PATCH 3/5] xfs_admin: support adding features to V5 filesystems Darrick J. Wong
2021-02-23  3:01 ` [PATCH 4/5] xfs_repair: enable inobtcount upgrade via repair Darrick J. Wong
2021-02-23  3:01 ` [PATCH 5/5] xfs_repair: enable bigtime " Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2021-02-13  5:47 [PATCHSET v6 0/5] xfs_admin: support upgrading v5 filesystems Darrick J. Wong
2021-02-13  5:47 ` [PATCH 2/5] xfs_repair: allow upgrades to " Darrick J. Wong
2021-02-16 12:18   ` Brian Foster
2021-02-25  7:40   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=161404929660.425731.17886982949516193444.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=bfoster@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).