1. 26 Apr, 2021 2 commits
  2. 25 Apr, 2021 1 commit
  3. 22 Apr, 2021 1 commit
  4. 19 Apr, 2021 1 commit
  5. 13 Apr, 2021 3 commits
    • Yi Chen's avatar
      f2fs: fix to avoid NULL pointer dereference · 594b6d04
      Yi Chen authored
      Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
      pc : f2fs_put_page+0x1c/0x26c
      lr : __revoke_inmem_pages+0x544/0x75c
      f2fs_put_page+0x1c/0x26c
      __revoke_inmem_pages+0x544/0x75c
      __f2fs_commit_inmem_pages+0x364/0x3c0
      f2fs_commit_inmem_pages+0xc8/0x1a0
      f2fs_ioc_commit_atomic_write+0xa4/0x15c
      f2fs_ioctl+0x5b0/0x1574
      file_ioctl+0x154/0x320
      do_vfs_ioctl+0x164/0x740
      __arm64_sys_ioctl+0x78/0xa4
      el0_svc_common+0xbc/0x1d0
      el0_svc_handler+0x74/0x98
      el0_svc+0x8/0xc
      
      In f2fs_put_page, we access page->mapping is NULL.
      The root cause is:
      In some cases, the page refcount and ATOMIC_WRITTEN_PAGE
      flag miss set for page-priavte flag has been set.
      We add f2fs_bug_on like this:
      
      f2fs_register_inmem_page()
      {
      	...
      	f2fs_set_page_private(page, ATOMIC_WRITTEN_PAGE);
      
      	f2fs_bug_on(F2FS_I_SB(inode), !IS_ATOMIC_WRITTEN_PAGE(page));
      	...
      }
      
      The bug on stack follow link this:
      PC is at f2fs_register_inmem_page+0x238/0x2b4
      LR is at f2fs_register_inmem_page+0x2a8/0x2b4
      f2fs_register_inmem_page+0x238/0x2b4
      f2fs_set_data_page_dirty+0x104/0x164
      set_page_dirty+0x78/0xc8
      f2fs_write_end+0x1b4/0x444
      generic_perform_write+0x144/0x1cc
      __generic_file_write_iter+0xc4/0x174
      f2fs_file_write_iter+0x2c0/0x350
      __vfs_write+0x104/0x134
      vfs_write+0xe8/0x19c
      SyS_pwrite64+0x78/0xb8
      
      To fix this issue, let's add page refcount add page-priavte flag.
      The page-private flag is not cleared and needs further analysis.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarGe Qiu <qiuge@huawei.com>
      Signed-off-by: default avatarDehe Gu <gudehe@huawei.com>
      Signed-off-by: default avatarYi Chen <chenyi77@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      594b6d04
    • Chao Yu's avatar
      f2fs: avoid duplicated codes for cleanup · 453e2ff8
      Chao Yu authored
      f2fs_segment_has_free_slot() was copied and modified from
      __next_free_blkoff(), they are almost the same, clean up to
      reuse common code as much as possible.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      453e2ff8
    • Chao Yu's avatar
      f2fs: document: add description about compressed space handling · 38740707
      Chao Yu authored
      User or developer may still be confused about why f2fs doesn't expose
      compressed space to userspace, add description about compressed space
      handling policy into f2fs documentation.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      38740707
  6. 10 Apr, 2021 1 commit
  7. 06 Apr, 2021 3 commits
  8. 02 Apr, 2021 1 commit
  9. 31 Mar, 2021 3 commits
    • Yi Zhuang's avatar
      f2fs: Fix a hungtask problem in atomic write · be1ee45d
      Yi Zhuang authored
      In the cache writing process, if it is an atomic file, increase the page
      count of F2FS_WB_CP_DATA, otherwise increase the page count of
      F2FS_WB_DATA.
      
      When you step into the hook branch due to insufficient memory in
      f2fs_write_begin, f2fs_drop_inmem_pages_all will be called to traverse
      all atomic inodes and clear the FI_ATOMIC_FILE mark of all atomic files.
      
      In f2fs_drop_inmem_pages,first acquire the inmem_lock , revoke all the
      inmem_pages, and then clear the FI_ATOMIC_FILE mark. Before this mark is
      cleared, other threads may hold inmem_lock to add inmem_pages to the inode
      that has just been emptied inmem_pages, and increase the page count of
      F2FS_WB_CP_DATA.
      
      When the IO returns, it is found that the FI_ATOMIC_FILE flag is cleared
      by f2fs_drop_inmem_pages_all, and f2fs_is_atomic_file returns false,which
      causes the page count of F2FS_WB_DATA to be decremented. The page count of
      F2FS_WB_CP_DATA cannot be cleared. Finally, hungtask is triggered in
      f2fs_wait_on_all_pages because get_pages will never return zero.
      
      process A:				process B:
      f2fs_drop_inmem_pages_all
      ->f2fs_drop_inmem_pages of inode#1
          ->mutex_lock(&fi->inmem_lock)
          ->__revoke_inmem_pages of inode#1	f2fs_ioc_commit_atomic_write
          ->mutex_unlock(&fi->inmem_lock)	->f2fs_commit_inmem_pages of inode#1
      					->mutex_lock(&fi->inmem_lock)
      					->__f2fs_commit_inmem_pages
      					    ->f2fs_do_write_data_page
      					        ->f2fs_outplace_write_data
      					            ->do_write_page
      					                ->f2fs_submit_page_write
      					                    ->inc_page_count(sbi, F2FS_WB_CP_DATA )
      					->mutex_unlock(&fi->inmem_lock)
          ->spin_lock(&sbi->inode_lock[ATOMIC_FILE]);
          ->clear_inode_flag(inode, FI_ATOMIC_FILE)
          ->spin_unlock(&sbi->inode_lock[ATOMIC_FILE])
      					f2fs_write_end_io
      					->dec_page_count(sbi, F2FS_WB_DATA );
      
      We can fix the problem by putting the action of clearing the FI_ATOMIC_FILE
      mark into the inmem_lock lock. This operation can ensure that no one will
      submit the inmem pages before the FI_ATOMIC_FILE mark is cleared, so that
      there will be no atomic writes waiting for writeback.
      
      Fixes: 57864ae5 ("f2fs: limit # of inmemory pages")
      Signed-off-by: default avatarYi Zhuang <zhuangyi1@huawei.com>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      be1ee45d
    • Chao Yu's avatar
      f2fs: fix to restrict mount condition on readonly block device · 23738e74
      Chao Yu authored
      When we mount an unclean f2fs image in a readonly block device, let's
      make mount() succeed only when there is no recoverable data in that
      image, otherwise after mount(), file fsyned won't be recovered as user
      expected.
      
      Fixes: 938a1842 ("f2fs: give a warning only for readonly partition")
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      23738e74
    • Chao Yu's avatar
      f2fs: introduce gc_merge mount option · 5911d2d1
      Chao Yu authored
      In this patch, we will add two new mount options: "gc_merge" and
      "nogc_merge", when background_gc is on, "gc_merge" option can be
      set to let background GC thread to handle foreground GC requests,
      it can eliminate the sluggish issue caused by slow foreground GC
      operation when GC is triggered from a process with limited I/O
      and CPU resources.
      
      Original idea is from Xiang.
      Signed-off-by: default avatarGao Xiang <xiang@kernel.org>
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      5911d2d1
  10. 26 Mar, 2021 14 commits
  11. 23 Mar, 2021 1 commit
    • Chao Yu's avatar
      f2fs: fix to align to section for fallocate() on pinned file · e1175f02
      Chao Yu authored
      Now, fallocate() on a pinned file only allocates blocks which aligns
      to segment rather than section, so GC may try to migrate pinned file's
      block, and after several times of failure, pinned file's block could
      be migrated to other place, however user won't be aware of such
      condition, and then old obsolete block address may be readed/written
      incorrectly.
      
      To avoid such condition, let's try to allocate pinned file's blocks
      with section alignment.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e1175f02
  12. 12 Mar, 2021 9 commits