On Nov 05, 2019 / 20:03, Chao Yu wrote: > On 2019/10/28 14:58, Shin'ichiro Kawasaki wrote: > > On sudden f2fs shutdown, write pointers of zoned block devices can go > > further but f2fs meta data keeps current segments at positions before the > > write operations. After remounting the f2fs, this inconsistency causes > > write operations not at write pointers and "Unaligned write command" > > error is reported. > > > > To avoid the error, compare current segments with write pointers of open > > zones the current segments point to, during mount operation. If the write > > pointer position is not aligned with the current segment position, assign > > a new zone to the current segments. Also check the newly assigned zone > > has write pointer at zone start. If not, make mount fail and ask users to > > run fsck. > > > > Perform the consistency check twice. Once during fsync recovery. Not to > > lose the fsync data, do the check after fsync data gets restored and > > before checkpoint commit which flushes data at current segment positions. > > The second check is done at end of f2fs_fill_super() to make sure the > > write pointer consistency regardless of fsync data recovery execution. > > > > Signed-off-by: Shin'ichiro Kawasaki <[email protected]> > > --- > > fs/f2fs/f2fs.h | 1 + > > fs/f2fs/recovery.c | 6 +++ > > fs/f2fs/segment.c | 127 +++++++++++++++++++++++++++++++++++++++++++++ > > fs/f2fs/super.c | 8 +++ > > 4 files changed, 142 insertions(+) > > > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > > index 4024790028aa..0216282c5b80 100644 > > --- a/fs/f2fs/f2fs.h > > +++ b/fs/f2fs/f2fs.h > > @@ -3136,6 +3136,7 @@ void f2fs_write_node_summaries(struct f2fs_sb_info > > *sbi, block_t start_blk); > > int f2fs_lookup_journal_in_cursum(struct f2fs_journal *journal, int type, > > unsigned int val, int alloc); > > void f2fs_flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control > > *cpc); > > +int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi, bool > > check_only); > > int f2fs_build_segment_manager(struct f2fs_sb_info *sbi); > > void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi); > > int __init f2fs_create_segment_manager_caches(void); > > diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c > > index 783773e4560d..c75d1cbae4d1 100644 > > --- a/fs/f2fs/recovery.c > > +++ b/fs/f2fs/recovery.c > > @@ -795,6 +795,12 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, > > bool check_only) > > if (need_writecp) { > > set_sbi_flag(sbi, SBI_IS_RECOVERED); > > > > + /* recover zoned block devices' write pointer consistency */ > > + if (!err && f2fs_sb_has_blkzoned(sbi)) { > > + err = f2fs_fix_curseg_write_pointer(sbi, false); > > Can we check and reset current segment under SBI_POR_DOING's protection? since > once SBI_POR_DOING flag is cleared, kworker is able to flush dirty data/node, > which may trigger unaligned write command if write pointer is inconsistent.
Yes, will move that part before the SBI_POR_DOING flag clear. Thanks. -- Best Regards, Shin'ichiro Kawasaki _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
