An error occurred fetching the project authors.
  1. 13 Apr, 2023 2 commits
    • Yohan Joung's avatar
      f2fs: add radix_tree_preload_end in error case · d09bd853
      Yohan Joung authored
      To prevent excessive increase in preemption count
      add radix_tree_preload_end in retry
      Signed-off-by: default avatarYohan Joung <yohan.joung@sk.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      d09bd853
    • Chao Yu's avatar
      f2fs: fix to recover quota data correctly · e1bb7d3d
      Chao Yu authored
      With -O quota mkfs option, xfstests generic/417 fails due to fsck detects
      data corruption on quota inodes.
      
      [ASSERT] (fsck_chk_quota_files:2051)  --> Quota file is missing or invalid quota file content found.
      
      The root cause is there is a hole f2fs doesn't hold quota inodes,
      so all recovered quota data will be dropped due to SBI_POR_DOING
      flag was set.
      - f2fs_fill_super
       - f2fs_recover_orphan_inodes
        - f2fs_enable_quota_files
        - f2fs_quota_off_umount
      <--- quota inodes were dropped --->
       - f2fs_recover_fsync_data
        - f2fs_enable_quota_files
        - f2fs_quota_off_umount
      
      This patch tries to eliminate the hole by holding quota inodes
      during entire recovery flow as below:
      - f2fs_fill_super
       - f2fs_recover_quota_begin
       - f2fs_recover_orphan_inodes
       - f2fs_recover_fsync_data
       - f2fs_recover_quota_end
      
      Then, recovered quota data can be persisted after SBI_POR_DOING
      is cleared.
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e1bb7d3d
  2. 10 Apr, 2023 2 commits
    • Chao Yu's avatar
      f2fs: fix to drop all dirty pages during umount() if cp_error is set · c9b3649a
      Chao Yu authored
      xfstest generic/361 reports a bug as below:
      
      f2fs_bug_on(sbi, sbi->fsync_node_num);
      
      kernel BUG at fs/f2fs/super.c:1627!
      RIP: 0010:f2fs_put_super+0x3a8/0x3b0
      Call Trace:
       generic_shutdown_super+0x8c/0x1b0
       kill_block_super+0x2b/0x60
       kill_f2fs_super+0x87/0x110
       deactivate_locked_super+0x39/0x80
       deactivate_super+0x46/0x50
       cleanup_mnt+0x109/0x170
       __cleanup_mnt+0x16/0x20
       task_work_run+0x65/0xa0
       exit_to_user_mode_prepare+0x175/0x190
       syscall_exit_to_user_mode+0x25/0x50
       do_syscall_64+0x4c/0x90
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      During umount(), if cp_error is set, f2fs_wait_on_all_pages() should
      not stop waiting all F2FS_WB_CP_DATA pages to be writebacked, otherwise,
      fsync_node_num can be non-zero after f2fs_wait_on_all_pages() causing
      this bug.
      
      In this case, to avoid deadloop in f2fs_wait_on_all_pages(), it needs
      to drop all dirty pages rather than redirtying them.
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      c9b3649a
    • Chao Yu's avatar
      f2fs: use f2fs_hw_is_readonly() instead of bdev_read_only() · 68f0453d
      Chao Yu authored
      f2fs has supported multi-device feature, to check devices' rw status,
      it should use f2fs_hw_is_readonly() rather than bdev_read_only(), fix
      it.
      
      Meanwhile, it removes f2fs_hw_is_readonly() check condition in:
      - f2fs_write_checkpoint()
      - f2fs_convert_inline_inode()
      As it has checked f2fs_readonly() condition, and if f2fs' devices
      were readonly, f2fs_readonly() must be true.
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      68f0453d
  3. 29 Mar, 2023 2 commits
  4. 07 Feb, 2023 1 commit
  5. 03 Feb, 2023 1 commit
  6. 02 Feb, 2023 2 commits
  7. 11 Jan, 2023 1 commit
  8. 02 Nov, 2022 2 commits
  9. 04 Oct, 2022 4 commits
    • Chao Yu's avatar
      f2fs: support recording stop_checkpoint reason into super_block · a9cfee0e
      Chao Yu authored
      This patch supports to record stop_checkpoint error into
      f2fs_super_block.s_stop_reason[].
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      a9cfee0e
    • Chao Yu's avatar
      f2fs: fix to account FS_CP_DATA_IO correctly · d80afefb
      Chao Yu authored
      f2fs_inode_info.cp_task was introduced for FS_CP_DATA_IO accounting
      since commit b0af6d49 ("f2fs: add app/fs io stat").
      
      However, cp_task usage coverage has been increased due to below
      commits:
      commit 040d2bb3 ("f2fs: fix to avoid deadloop if data_flush is on")
      commit 186857c5 ("f2fs: fix potential recursive call when enabling data_flush")
      
      So that, if data_flush mountoption is on, when data flush was
      triggered from background, the IO from data flush will be accounted
      as checkpoint IO type incorrectly.
      
      In order to fix this issue, this patch splits cp_task into two:
      a) cp_task: used for IO accounting
      b) wb_task: used to avoid deadlock
      
      Fixes: 040d2bb3 ("f2fs: fix to avoid deadloop if data_flush is on")
      Fixes: 186857c5 ("f2fs: fix potential recursive call when enabling data_flush")
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      d80afefb
    • Chao Yu's avatar
      f2fs: fix to do sanity check on destination blkaddr during recovery · 0ef4ca04
      Chao Yu authored
      As Wenqing Liu reported in bugzilla:
      
      https://bugzilla.kernel.org/show_bug.cgi?id=216456
      
      loop5: detected capacity change from 0 to 131072
      F2FS-fs (loop5): recover_inode: ino = 6, name = hln, inline = 1
      F2FS-fs (loop5): recover_data: ino = 6 (i_size: recover) err = 0
      F2FS-fs (loop5): recover_inode: ino = 6, name = hln, inline = 1
      F2FS-fs (loop5): recover_data: ino = 6 (i_size: recover) err = 0
      F2FS-fs (loop5): recover_inode: ino = 6, name = hln, inline = 1
      F2FS-fs (loop5): recover_data: ino = 6 (i_size: recover) err = 0
      F2FS-fs (loop5): Bitmap was wrongly set, blk:5634
      ------------[ cut here ]------------
      WARNING: CPU: 3 PID: 1013 at fs/f2fs/segment.c:2198
      RIP: 0010:update_sit_entry+0xa55/0x10b0 [f2fs]
      Call Trace:
       <TASK>
       f2fs_do_replace_block+0xa98/0x1890 [f2fs]
       f2fs_replace_block+0xeb/0x180 [f2fs]
       recover_data+0x1a69/0x6ae0 [f2fs]
       f2fs_recover_fsync_data+0x120d/0x1fc0 [f2fs]
       f2fs_fill_super+0x4665/0x61e0 [f2fs]
       mount_bdev+0x2cf/0x3b0
       legacy_get_tree+0xed/0x1d0
       vfs_get_tree+0x81/0x2b0
       path_mount+0x47e/0x19d0
       do_mount+0xce/0xf0
       __x64_sys_mount+0x12c/0x1a0
       do_syscall_64+0x38/0x90
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      If we enable CONFIG_F2FS_CHECK_FS config, it will trigger a kernel panic
      instead of warning.
      
      The root cause is: in fuzzed image, SIT table is inconsistent with inode
      mapping table, result in triggering such warning during SIT table update.
      
      This patch introduces a new flag DATA_GENERIC_ENHANCE_UPDATE, w/ this
      flag, data block recovery flow can check destination blkaddr's validation
      in SIT table, and skip f2fs_replace_block() to avoid inconsistent status.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarWenqing Liu <wenqingliu0120@gmail.com>
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      0ef4ca04
    • Shuqi Zhang's avatar
      f2fs: fix wrong dirty page count when race between mmap and fallocate. · 9b7eadd9
      Shuqi Zhang authored
      This is a BUG_ON issue as follows when running xfstest-generic-503:
      WARNING: CPU: 21 PID: 1385 at fs/f2fs/inode.c:762 f2fs_evict_inode+0x847/0xaa0
      Modules linked in:
      CPU: 21 PID: 1385 Comm: umount Not tainted 5.19.0-rc5+ #73
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-4.fc34 04/01/2014
      
      Call Trace:
      evict+0x129/0x2d0
      dispose_list+0x4f/0xb0
      evict_inodes+0x204/0x230
      generic_shutdown_super+0x5b/0x1e0
      kill_block_super+0x29/0x80
      kill_f2fs_super+0xe6/0x140
      deactivate_locked_super+0x44/0xc0
      deactivate_super+0x79/0x90
      cleanup_mnt+0x114/0x1a0
      __cleanup_mnt+0x16/0x20
      task_work_run+0x98/0x100
      exit_to_user_mode_prepare+0x3d0/0x3e0
      syscall_exit_to_user_mode+0x12/0x30
      do_syscall_64+0x42/0x80
      entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      Function flow analysis when BUG occurs:
      f2fs_fallocate                    mmap
                                        do_page_fault
                                          pte_spinlock  // ---lock_pte
                                          do_wp_page
                                            wp_page_shared
                                              pte_unmap_unlock   // unlock_pte
                                                do_page_mkwrite
                                                f2fs_vm_page_mkwrite
                                                  down_read(invalidate_lock)
                                                  lock_page
                                                  if (PageMappedToDisk(page))
                                                    goto out;
                                                  // set_page_dirty  --NOT RUN
                                                  out: up_read(invalidate_lock);
                                              finish_mkwrite_fault // unlock_pte
      f2fs_collapse_range
        down_write(i_mmap_sem)
        truncate_pagecache
          unmap_mapping_pages
            i_mmap_lock_write // down_write(i_mmap_rwsem)
              ......
              zap_pte_range
                pte_offset_map_lock // ---lock_pte
                 set_page_dirty
                  f2fs_dirty_data_folio
                    if (!folio_test_dirty(folio)) {
                                              fault_dirty_shared_page
                                                set_page_dirty
                                                  f2fs_dirty_data_folio
                                                    if (!folio_test_dirty(folio)) {
                                                      filemap_dirty_folio
                                                      f2fs_update_dirty_folio // ++
                                                    }
                                                  unlock_page
                      filemap_dirty_folio
                      f2fs_update_dirty_folio // page count++
                    }
                pte_unmap_unlock  // --unlock_pte
            i_mmap_unlock_write  // up_write(i_mmap_rwsem)
        truncate_inode_pages
        up_write(i_mmap_sem)
      
      When race happens between mmap-do_page_fault-wp_page_shared and
      fallocate-truncate_pagecache-zap_pte_range, the zap_pte_range calls
      function set_page_dirty without page lock. Besides, though
      truncate_pagecache has immap and pte lock, wp_page_shared calls
      fault_dirty_shared_page without any. In this case, two threads race
      in f2fs_dirty_data_folio function. Page is set to dirty only ONCE,
      but the count is added TWICE by calling filemap_dirty_folio.
      Thus the count of dirty page cannot accord with the real dirty pages.
      
      Following is the solution to in case of race happens without any lock.
      Since folio_test_set_dirty in filemap_dirty_folio is atomic, judge return
      value will not be at risk of race.
      Signed-off-by: default avatarShuqi Zhang <zhangshuqi3@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      9b7eadd9
  10. 13 Sep, 2022 1 commit
  11. 30 Aug, 2022 1 commit
  12. 02 Aug, 2022 1 commit
  13. 12 May, 2022 1 commit
  14. 10 May, 2022 1 commit
  15. 06 May, 2022 2 commits
    • Jaegeuk Kim's avatar
      f2fs: avoid infinite loop to flush node pages · a7b8618a
      Jaegeuk Kim authored
      xfstests/generic/475 can give EIO all the time which give an infinite loop
      to flush node page like below. Let's avoid it.
      
      [16418.518551] Call Trace:
      [16418.518553]  ? dm_submit_bio+0x48/0x400
      [16418.518574]  ? submit_bio_checks+0x1ac/0x5a0
      [16418.525207]  __submit_bio+0x1a9/0x230
      [16418.525210]  ? kmem_cache_alloc+0x29e/0x3c0
      [16418.525223]  submit_bio_noacct+0xa8/0x2b0
      [16418.525226]  submit_bio+0x4d/0x130
      [16418.525238]  __submit_bio+0x49/0x310 [f2fs]
      [16418.525339]  ? bio_add_page+0x6a/0x90
      [16418.525344]  f2fs_submit_page_bio+0x134/0x1f0 [f2fs]
      [16418.525365]  read_node_page+0x125/0x1b0 [f2fs]
      [16418.525388]  __get_node_page.part.0+0x58/0x3f0 [f2fs]
      [16418.525409]  __get_node_page+0x2f/0x60 [f2fs]
      [16418.525431]  f2fs_get_dnode_of_data+0x423/0x860 [f2fs]
      [16418.525452]  ? asm_sysvec_apic_timer_interrupt+0x12/0x20
      [16418.525458]  ? __mod_memcg_state.part.0+0x2a/0x30
      [16418.525465]  ? __mod_memcg_lruvec_state+0x27/0x40
      [16418.525467]  ? __xa_set_mark+0x57/0x70
      [16418.525472]  f2fs_do_write_data_page+0x10e/0x7b0 [f2fs]
      [16418.525493]  f2fs_write_single_data_page+0x555/0x830 [f2fs]
      [16418.525514]  ? sysvec_apic_timer_interrupt+0x4e/0x90
      [16418.525518]  ? asm_sysvec_apic_timer_interrupt+0x12/0x20
      [16418.525523]  f2fs_write_cache_pages+0x303/0x880 [f2fs]
      [16418.525545]  ? blk_flush_plug_list+0x47/0x100
      [16418.525548]  f2fs_write_data_pages+0xfd/0x320 [f2fs]
      [16418.525569]  do_writepages+0xd5/0x210
      [16418.525648]  filemap_fdatawrite_wbc+0x7d/0xc0
      [16418.525655]  filemap_fdatawrite+0x50/0x70
      [16418.525658]  f2fs_sync_dirty_inodes+0xa4/0x230 [f2fs]
      [16418.525679]  f2fs_write_checkpoint+0x16d/0x1720 [f2fs]
      [16418.525699]  ? ttwu_do_wakeup+0x1c/0x160
      [16418.525709]  ? ttwu_do_activate+0x6d/0xd0
      [16418.525711]  ? __wait_for_common+0x11d/0x150
      [16418.525715]  kill_f2fs_super+0xca/0x100 [f2fs]
      [16418.525733]  deactivate_locked_super+0x3b/0xb0
      [16418.525739]  deactivate_super+0x40/0x50
      [16418.525741]  cleanup_mnt+0x139/0x190
      [16418.525747]  __cleanup_mnt+0x12/0x20
      [16418.525749]  task_work_run+0x6d/0xa0
      [16418.525765]  exit_to_user_mode_prepare+0x1ad/0x1b0
      [16418.525771]  syscall_exit_to_user_mode+0x27/0x50
      [16418.525774]  do_syscall_64+0x48/0xc0
      [16418.525776]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      a7b8618a
    • Dongliang Mu's avatar
      f2fs: remove WARN_ON in f2fs_is_valid_blkaddr · dc2f78e2
      Dongliang Mu authored
      Syzbot triggers two WARNs in f2fs_is_valid_blkaddr and
      __is_bitmap_valid. For example, in f2fs_is_valid_blkaddr,
      if type is DATA_GENERIC_ENHANCE or DATA_GENERIC_ENHANCE_READ,
      it invokes WARN_ON if blkaddr is not in the right range.
      The call trace is as follows:
      
       f2fs_get_node_info+0x45f/0x1070
       read_node_page+0x577/0x1190
       __get_node_page.part.0+0x9e/0x10e0
       __get_node_page
       f2fs_get_node_page+0x109/0x180
       do_read_inode
       f2fs_iget+0x2a5/0x58b0
       f2fs_fill_super+0x3b39/0x7ca0
      
      Fix these two WARNs by replacing WARN_ON with dump_stack.
      
      Reported-by: syzbot+763ae12a2ede1d99d4dc@syzkaller.appspotmail.com
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Reviewed-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      dc2f78e2
  16. 20 Apr, 2022 1 commit
  17. 01 Apr, 2022 1 commit
  18. 21 Mar, 2022 1 commit
    • Chao Yu's avatar
      f2fs: fix to do sanity check on .cp_pack_total_block_count · 5b5b4f85
      Chao Yu authored
      As bughunter reported in bugzilla:
      
      https://bugzilla.kernel.org/show_bug.cgi?id=215709
      
      f2fs may hang when mounting a fuzzed image, the dmesg shows as below:
      
      __filemap_get_folio+0x3a9/0x590
      pagecache_get_page+0x18/0x60
      __get_meta_page+0x95/0x460 [f2fs]
      get_checkpoint_version+0x2a/0x1e0 [f2fs]
      validate_checkpoint+0x8e/0x2a0 [f2fs]
      f2fs_get_valid_checkpoint+0xd0/0x620 [f2fs]
      f2fs_fill_super+0xc01/0x1d40 [f2fs]
      mount_bdev+0x18a/0x1c0
      f2fs_mount+0x15/0x20 [f2fs]
      legacy_get_tree+0x28/0x50
      vfs_get_tree+0x27/0xc0
      path_mount+0x480/0xaa0
      do_mount+0x7c/0xa0
      __x64_sys_mount+0x8b/0xe0
      do_syscall_64+0x38/0xc0
      entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      The root cause is cp_pack_total_block_count field in checkpoint was fuzzed
      to one, as calcuated, two cp pack block locates in the same block address,
      so then read latter cp pack block, it will block on the page lock due to
      the lock has already held when reading previous cp pack block, fix it by
      adding sanity check for cp_pack_total_block_count.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarChao Yu <chao.yu@oppo.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      5b5b4f85
  19. 15 Mar, 2022 3 commits
  20. 04 Mar, 2022 1 commit
    • Jaegeuk Kim's avatar
      f2fs: avoid an infinite loop in f2fs_sync_dirty_inodes · 50c63009
      Jaegeuk Kim authored
      If one read IO is always failing, we can fall into an infinite loop in
      f2fs_sync_dirty_inodes. This happens during xfstests/generic/475.
      
      [  142.803335] Buffer I/O error on dev dm-1, logical block 8388592, async page read
      ...
      [  382.887210]  submit_bio_noacct+0xdd/0x2a0
      [  382.887213]  submit_bio+0x80/0x110
      [  382.887223]  __submit_bio+0x4d/0x300 [f2fs]
      [  382.887282]  f2fs_submit_page_bio+0x125/0x200 [f2fs]
      [  382.887299]  __get_meta_page+0xc9/0x280 [f2fs]
      [  382.887315]  f2fs_get_meta_page+0x13/0x20 [f2fs]
      [  382.887331]  f2fs_get_node_info+0x317/0x3c0 [f2fs]
      [  382.887350]  f2fs_do_write_data_page+0x327/0x6f0 [f2fs]
      [  382.887367]  f2fs_write_single_data_page+0x5b7/0x960 [f2fs]
      [  382.887386]  f2fs_write_cache_pages+0x302/0x890 [f2fs]
      [  382.887405]  ? preempt_count_add+0x7a/0xc0
      [  382.887408]  f2fs_write_data_pages+0xfd/0x320 [f2fs]
      [  382.887425]  ? _raw_spin_unlock+0x1a/0x30
      [  382.887428]  do_writepages+0xd3/0x1d0
      [  382.887432]  filemap_fdatawrite_wbc+0x69/0x90
      [  382.887434]  filemap_fdatawrite+0x50/0x70
      [  382.887437]  f2fs_sync_dirty_inodes+0xa4/0x270 [f2fs]
      [  382.887453]  f2fs_write_checkpoint+0x189/0x1640 [f2fs]
      [  382.887469]  ? schedule_timeout+0x114/0x150
      [  382.887471]  ? ttwu_do_activate+0x6d/0xb0
      [  382.887473]  ? preempt_count_add+0x7a/0xc0
      [  382.887476]  kill_f2fs_super+0xca/0x100 [f2fs]
      [  382.887491]  deactivate_locked_super+0x35/0xa0
      [  382.887494]  deactivate_super+0x40/0x50
      [  382.887497]  cleanup_mnt+0x139/0x190
      [  382.887499]  __cleanup_mnt+0x12/0x20
      [  382.887501]  task_work_run+0x64/0xa0
      [  382.887505]  exit_to_user_mode_prepare+0x1b7/0x1c0
      [  382.887508]  syscall_exit_to_user_mode+0x27/0x50
      [  382.887510]  do_syscall_64+0x48/0xc0
      [  382.887513]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      Reviewed-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      50c63009
  21. 12 Feb, 2022 1 commit
  22. 04 Feb, 2022 1 commit
  23. 25 Jan, 2022 1 commit
    • Tim Murray's avatar
      f2fs: move f2fs to use reader-unfair rwsems · e4544b63
      Tim Murray authored
      f2fs rw_semaphores work better if writers can starve readers,
      especially for the checkpoint thread, because writers are strictly
      more important than reader threads. This prevents significant priority
      inversion between low-priority readers that blocked while trying to
      acquire the read lock and a second acquisition of the write lock that
      might be blocking high priority work.
      Signed-off-by: default avatarTim Murray <timmurray@google.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e4544b63
  24. 04 Jan, 2022 2 commits
  25. 29 Oct, 2021 1 commit
  26. 16 Sep, 2021 2 commits
  27. 23 Aug, 2021 1 commit