Merge tag 'f2fs-for-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Feb 2023 00:18:51 +0000 (16:18 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Feb 2023 00:18:51 +0000 (16:18 -0800)
Pull f2fs updates from Jaegeuk Kim:
 "In this round, we've got a huge number of patches that improve code
  readability along with minor bug fixes, while we've mainly fixed some
  critical issues in recently-added per-block age-based extent_cache,
  atomic write support, and some folio cases.

  Enhancements:

   - add sysfs nodes to set last_age_weight and manage
     discard_io_aware_gran

   - show ipu policy in debugfs

   - reduce stack memory cost by using bitfield in struct f2fs_io_info

   - introduce trace_f2fs_replace_atomic_write_block

   - enhance iostat support and adds flush commands

  Bug fixes:

   - revert "f2fs: truncate blocks in batch in __complete_revoke_list()"

   - fix kernel crash on the atomic write abort flow

   - call clear_page_private_reference in .{release,invalid}_folio

   - support .migrate_folio for compressed inode

   - fix cgroup writeback accounting with fs-layer encryption

   - retry to update the inode page given data corruption

   - fix kernel crash due to NULL io->bio

   - fix some bugs in per-block age-based extent_cache:
       - wrong calculation of block age
       - update age extent in f2fs_do_zero_range()
       - update age extent correctly during truncation"

* tag 'f2fs-for-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (81 commits)
  f2fs: drop unnecessary arg for f2fs_ioc_*()
  f2fs: Revert "f2fs: truncate blocks in batch in __complete_revoke_list()"
  f2fs: synchronize atomic write aborts
  f2fs: fix wrong segment count
  f2fs: replace si->sbi w/ sbi in stat_show()
  f2fs: export ipu policy in debugfs
  f2fs: make kobj_type structures constant
  f2fs: fix to do sanity check on extent cache correctly
  f2fs: add missing description for ipu_policy node
  f2fs: fix to set ipu policy
  f2fs: fix typos in comments
  f2fs: fix kernel crash due to null io->bio
  f2fs: use iostat_lat_type directly as a parameter in the iostat_update_and_unbind_ctx()
  f2fs: add sysfs nodes to set last_age_weight
  f2fs: fix f2fs_show_options to show nogc_merge mount option
  f2fs: fix cgroup writeback accounting with fs-layer encryption
  f2fs: fix wrong calculation of block age
  f2fs: fix to update age extent in f2fs_do_zero_range()
  f2fs: fix to update age extent correctly during truncation
  f2fs: fix to avoid potential memory corruption in __update_iostat_latency()
  ...

1  2 
MAINTAINERS
fs/f2fs/checkpoint.c
fs/f2fs/data.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/namei.c
fs/f2fs/node.c
fs/f2fs/super.c
fs/f2fs/verity.c

diff --cc MAINTAINERS
Simple merge
Simple merge
diff --cc fs/f2fs/data.c
Simple merge
diff --cc fs/f2fs/f2fs.h
Simple merge
diff --cc fs/f2fs/file.c
index b906176397436a1fefe4cbaeee6326847039f644,ca1720fc1187e7d97784f4da062ed4b198321302..15dabeac4690500f8f6e6d05d64b5cba18729781
@@@ -2087,19 -2092,28 +2092,28 @@@ static int f2fs_ioc_start_atomic_write(
                goto out;
        }
  
-       /* Create a COW inode for atomic write */
-       pinode = f2fs_iget(inode->i_sb, fi->i_pino);
-       if (IS_ERR(pinode)) {
-               f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
-               ret = PTR_ERR(pinode);
-               goto out;
-       }
+       /* Check if the inode already has a COW inode */
+       if (fi->cow_inode == NULL) {
+               /* Create a COW inode for atomic write */
+               pinode = f2fs_iget(inode->i_sb, fi->i_pino);
+               if (IS_ERR(pinode)) {
+                       f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
+                       ret = PTR_ERR(pinode);
+                       goto out;
+               }
  
-       ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode);
-       iput(pinode);
-       if (ret) {
-               f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
-               goto out;
 -              ret = f2fs_get_tmpfile(mnt_userns, pinode, &fi->cow_inode);
++              ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode);
+               iput(pinode);
+               if (ret) {
+                       f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
+                       goto out;
+               }
+               set_inode_flag(fi->cow_inode, FI_COW_FILE);
+               clear_inode_flag(fi->cow_inode, FI_INLINE_DATA);
+       } else {
+               /* Reuse the already created COW inode */
+               f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
        }
  
        f2fs_write_inode(inode, NULL);
diff --cc fs/f2fs/namei.c
index d8e01bbbf27fb4a6a63b89897570872d5786c6de,f9aafb7ac44df17b8af148da0c05c0bbe9ae8b55..11fc4c8036a9df064562e9d68065912a381a6c87
@@@ -923,13 -923,10 +923,10 @@@ static int f2fs_tmpfile(struct mnt_idma
        return finish_open_simple(file, err);
  }
  
 -static int f2fs_create_whiteout(struct user_namespace *mnt_userns,
 +static int f2fs_create_whiteout(struct mnt_idmap *idmap,
                                struct inode *dir, struct inode **whiteout)
  {
-       if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
-               return -EIO;
 -      return __f2fs_tmpfile(mnt_userns, dir, NULL,
 +      return __f2fs_tmpfile(idmap, dir, NULL,
                                S_IFCHR | WHITEOUT_MODE, true, whiteout);
  }
  
diff --cc fs/f2fs/node.c
Simple merge
diff --cc fs/f2fs/super.c
Simple merge
Simple merge