Merge tag 'f2fs-for-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
[sfrench/cifs-2.6.git] / fs / f2fs / super.c
index 206d03c82d96f78b97dbbd1810a2693632d167c0..d00d21a8b53adf8defa18deb55d438e3dd855a1a 100644 (file)
@@ -1712,12 +1712,10 @@ static void f2fs_put_super(struct super_block *sb)
 
        kvfree(sbi->ckpt);
 
-       sb->s_fs_info = NULL;
        if (sbi->s_chksum_driver)
                crypto_free_shash(sbi->s_chksum_driver);
        kfree(sbi->raw_super);
 
-       destroy_device_list(sbi);
        f2fs_destroy_page_array_cache(sbi);
        f2fs_destroy_xattr_caches(sbi);
        mempool_destroy(sbi->write_io_dummy);
@@ -1733,7 +1731,6 @@ static void f2fs_put_super(struct super_block *sb)
 #if IS_ENABLED(CONFIG_UNICODE)
        utf8_unload(sb->s_encoding);
 #endif
-       kfree(sbi);
 }
 
 int f2fs_sync_fs(struct super_block *sb, int sync)
@@ -4285,24 +4282,21 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
                        sbi->aligned_blksize = false;
 
 #ifdef CONFIG_BLK_DEV_ZONED
-               if (bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HM &&
-                               !f2fs_sb_has_blkzoned(sbi)) {
-                       f2fs_err(sbi, "Zoned block device feature not enabled");
-                       return -EINVAL;
-               }
-               if (bdev_zoned_model(FDEV(i).bdev) != BLK_ZONED_NONE) {
+               if (bdev_is_zoned(FDEV(i).bdev)) {
+                       if (!f2fs_sb_has_blkzoned(sbi)) {
+                               f2fs_err(sbi, "Zoned block device feature not enabled");
+                               return -EINVAL;
+                       }
                        if (init_blkz_info(sbi, i)) {
                                f2fs_err(sbi, "Failed to initialize F2FS blkzone information");
                                return -EINVAL;
                        }
                        if (max_devices == 1)
                                break;
-                       f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: %s)",
+                       f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: Host-managed)",
                                  i, FDEV(i).path,
                                  FDEV(i).total_segments,
-                                 FDEV(i).start_blk, FDEV(i).end_blk,
-                                 bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HA ?
-                                 "Host-aware" : "Host-managed");
+                                 FDEV(i).start_blk, FDEV(i).end_blk);
                        continue;
                }
 #endif
@@ -4904,9 +4898,9 @@ static struct dentry *f2fs_mount(struct file_system_type *fs_type, int flags,
 
 static void kill_f2fs_super(struct super_block *sb)
 {
-       if (sb->s_root) {
-               struct f2fs_sb_info *sbi = F2FS_SB(sb);
+       struct f2fs_sb_info *sbi = F2FS_SB(sb);
 
+       if (sb->s_root) {
                set_sbi_flag(sbi, SBI_IS_CLOSE);
                f2fs_stop_gc_thread(sbi);
                f2fs_stop_discard_thread(sbi);
@@ -4933,6 +4927,12 @@ static void kill_f2fs_super(struct super_block *sb)
                        sb->s_flags &= ~SB_RDONLY;
        }
        kill_block_super(sb);
+       /* Release block devices last, after fscrypt_destroy_keyring(). */
+       if (sbi) {
+               destroy_device_list(sbi);
+               kfree(sbi);
+               sb->s_fs_info = NULL;
+       }
 }
 
 static struct file_system_type f2fs_fs_type = {