summaryrefslogtreecommitdiff
authorChao Yu <yuchao0@huawei.com>2019-04-22 12:22:36 (GMT)
committer Jaegeuk Kim <jaegeuk@kernel.org>2019-05-09 04:47:05 (GMT)
commitcbc0f4ebf1561c5e8419513a4512a2aa383833bf (patch)
tree2916824cfd4f159b23205f368db2f63f2db77e9a
parent1b728c7a0d4cdcef0b5432ed852b02372b7f1ec4 (diff)
downloadcommon-cbc0f4ebf1561c5e8419513a4512a2aa383833bf.zip
common-cbc0f4ebf1561c5e8419513a4512a2aa383833bf.tar.gz
common-cbc0f4ebf1561c5e8419513a4512a2aa383833bf.tar.bz2
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: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat
-rw-r--r--fs/f2fs/f2fs.h14
-rw-r--r--fs/f2fs/super.c2
2 files changed, 15 insertions, 1 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a49faef..0b3dd6a 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3642,6 +3642,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);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f68cd03..9a8a992 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3380,7 +3380,7 @@ try_onemore:
* 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;