Removed fsinfo.block_usage for now

In terms of ease-of-use, a user familiar with other filesystems expects
block_usage in fsinfo. But in terms of practicality, block_usage can be
expensive to find in littlefs, so if it's not needed in the resulting
fsinfo, that operation is wasteful.

It's not clear to me what the best course of action is, but since
block_usage can always be added to fsinfo later, but not removed without
breaking backwards compatibility, I'm leaving this out for now.

Block usage can still be found by explicitly calling lfs_fs_size.
This commit is contained in:
Christopher Haster 2023-06-29 12:23:33 -05:00
parent c5fb3f181b
commit 265692e709
3 changed files with 0 additions and 15 deletions

7
lfs.c
View File

@ -4448,13 +4448,6 @@ static int lfs_fs_rawstat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
fsinfo->disk_version = superblock.version;
}
// find the current block usage
lfs_ssize_t usage = lfs_fs_rawsize(lfs);
if (usage < 0) {
return usage;
}
fsinfo->block_usage = usage;
// other on-disk configuration, we cache all of these for internal use
fsinfo->name_max = lfs->name_max;
fsinfo->file_max = lfs->file_max;

6
lfs.h
View File

@ -285,12 +285,6 @@ struct lfs_fsinfo {
// On-disk version.
uint32_t disk_version;
// Number of blocks in use, this is the same as lfs_fs_size.
//
// Note: block_usage is best effort. If files share COW structures, the
// calculated block_usage may be larger than the actual contents on-disk.
lfs_size_t block_usage;
// Upper limit on the length of file names in bytes.
lfs_size_t name_max;

View File

@ -46,7 +46,6 @@ code = '''
struct lfs_fsinfo fsinfo;
lfs_fs_stat(&lfs, &fsinfo) => 0;
assert(fsinfo.disk_version == LFS_DISK_VERSION);
assert(fsinfo.block_usage > 0 && fsinfo.block_usage < BLOCK_COUNT);
assert(fsinfo.name_max == LFS_NAME_MAX);
assert(fsinfo.file_max == LFS_FILE_MAX);
assert(fsinfo.attr_max == LFS_ATTR_MAX);
@ -74,7 +73,6 @@ code = '''
struct lfs_fsinfo fsinfo;
lfs_fs_stat(&lfs, &fsinfo) => 0;
assert(fsinfo.disk_version == LFS_DISK_VERSION);
assert(fsinfo.block_usage > 0 && fsinfo.block_usage < BLOCK_COUNT);
assert(fsinfo.name_max == TWEAKED_NAME_MAX);
assert(fsinfo.file_max == TWEAKED_FILE_MAX);
assert(fsinfo.attr_max == TWEAKED_ATTR_MAX);