]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bcachefs: bcachefs_metadata_version_inode_depth
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 3 Aug 2023 00:27:38 +0000 (20:27 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 29 Dec 2024 18:30:39 +0000 (13:30 -0500)
commit59c50511f7a8ecded211656425c9b92e31329333
treeef9f98dd3e56e565469741676e356359f926611c
parent80c6352c2c98bc7b399ce94ae7e54b5b36aad731
bcachefs: bcachefs_metadata_version_inode_depth

This adds a new inode field, bi_depth, for directory inodes: this allows
us to make the check_directory_structure pass much more efficient.

Currently, to ensure the filesystem is fully connect and has no loops,
for every directory we follow backpointers until we find the root. But
by adding a depth counter, it sufficies to only check the parent of each
directory, and check that the parent's bi_depth is smaller.

(fsck doesn't require that bi_depth = parent->bi_depth + 1; if a rename
causes bi_depth off, but the chain to the root is still strictly
decreasing, then the algorithm still works and there's no need for fsck
to fixup the bi_depth fields).

We've already checked backpointers, so we know that every directory
(excluding the root)has a valid parent: if bi_depth is always
decreasing, every chain must terminate, and terminate at the root
directory.

bi_depth will not necessarily be correct when fsck runs, due to
directory renames - we can't change bi_depth on every child directory
when renaming a directory. That's ok; fsck will silently fix the
bi_depth field as needed, and future fsck runs will be much faster.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs_format.h
fs/bcachefs/fs-common.c
fs/bcachefs/fsck.c
fs/bcachefs/inode.h
fs/bcachefs/inode_format.h