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

The inode transid detect and repair is reusing the existing inode
geneartion code.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/check/main.c b/check/main.c
index 9a2ee2a00f9a..e7996b7c8c0e 100644
--- a/check/main.c
+++ b/check/main.c
@@ -620,7 +620,7 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
 		fprintf(stderr, ", invalid inode mode bit 0%o",
 			rec->imode & ~07777);
 	if (errors & I_ERR_INVALID_GEN)
-		fprintf(stderr, ", invalid inode generation");
+		fprintf(stderr, ", invalid inode generation or transid");
 	fprintf(stderr, "\n");
 
 	/* Print the holes if needed */
@@ -912,7 +912,8 @@ static int process_inode_item(struct extent_buffer *eb,
 	 * inode generation uplimit, use super_generation + 1 anyway
 	 */
 	gen_uplimit = btrfs_super_generation(gfs_info->super_copy) + 1;
-	if (btrfs_inode_generation(eb, item) > gen_uplimit)
+	if (btrfs_inode_generation(eb, item) > gen_uplimit ||
+	    btrfs_inode_transid(eb, item) > gen_uplimit)
 		rec->errors |= I_ERR_INVALID_GEN;
 	maybe_free_inode_rec(&active_node->inode_cache, rec);
 	return 0;
@@ -2835,9 +2836,10 @@ static int repair_inode_gen_original(struct btrfs_trans_handle *trans,
 	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]);
 	btrfs_release_path(path);
-	printf("resetting inode generation to %llu for ino %llu\n",
+	printf("resetting inode generation/transid to %llu for ino %llu\n",
 		trans->transid, rec->ino);
 	rec->errors &= ~I_ERR_INVALID_GEN;
 	return 0;
-- 
2.28.0


  parent 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 ` [PATCH 1/3] btrfs-progs: check/lowmem: add inode " Qu Wenruo
2020-08-26 14:34   ` Josef Bacik
2020-08-26  0:52 ` Qu Wenruo [this message]
2020-08-26 14:35   ` [PATCH 2/3] btrfs-progs: check/original: " 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-3-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.