diff mbox series

[2/3] btrfs-progs: check/original: add inode transid detect and repair support

Message ID 20200826005233.90063-3-wqu@suse.com
State New, archived
Headers show
Series btrfs-progs: check: add inode invalid transid detect and repair support | expand

Commit Message

Qu Wenruo Aug. 26, 2020, 12:52 a.m. UTC
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(-)

Comments

Josef Bacik Aug. 26, 2020, 2:35 p.m. UTC | #1
On 8/25/20 8:52 PM, Qu Wenruo wrote:
> The inode transid detect and repair is reusing the existing inode
> geneartion code.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef
diff mbox series

Patch

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;