1. 04 Mar, 2024 12 commits
  2. 29 Feb, 2024 8 commits
  3. 27 Feb, 2024 10 commits
  4. 20 Feb, 2024 1 commit
  5. 06 Feb, 2024 9 commits
    • Chao Yu's avatar
      f2fs: fix to avoid potential panic during recovery · 21ec6823
      Chao Yu authored
      During recovery, if FAULT_BLOCK is on, it is possible that
      f2fs_reserve_new_block() will return -ENOSPC during recovery,
      then it may trigger panic.
      
      Also, if fault injection rate is 1 and only FAULT_BLOCK fault
      type is on, it may encounter deadloop in loop of block reservation.
      
      Let's change as below to fix these issues:
      - remove bug_on() to avoid panic.
      - limit the loop count of block reservation to avoid potential
      deadloop.
      
      Fixes: 956fa1dd ("f2fs: fix to check return value of f2fs_reserve_new_block()")
      Reported-by: default avatarZhiguo Niu <zhiguo.niu@unisoc.com>
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      21ec6823
    • Zhiguo Niu's avatar
      f2fs: use IS_INODE replace IS_DNODE in f2fs_flush_inline_data · 8e9c1a34
      Zhiguo Niu authored
      Now IS_DNODE is used in f2fs_flush_inline_data and it has some problems:
      1. Just only inodes may include inline data,not all direct nodes
      2. When system IO is busy, it is inefficient to lock a direct node page
      but not an inode page. Besides, if this direct node page is being
      locked by others for IO, f2fs_flush_inline_data will be blocked here,
      which will affects the checkpoint process, this is unreasonable.
      
      So IS_INODE should be used in f2fs_flush_inline_data.
      Signed-off-by: default avatarZhiguo Niu <zhiguo.niu@unisoc.com>
      Reviewed-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      8e9c1a34
    • Zhiguo Niu's avatar
      f2fs: compress: remove some redundant codes in f2fs_cache_compressed_page · f289e95f
      Zhiguo Niu authored
      Just remove some redundant codes, no logic change.
      Signed-off-by: default avatarZhiguo Niu <zhiguo.niu@unisoc.com>
      Reviewed-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      f289e95f
    • Chao Yu's avatar
      f2fs: compress: fix to cover f2fs_disable_compressed_file() w/ i_sem · 2f9420d3
      Chao Yu authored
      - f2fs_disable_compressed_file
        - check inode_has_data
      					- f2fs_file_mmap
      					- mkwrite
      					 - f2fs_get_block_locked
      					 : update metadata in compressed
      					   inode's disk layout
        - fi->i_flags &= ~F2FS_COMPR_FL
        - clear_inode_flag(inode, FI_COMPRESSED_FILE);
      
      we should use i_sem lock to prevent above race case.
      
      Fixes: 4c8ff709 ("f2fs: support data compression")
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2f9420d3
    • Chao Yu's avatar
      f2fs: use f2fs_err_ratelimited() to avoid redundant logs · 0b8eb814
      Chao Yu authored
      Use f2fs_err_ratelimited() to instead f2fs_err() in
      f2fs_record_stop_reason() and f2fs_record_errors() to
      avoid redundant logs.
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      0b8eb814
    • Chao Yu's avatar
      f2fs: support printk_ratelimited() in f2fs_printk() · b1c9d3f8
      Chao Yu authored
      This patch supports using printk_ratelimited() in f2fs_printk(), and
      wrap ratelimited f2fs_printk() into f2fs_{err,warn,info}_ratelimited(),
      then, use these new helps to clean up codes.
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      b1c9d3f8
    • Wenjie Qi's avatar
      f2fs: fix NULL pointer dereference in f2fs_submit_page_write() · c2034ef6
      Wenjie Qi authored
      BUG: kernel NULL pointer dereference, address: 0000000000000014
      RIP: 0010:f2fs_submit_page_write+0x6cf/0x780 [f2fs]
      Call Trace:
      <TASK>
      ? show_regs+0x6e/0x80
      ? __die+0x29/0x70
      ? page_fault_oops+0x154/0x4a0
      ? prb_read_valid+0x20/0x30
      ? __irq_work_queue_local+0x39/0xd0
      ? irq_work_queue+0x36/0x70
      ? do_user_addr_fault+0x314/0x6c0
      ? exc_page_fault+0x7d/0x190
      ? asm_exc_page_fault+0x2b/0x30
      ? f2fs_submit_page_write+0x6cf/0x780 [f2fs]
      ? f2fs_submit_page_write+0x736/0x780 [f2fs]
      do_write_page+0x50/0x170 [f2fs]
      f2fs_outplace_write_data+0x61/0xb0 [f2fs]
      f2fs_do_write_data_page+0x3f8/0x660 [f2fs]
      f2fs_write_single_data_page+0x5bb/0x7a0 [f2fs]
      f2fs_write_cache_pages+0x3da/0xbe0 [f2fs]
      ...
      It is possible that other threads have added this fio to io->bio
      and submitted the io->bio before entering f2fs_submit_page_write().
      At this point io->bio = NULL.
      If is_end_zone_blkaddr(sbi, fio->new_blkaddr) of this fio is true,
      then an NULL pointer dereference error occurs at bio_get(io->bio).
      The original code for determining zone end was after "out:",
      which would have missed some fio who is zone end. I've moved
       this code before "skip:" to make sure it's done for each fio.
      
      Fixes: e067dc3c ("f2fs: maintain six open zones for zoned devices")
      Signed-off-by: default avatarWenjie Qi <qwjhust@gmail.com>
      Reviewed-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      c2034ef6
    • Chao Yu's avatar
      f2fs: zone: fix to wait completion of last bio in zone correctly · 536af821
      Chao Yu authored
      It needs to check last zone_pending_bio and wait IO completion before
      traverse next fio in io->io_list, otherwise, bio in next zone may be
      submitted before all IO completion in current zone.
      
      Fixes: e067dc3c ("f2fs: maintain six open zones for zoned devices")
      Cc: Daeho Jeong <daehojeong@google.com>
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Reviewed-by: default avatarDaeho Jeong <daehojeong@google.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      536af821
    • Chao Yu's avatar
      f2fs: introduce FAULT_BLKADDR_CONSISTENCE · c7115e09
      Chao Yu authored
      We will encounter below inconsistent status when FAULT_BLKADDR type
      fault injection is on.
      
      Info: checkpoint state = d6 :  nat_bits crc fsck compacted_summary orphan_inodes sudden-power-off
      [ASSERT] (fsck_chk_inode_blk:1254)  --> ino: 0x1c100 has i_blocks: 000000c0, but has 191 blocks
      [FIX] (fsck_chk_inode_blk:1260)  --> [0x1c100] i_blocks=0x000000c0 -> 0xbf
      [FIX] (fsck_chk_inode_blk:1269)  --> [0x1c100] i_compr_blocks=0x00000026 -> 0x27
      [ASSERT] (fsck_chk_inode_blk:1254)  --> ino: 0x1cadb has i_blocks: 0000002f, but has 46 blocks
      [FIX] (fsck_chk_inode_blk:1260)  --> [0x1cadb] i_blocks=0x0000002f -> 0x2e
      [FIX] (fsck_chk_inode_blk:1269)  --> [0x1cadb] i_compr_blocks=0x00000011 -> 0x12
      [ASSERT] (fsck_chk_inode_blk:1254)  --> ino: 0x1c62c has i_blocks: 00000002, but has 1 blocks
      [FIX] (fsck_chk_inode_blk:1260)  --> [0x1c62c] i_blocks=0x00000002 -> 0x1
      
      After we inject fault into f2fs_is_valid_blkaddr() during truncation,
      a) it missed to increase @nr_free or @valid_blocks
      b) it can cause in blkaddr leak in truncated dnode
      Which may cause inconsistent status.
      
      This patch separates FAULT_BLKADDR_CONSISTENCE from FAULT_BLKADDR,
      and rename FAULT_BLKADDR to FAULT_BLKADDR_VALIDITY
      so that we can:
      a) use FAULT_BLKADDR_CONSISTENCE in f2fs_truncate_data_blocks_range()
      to simulate inconsistent issue independently, then it can verify fsck
      repair flow.
      b) FAULT_BLKADDR_VALIDITY fault will not cause any inconsistent status,
      we can just use it to check error path handling in kernel side.
      Reviewed-by: default avatarDaeho Jeong <daehojeong@google.com>
      Signed-off-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      c7115e09