]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
f2fs: fix to consider multiple device for readonly check
authorChao Yu <yuchao0@huawei.com>
Mon, 22 Apr 2019 12:22:36 +0000 (20:22 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 9 May 2019 04:23:12 +0000 (21:23 -0700)
This patch introduce f2fs_hw_is_readonly() to check whether lower
device is readonly or not, it adapts multiple device scenario.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/super.c

index 97e4ef71de64491c752efdadac47e60630e0682c..1c814a309748be41065294827a646ff02a508bfb 100644 (file)
@@ -3609,6 +3609,20 @@ static inline bool f2fs_realtime_discard_enable(struct f2fs_sb_info *sbi)
                                        f2fs_hw_should_discard(sbi);
 }
 
+static inline bool f2fs_hw_is_readonly(struct f2fs_sb_info *sbi)
+{
+       int i;
+
+       if (!f2fs_is_multi_device(sbi))
+               return bdev_read_only(sbi->sb->s_bdev);
+
+       for (i = 0; i < sbi->s_ndevs; i++)
+               if (bdev_read_only(FDEV(i).bdev))
+                       return true;
+       return false;
+}
+
+
 static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
 {
        clear_opt(sbi, ADAPTIVE);
index fefc8cc6e756d462c8e909dcb1cd60d79afe39f4..29d985cf830175b90966f89042bad8e991900d85 100644 (file)
@@ -3377,7 +3377,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
                 * mount should be failed, when device has readonly mode, and
                 * previous checkpoint was not done by clean system shutdown.
                 */
-               if (bdev_read_only(sb->s_bdev) &&
+               if (f2fs_hw_is_readonly(sbi) &&
                                !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {
                        err = -EROFS;
                        goto free_meta;