Message ID | 20240116140513.1222-1-qwjhust@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [f2fs-dev,v2] f2fs: fix zoned block device information initialization | expand |
Hi Wenjie, kernel test robot noticed the following build warnings: https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Wenjie-Qi/f2fs-fix-zoned-block-device-information-initialization/20240116-220824 base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test patch link: https://lore.kernel.org/r/20240116140513.1222-1-qwjhust%40gmail.com patch subject: [PATCH v2] f2fs: fix zoned block device information initialization config: x86_64-randconfig-161-20240119 (https://download.01.org/0day-ci/archive/20240120/202401201237.ovVyEKvs-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org> | Closes: https://lore.kernel.org/r/202401201237.ovVyEKvs-lkp@intel.com/ New smatch warnings: fs/f2fs/super.c:2393 f2fs_remount() warn: missing error code 'err' Old smatch warnings: fs/f2fs/super.c:4040 read_raw_super_block() warn: possible memory leak of 'super' vim +/err +2393 fs/f2fs/super.c 4b2414d04e9912 Chao Yu 2017-08-08 2371 df728b0f6954c3 Jaegeuk Kim 2016-03-23 2372 /* recover superblocks we couldn't write due to previous RO mount */ 1751e8a6cb935e Linus Torvalds 2017-11-27 2373 if (!(*flags & SB_RDONLY) && is_sbi_flag_set(sbi, SBI_NEED_SB_WRITE)) { df728b0f6954c3 Jaegeuk Kim 2016-03-23 2374 err = f2fs_commit_super(sbi, false); dcbb4c10e6d969 Joe Perches 2019-06-18 2375 f2fs_info(sbi, "Try to recover all the superblocks, ret: %d", dcbb4c10e6d969 Joe Perches 2019-06-18 2376 err); df728b0f6954c3 Jaegeuk Kim 2016-03-23 2377 if (!err) df728b0f6954c3 Jaegeuk Kim 2016-03-23 2378 clear_sbi_flag(sbi, SBI_NEED_SB_WRITE); df728b0f6954c3 Jaegeuk Kim 2016-03-23 2379 } df728b0f6954c3 Jaegeuk Kim 2016-03-23 2380 458c15dfbce62c Chao Yu 2023-05-23 2381 default_options(sbi, true); 26666c8a4366de Chao Yu 2014-09-15 2382 696c018c7718f5 Namjae Jeon 2013-06-16 2383 /* parse mount options */ ed318a6cc0b620 Eric Biggers 2020-05-12 2384 err = parse_options(sb, data, true); 696c018c7718f5 Namjae Jeon 2013-06-16 2385 if (err) 696c018c7718f5 Namjae Jeon 2013-06-16 2386 goto restore_opts; 696c018c7718f5 Namjae Jeon 2013-06-16 2387 ed7a1efe8afd55 Wenjie Qi 2024-01-16 2388 #ifdef CONFIG_BLK_DEV_ZONED ed7a1efe8afd55 Wenjie Qi 2024-01-16 2389 if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) { ed7a1efe8afd55 Wenjie Qi 2024-01-16 2390 f2fs_err(sbi, ed7a1efe8afd55 Wenjie Qi 2024-01-16 2391 "zoned: max active zones %u is too small, need at least %u active zones", ed7a1efe8afd55 Wenjie Qi 2024-01-16 2392 sbi->max_active_zones, F2FS_OPTION(sbi).active_logs); ed7a1efe8afd55 Wenjie Qi 2024-01-16 @2393 goto restore_opts; err = -EINVAL? ed7a1efe8afd55 Wenjie Qi 2024-01-16 2394 } ed7a1efe8afd55 Wenjie Qi 2024-01-16 2395 #endif ed7a1efe8afd55 Wenjie Qi 2024-01-16 2396 b62e71be2110d8 Chao Yu 2023-04-23 2397 /* flush outstanding errors before changing fs state */ b62e71be2110d8 Chao Yu 2023-04-23 2398 flush_work(&sbi->s_error_work); b62e71be2110d8 Chao Yu 2023-04-23 2399 696c018c7718f5 Namjae Jeon 2013-06-16 2400 /* 696c018c7718f5 Namjae Jeon 2013-06-16 2401 * Previous and new state of filesystem is RO, 876dc59eb1f013 Gu Zheng 2014-04-11 2402 * so skip checking GC and FLUSH_MERGE conditions. 696c018c7718f5 Namjae Jeon 2013-06-16 2403 */ 1751e8a6cb935e Linus Torvalds 2017-11-27 2404 if (f2fs_readonly(sb) && (*flags & SB_RDONLY)) 696c018c7718f5 Namjae Jeon 2013-06-16 2405 goto skip; 696c018c7718f5 Namjae Jeon 2013-06-16 2406 d78dfefcde9d31 Chao Yu 2023-04-04 2407 if (f2fs_dev_is_readonly(sbi) && !(*flags & SB_RDONLY)) { a7d9fe3c338870 Jaegeuk Kim 2021-05-21 2408 err = -EROFS; a7d9fe3c338870 Jaegeuk Kim 2021-05-21 2409 goto restore_opts; a7d9fe3c338870 Jaegeuk Kim 2021-05-21 2410 } a7d9fe3c338870 Jaegeuk Kim 2021-05-21 2411
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 65294e3b0bef..669f84f6b0e5 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1551,6 +1551,7 @@ struct f2fs_sb_info { #ifdef CONFIG_BLK_DEV_ZONED unsigned int blocks_per_blkz; /* F2FS blocks per zone */ + unsigned int max_active_zones; /* max zone resources of the zoned device */ #endif /* for node-related operations */ diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 206d03c82d96..b65547f4c710 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2385,6 +2385,15 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) if (err) goto restore_opts; +#ifdef CONFIG_BLK_DEV_ZONED + if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) { + f2fs_err(sbi, + "zoned: max active zones %u is too small, need at least %u active zones", + sbi->max_active_zones, F2FS_OPTION(sbi).active_logs); + goto restore_opts; + } +#endif + /* flush outstanding errors before changing fs state */ flush_work(&sbi->s_error_work); @@ -3932,6 +3941,14 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) if (!f2fs_sb_has_blkzoned(sbi)) return 0; + sbi->max_active_zones = bdev_max_active_zones(bdev); + if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) { + f2fs_err(sbi, + "zoned: max active zones %u is too small, need at least %u active zones", + sbi->max_active_zones, F2FS_OPTION(sbi).active_logs); + return -EINVAL; + } + zone_sectors = bdev_zone_sectors(bdev); if (!is_power_of_2(zone_sectors)) { f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");
If the max active zones of zoned devices are less than the active logs of F2FS, the device may error due to insufficient zone resources when multiple active logs are being written at the same time. If this value is 0, there is no limit. Signed-off-by: Wenjie Qi <qwjhust@gmail.com> --- fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)