On 2023/11/18 10:03, Daniel Rosenberg wrote:
The cache is initialized during the first read, however, it requires the
block size to establish its buffer. This disables the cache until the
block size is known.

Hi Daniel,

How about this? It be more explicit to indicate the logic?

---
 fsck/mount.c      | 2 ++
 include/f2fs_fs.h | 3 +++
 lib/libf2fs_io.c  | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/fsck/mount.c b/fsck/mount.c
index 72516f4..4dfb996 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1238,6 +1238,8 @@ int init_sb_info(struct f2fs_sb_info *sbi)
        MSG(0, "Info: total FS sectors = %"PRIu64" (%"PRIu64" MB)\n",
                                total_sectors, total_sectors >>
                                                (20 - get_sb(log_sectorsize)));
+
+       c.cache_config.blksize_initialized = true;
        return 0;
 }

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 6df2e73..e377d48 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -460,6 +460,9 @@ typedef struct {
        unsigned max_hash_collision;

        bool dbg_en;
+
+       /* whether blksize has been initialized */
+       bool blksize_initialized;
 } dev_cache_config_t;

 /* f2fs_configration for compression used for sload.f2fs */
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index 39d3777..bb77418 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -199,6 +199,10 @@ void dcache_init(void)
 {
        long n;

+       /* Must not initiate cache until block size is known */
+       if (!c.cache_config.blksize_initialized)
+               return;
+
        if (c.cache_config.num_cache_entry <= 0)
                return;

--
2.40.1




_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to