aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkatao <katao@xiaomi.com>2018-03-27 13:25:46 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2018-04-02 22:57:31 -0700
commit74bd6a84699fa15662a16c484d70736a7b314107 (patch)
treec541296bec3891dd105f373b7ed91659005977f6 /lib
parent58364e9aedd612f3ca59f578e29ee0cc441497f8 (diff)
downloadf2fs-tools-74bd6a84699fa15662a16c484d70736a7b314107.tar.gz
libf2fs,mkfs.f2fs: add wanted_sector_size for wanted_total_sectors
The wanted_total_sectors was determined by device sector size, but sometimes we don't know precise sector_size by default. So, let's give wanted_sector_size in such the ambiguous situation. Signed-off-by: katao <katao@xiaomi.com> Signed-off-by: Junling Zheng <zhengjunling@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libf2fs.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index ffdbccb..bb7fe2e 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -593,6 +593,7 @@ void f2fs_init_configuration(void)
c.blks_per_seg = DEFAULT_BLOCKS_PER_SEGMENT;
c.rootdev_name = get_rootdev();
c.wanted_total_sectors = -1;
+ c.wanted_sector_size = -1;
c.zoned_mode = 0;
c.zoned_model = 0;
c.zone_blocks = 0;
@@ -900,6 +901,18 @@ int get_device_info(int i)
dev->zone_blocks);
}
#endif
+ /* adjust wanted_total_sectors */
+ if (c.wanted_total_sectors != -1) {
+ MSG(0, "Info: wanted sectors = %"PRIu64" (in %"PRIu64" bytes)\n",
+ c.wanted_total_sectors, c.wanted_sector_size);
+ if (c.wanted_sector_size == -1) {
+ c.wanted_sector_size = dev->sector_size;
+ } else if (dev->sector_size != c.wanted_sector_size) {
+ c.wanted_total_sectors *= c.wanted_sector_size;
+ c.wanted_total_sectors /= dev->sector_size;
+ }
+ }
+
c.total_sectors += dev->total_sectors;
return 0;
}