Skip to contentSkip to conversation

f2fs: fix to data block override node segment by mistake

PATCH Superseded zhengliang 2 participants 3 messages Feb 25, 2019 – Feb 27, 2019 F2FS file system

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

zhengliang

author
#0 lore raw

PATCH v3 1/1 f2fs: fix to data block override node segment by mistake

v2->v3: It describe the problem scenario more accurately.

TASK A TASK kworker TASK B TASK C

open
write
close
f2fs_write_data_pages
f2fs_write_cache_pages
f2fs_outplace_write_data
f2fs_allocate_data_block (get block in seg S,
S is full, and only
have this valid data
block)
allocate_segment
locate_dirty_segment (mark S as PRE)
f2fs_submit_page_write (submit but is not
written on dev)
unlink
iput_final
f2fs_drop_inode
f2fs_truncate
(not evict)
write_checkpoint
flush merged bio but not wait file data writeback set_prefree_as_free (mark S as FREE)
update NODE/DATA allocate_segment (select S)
writeback done

maintainer
#1 lore raw
Quoted 21 lines · zhengliang

v2->v3: It describe the problem scenario more accurately.

TASK A TASK kworker TASK B TASK C

open
write
close
f2fs_write_data_pages
f2fs_write_cache_pages
f2fs_outplace_write_data
f2fs_allocate_data_block (get block in seg S,
S is full, and only have this valid data block)
allocate_segment locate_dirty_segment (mark S as PRE)
f2fs_submit_page_write (submit but is not
written on dev)
unlink
iput_final
f2fs_drop_inode

Quoted 8 lines

f2fs_truncate
(not evict)
write_checkpoint
flush merged bio but not wait file data writeback set_prefree_as_free (mark S as FREE)
update NODE/DATA allocate_segment (select S)
writeback done

Patch was broken?

author Reviewed-by Chao Yu
#2 lore raw

I'm very sorry I forget to attach the patch in v3.

--------

fs/f2fs/super.c +4 -0
index c46a1d43..60f0599 100644
@@ -915,6 +915,10 @@ static int f2fs_drop_inode(struct inode *inode)
                        sb_start_intwrite(inode->i_sb);
                        f2fs_i_size_write(inode, 0);
 
+                       f2fs_submit_merged_write_cond(F2FS_I_SB(inode),
+                                       inode, NULL, 0, DATA);
+                       truncate_inode_pages_final(inode->i_mapping);
+
                        if (F2FS_HAS_BLOCKS(inode))
                                f2fs_truncate(inode);
 
Quoted 31 lines · Jaegeuk Kim
Quoted 21 lines · zhengliang

v2->v3: It describe the problem scenario more accurately.

TASK A TASK kworker TASK B TASK C

open
write
close
f2fs_write_data_pages
f2fs_write_cache_pages
f2fs_outplace_write_data
f2fs_allocate_data_block (get block in seg S,
S is full, and only have this valid data block)
allocate_segment locate_dirty_segment (mark S as PRE)
f2fs_submit_page_write (submit but is not
written on dev)
unlink
iput_final
f2fs_drop_inode

Quoted 8 lines

f2fs_truncate
(not evict)
write_checkpoint
flush merged bio but not wait file data writeback set_prefree_as_free (mark S as FREE)
update NODE/DATA allocate_segment (select S)
writeback done

Quoted 4 lines

Patch was broken?

.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel