f2fs: fix to check readonly condition correctly
Chao Yu
maintainerPATCH v2 1/1 f2fs: fix to check readonly condition correctly
With below case, it can mount multi-device image w/ rw option, however one of secondary device is set as ro, later update will cause panic, so let's introduce f2fs_dev_is_readonly(), and check multi-devices rw status in f2fs_remount() w/ it in order to avoid such inconsistent mount status.
mkfs.f2fs -c /dev/zram1 /dev/zram0 -f
blockdev --setro /dev/zram1
mount -t f2fs dev/zram0 /mnt/f2fs
mount: /mnt/f2fs: WARNING: source write-protected, mounted read-only. mount -t f2fs -o remount,rw mnt/f2fs
dd if=/dev/zero of=/mnt/f2fs/file bs=1M count=8192
kernel BUG at fs/f2fs/inline.c:258!
RIP: 0010:f2fs_write_inline_data+0x23e/0x2d0 [f2fs] Call Trace: f2fs_write_single_data_page+0x26b/0x9f0 [f2fs] f2fs_write_cache_pages+0x389/0xa60 [f2fs] __f2fs_write_data_pages+0x26b/0x2d0 [f2fs] f2fs_write_data_pages+0x2e/0x40 [f2fs] do_writepages+0xd3/0x1b0 __writeback_single_inode+0x5b/0x420 writeback_sb_inodes+0x236/0x5a0 __writeback_inodes_wb+0x56/0xf0 wb_writeback+0x2a3/0x490 wb_do_writeback+0x2b2/0x330 wb_workfn+0x6a/0x260 process_one_work+0x270/0x5e0 worker_thread+0x52/0x3e0 kthread+0xf4/0x120 ret_from_fork+0x29/0x50
---
v2:
- update commit message to describe details of the issue.
- fix to do the check in f2fs_remount().
fs/f2fs/f2fs.h | 5 +++++ fs/f2fs/super.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/f2fs.h +5 -0
@@ -4446,6 +4446,11 @@ static inline bool f2fs_hw_is_readonly(struct f2fs_sb_info *sbi)return false; } +static inline bool f2fs_dev_is_readonly (struct f2fs_sb_info *sbi) +{ +return f2fs_sb_has_readonly (sbi) ||f2fs_hw_is_readonly (sbi); +} +static inline bool f2fs_lfs_mode (struct f2fs_sb_info *sbi) {return F2FS_OPTION (sbi).fs_mode ==FS_MODE_LFS ;
fs/f2fs/super.c +1 -1
@@ -2321,7 +2321,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)if (f2fs_readonly (sb) && (*flags &SB_RDONLY )) goto skip; -if (f2fs_sb_has_readonly (sbi) && !(*flags &SB_RDONLY )) { +if (f2fs_dev_is_readonly (sbi) && !(*flags &SB_RDONLY )) { err = -EROFS ; goto restore_opts; }
Signature · 8 lines
2.36.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:
Quoted 5 lines · On Tue, 4 Apr 2023 23:28:07 +0800 you wrote:
With below case, it can mount multi-device image w/ rw option, however one of secondary device is set as ro, later update will cause panic, so let's introduce
f2fs_dev_is_readonly(), and check multi-devices rw status inf2fs_remount()w/ it in order to avoid such inconsistent mount status.
Quoted 8 lines
mkfs.f2fs -c
/dev/zram1/dev/zram0-f
blockdev --setro/dev/zram1
mount -t f2fs dev/zram0/mnt/f2fs
mount:/mnt/f2fs: WARNING: source write-protected, mounted read-only. mount -t f2fs -o remount,rw mnt/f2fs
dd if=/dev/zero of=/mnt/f2fs/file bs=1M count=8192[...]
Here is the summary with links:
- [f2fs-dev,v2] f2fs: fix to check readonly condition correctly
https://git.kernel.org/jaegeuk/f2fs/c/2bce08d26c0f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html