linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jeffm@suse.com
To: linux-btrfs@vger.kernel.org
Cc: Jeff Mahoney <jeffm@suse.com>
Subject: [PATCH 2/2] btrfs-progs: check: fixup_extent_flags needs to deal with non-skinny metadata
Date: Tue,  2 Apr 2019 14:09:56 -0400	[thread overview]
Message-ID: <20190402180956.28893-2-jeffm@suse.com> (raw)
In-Reply-To: <20190402180956.28893-1-jeffm@suse.com>

From: Jeff Mahoney <jeffm@suse.com>

When repairing a file system created by a very old kernel, I ran into
issues fixing up the extent flags since fixup_extent_flags assumed
that a METADATA_ITEM would be present if the record was for metadata.

Since METADATA_ITEMs don't exist without skinny metadata, we need to
fall back to EXTENT_ITEMs.  This also falls back to EXTENT_ITEMs even
with skinny metadata enabled as other parts of the tools do.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 check/main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/check/main.c b/check/main.c
index 7547209c..4a27a443 100644
--- a/check/main.c
+++ b/check/main.c
@@ -7540,9 +7540,13 @@ static int fixup_extent_flags(struct btrfs_fs_info *fs_info,
 	struct btrfs_key key;
 	u64 flags;
 	int ret = 0;
+	bool metadata_item = rec->metadata;
 
+	if (!btrfs_fs_incompat(root->fs_info, SKINNY_METADATA))
+		metadata_item = false;
+retry:
 	key.objectid = rec->start;
-	if (rec->metadata) {
+	if (metadata_item) {
 		key.type = BTRFS_METADATA_ITEM_KEY;
 		key.offset = rec->info_level;
 	} else {
@@ -7561,6 +7565,10 @@ static int fixup_extent_flags(struct btrfs_fs_info *fs_info,
 		btrfs_commit_transaction(trans, root);
 		return ret;
 	} else if (ret) {
+		if (key.type == BTRFS_METADATA_ITEM_KEY) {
+			metadata_item = false;
+			goto retry;
+		}
 		fprintf(stderr, "Didn't find extent for %llu\n",
 			(unsigned long long)rec->start);
 		btrfs_release_path(&path);
-- 
2.16.4


  reply	other threads:[~2019-04-02 18:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02 18:09 [PATCH 1/2] btrfs-progs: check: run delayed refs after writing out dirty block groups jeffm
2019-04-02 18:09 ` jeffm [this message]
2019-04-02 19:21   ` [PATCH 2/2] btrfs-progs: check: fixup_extent_flags needs to deal with non-skinny metadata Filipe Manana
2019-04-02 19:19 ` [PATCH 1/2] btrfs-progs: check: run delayed refs after writing out dirty block groups Filipe Manana
2019-04-04  2:38   ` Jeff Mahoney
2019-05-15 14:16     ` David Sterba
2019-05-15 14:45       ` Filipe Manana
2019-05-17 13:12         ` David Sterba
2019-07-24 13:53           ` Jeff Mahoney
2019-07-24 14:17             ` David Sterba

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=20190402180956.28893-2-jeffm@suse.com \
    --to=jeffm@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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).