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) // not include the '\0'
To ensure compatibility with the old file system, we have implemented
the check_directory_size in fsck which checks whether the size of
directories matches the expected values during each fsck operation.
To achieve this, we have introduced a new metadata version called
'directory_size' to support this feature. We have conducted the
following tests:
1. Creating and deleting subitems under the new file system;
2. Upgrading from the old file system to the new one;
And the directory size feature works well.
Changes since v2:
https://lore.kernel.org/linux-bcachefs/[email protected]/
- Rebase the code on testing branch.
Changes since v1:
https://lore.kernel.org/all/2sjq2njetbhhqo2zuufrjuarzvo4jl2pid52idwdz45h7li4bm@throc6jwnckk/T/#m3fcb3fbdc17719523285030b9998722df0472ae3
- Add check_directory_size in fsck period.
Hongbo Li (2):
bcachefs: make directory i_size meaningful
bcachefs: bcachefs_metadata_version_directory_size
fs/bcachefs/bcachefs_format.h | 3 ++-
fs/bcachefs/dirent.h | 5 +++++
fs/bcachefs/fs-common.c | 11 +++++++++
fs/bcachefs/fs.c | 13 ++++++-----
fs/bcachefs/fsck.c | 41 ++++++++++++++++++++++++++++++++++
fs/bcachefs/sb-downgrade.c | 5 ++++-
fs/bcachefs/sb-errors_format.h | 3 ++-
7 files changed, 73 insertions(+), 8 deletions(-)
--
2.34.1