• S
    f2fs: fix race between write_checkpoint and write_begin · 2866fb16
    Sheng Yong 提交于
    The following race could lead to inconsistent SIT bitmap:
    
    Task A                          Task B
    ======                          ======
    f2fs_write_checkpoint
      block_operations
        f2fs_lock_all
          down_write(node_change)
          down_write(node_write)
          ... sync ...
          up_write(node_change)
                                    f2fs_file_write_iter
                                      set_inode_flag(FI_NO_PREALLOC)
                                      ......
                                      f2fs_write_begin(index=0, has inline data)
                                        prepare_write_begin
                                          __do_map_lock(AIO) => down_read(node_change)
                                          f2fs_convert_inline_page => update SIT
                                          __do_map_lock(AIO) => up_read(node_change)
      f2fs_flush_sit_entries <= inconsistent SIT
      finish write checkpoint
      sudden-power-off
    
    If SPO occurs after checkpoint is finished, SIT bitmap will be set
    incorrectly.
    Signed-off-by: NSheng Yong <shengyong1@huawei.com>
    Reviewed-by: NChao Yu <yuchao0@huawei.com>
    Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
    2866fb16
data.c 68.9 KB