summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmds-check.c b/cmds-check.c
index d57363c1..3d3d8d79 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -1927,6 +1927,21 @@ static int check_inode_recs(struct btrfs_root *root,
}
/*
+ * We need to record the highest inode number for later 'lost+found'
+ * dir creation.
+ * We must select a ino not used/refered by any existing inode, or
+ * 'lost+found' ino may be a missing ino in a corrupted leaf,
+ * this may cause 'lost+found' dir has wrong nlinks.
+ */
+ cache = last_cache_extent(inode_cache);
+ if (cache) {
+ node = container_of(cache, struct ptr_node, cache);
+ rec = node->data;
+ if (rec->ino > root->highest_inode)
+ root->highest_inode = rec->ino;
+ }
+
+ /*
* We need to repair backrefs first because we could change some of the
* errors in the inode recs.
*