Commit f824deb5 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: fix to consider multiple device for readonly check

This patch introduce f2fs_hw_is_readonly() to check whether lower
device is readonly or not, it adapts multiple device scenario.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b471eb99
...@@ -3609,6 +3609,20 @@ static inline bool f2fs_realtime_discard_enable(struct f2fs_sb_info *sbi) ...@@ -3609,6 +3609,20 @@ static inline bool f2fs_realtime_discard_enable(struct f2fs_sb_info *sbi)
f2fs_hw_should_discard(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) static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
{ {
clear_opt(sbi, ADAPTIVE); clear_opt(sbi, ADAPTIVE);
......
...@@ -3377,7 +3377,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -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 * mount should be failed, when device has readonly mode, and
* previous checkpoint was not done by clean system shutdown. * 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)) { !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {
err = -EROFS; err = -EROFS;
goto free_meta; goto free_meta;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment