All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/3] btrfs-progs: check/lowmem: add inode transid detect and repair support
Date: Wed, 26 Aug 2020 08:52:31 +0800	[thread overview]
Message-ID: <20200826005233.90063-2-wqu@suse.com> (raw)
In-Reply-To: <20200826005233.90063-1-wqu@suse.com>

There are quite some reports on kernel rejecting invalid inode
generation, but it turns out to be that, kernel is just rejecting inode
transid. It's a bug in kernel error message.

To solve the problem and make the fs mountable again, add the detect and
repair support for lowmem mode.

The implementation is pretty much the same, just re-use the existing
inode generation detect and repair code.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/mode-lowmem.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 837bacf920ac..2b689b2abf63 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -2554,6 +2554,7 @@ static int repair_inode_gen_lowmem(struct btrfs_root *root,
 	ii = btrfs_item_ptr(path->nodes[0], path->slots[0],
 			    struct btrfs_inode_item);
 	btrfs_set_inode_generation(path->nodes[0], ii, trans->transid);
+	btrfs_set_inode_transid(path->nodes[0], ii, trans->transid);
 	btrfs_mark_buffer_dirty(path->nodes[0]);
 	ret = btrfs_commit_transaction(trans, root);
 	if (ret < 0) {
@@ -2561,7 +2562,7 @@ static int repair_inode_gen_lowmem(struct btrfs_root *root,
 		error("failed to commit transaction: %m");
 		goto error;
 	}
-	printf("resetting inode generation to %llu for ino %llu\n",
+	printf("resetting inode generation/transid to %llu for ino %llu\n",
 		transid, key.objectid);
 	return ret;
 
@@ -2597,6 +2598,7 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
 	u64 extent_end = 0;
 	u64 extent_size = 0;
 	u64 generation;
+	u64 transid;
 	u64 gen_uplimit;
 	unsigned int dir;
 	unsigned int nodatasum;
@@ -2629,6 +2631,7 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
 	dir = imode_to_type(mode) == BTRFS_FT_DIR;
 	nlink = btrfs_inode_nlink(node, ii);
 	generation = btrfs_inode_generation(node, ii);
+	transid = btrfs_inode_transid(node, ii);
 	nodatasum = btrfs_inode_flags(node, ii) & BTRFS_INODE_NODATASUM;
 
 	if (!is_valid_imode(mode)) {
@@ -2648,10 +2651,10 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
 	else
 		gen_uplimit = btrfs_super_generation(super);
 
-	if (generation > gen_uplimit) {
+	if (generation > gen_uplimit || transid > gen_uplimit) {
 		error(
-	"invalid inode generation for ino %llu, have %llu expect [0, %llu)",
-		      inode_id, generation, gen_uplimit);
+"invalid inode generation or transid for ino %llu, have %llu,%llu expect [0, %llu)",
+		      inode_id, generation, transid, gen_uplimit);
 		if (repair) {
 			ret = repair_inode_gen_lowmem(root, path);
 			if (ret < 0)
-- 
2.28.0


  reply	other threads:[~2020-08-26  1:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26  0:52 [PATCH 0/3] btrfs-progs: check: add inode invalid transid detect and repair support Qu Wenruo
2020-08-26  0:52 ` Qu Wenruo [this message]
2020-08-26 14:34   ` [PATCH 1/3] btrfs-progs: check/lowmem: add inode " Josef Bacik
2020-08-26  0:52 ` [PATCH 2/3] btrfs-progs: check/original: " Qu Wenruo
2020-08-26 14:35   ` Josef Bacik
2020-08-26  0:52 ` [PATCH 3/3] btrfs-progs: tests/fsck: add test image for inode transid repair Qu Wenruo
2020-08-26 14:35   ` Josef Bacik
2020-08-31 15:09 ` [PATCH 0/3] btrfs-progs: check: add inode invalid transid detect and repair support 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=20200826005233.90063-2-wqu@suse.com \
    --to=wqu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.