summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/dirent.h
diff options
context:
space:
mode:
authorHongbo Li <lihongbo22@huawei.com>2025-01-07 14:18:40 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2025-01-13 20:58:38 +0100
commite614a6c52d32c9c7ff545ca842eb2de4aeb1d2d9 (patch)
tree1846f383297edaff949c804aeaa248ebde263dfa /fs/bcachefs/dirent.h
parentbcachefs: check_unreachable_inodes is not actually PASS_ONLINE yet (diff)
downloadlinux-e614a6c52d32c9c7ff545ca842eb2de4aeb1d2d9.tar.xz
linux-e614a6c52d32c9c7ff545ca842eb2de4aeb1d2d9.zip
bcachefs: make directory i_size meaningful
The isize of directory is 0 in bcachefs if the directory is empty. With more child dirents created, its size ought to change. Many other filesystems changed as that (ie. xfs and btrfs). And many of them changed as the size of child dirent name. Although the directory size may not seem to convey much, we can still give it some meaning. The formula of dentry size as follow: occupied_size = 40 + ALIGN(9 + namelen, 8) Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/dirent.h')
-rw-r--r--fs/bcachefs/dirent.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/bcachefs/dirent.h b/fs/bcachefs/dirent.h
index 362b3b2f2f2e..a633f83c1ac7 100644
--- a/fs/bcachefs/dirent.h
+++ b/fs/bcachefs/dirent.h
@@ -31,6 +31,11 @@ static inline unsigned dirent_val_u64s(unsigned len)
sizeof(u64));
}
+static inline unsigned int dirent_occupied_size(const struct qstr *name)
+{
+ return (BKEY_U64s + dirent_val_u64s(name->len)) * sizeof(u64);
+}
+
int bch2_dirent_read_target(struct btree_trans *, subvol_inum,
struct bkey_s_c_dirent, subvol_inum *);