Merge tag 'f2fs-for-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeu...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 17 Dec 2020 19:18:00 +0000 (11:18 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 17 Dec 2020 19:18:00 +0000 (11:18 -0800)
Pull f2fs updates from Jaegeuk Kim:
 "In this round, we've made more work into per-file compression support.

  For example, F2FS_IOC_GET | SET_COMPRESS_OPTION provides a way to
  change the algorithm or cluster size per file. F2FS_IOC_COMPRESS |
  DECOMPRESS_FILE provides a way to compress and decompress the existing
  normal files manually.

  There is also a new mount option, compress_mode=fs|user, which can
  control who compresses the data.

  Chao also added a checksum feature with a mount option so that
  we are able to detect any corrupted cluster.

  In addition, Daniel contributed casefolding with encryption patch,
  which will be used for Android devices.

  Summary:

  Enhancements:
   - add ioctls and mount option to manage per-file compression feature
   - support casefolding with encryption
   - support checksum for compressed cluster
   - avoid IO starvation by replacing mutex with rwsem
   - add sysfs, max_io_bytes, to control max bio size

  Bug fixes:
   - fix use-after-free issue when compression and fsverity are enabled
   - fix consistency corruption during fault injection test
   - fix data offset for lseek
   - get rid of buffer_head which has 32bits limit in fiemap
   - fix some bugs in multi-partitions support
   - fix nat entry count calculation in shrinker
   - fix some stat information

  And, we've refactored some logics and fix minor bugs as well"

* tag 'f2fs-for-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (36 commits)
  f2fs: compress: fix compression chksum
  f2fs: fix shift-out-of-bounds in sanity_check_raw_super()
  f2fs: fix race of pending_pages in decompression
  f2fs: fix to account inline xattr correctly during recovery
  f2fs: inline: fix wrong inline inode stat
  f2fs: inline: correct comment in f2fs_recover_inline_data
  f2fs: don't check PAGE_SIZE again in sanity_check_raw_super()
  f2fs: convert to F2FS_*_INO macro
  f2fs: introduce max_io_bytes, a sysfs entry, to limit bio size
  f2fs: don't allow any writes on readonly mount
  f2fs: avoid race condition for shrinker count
  f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE
  f2fs: add compress_mode mount option
  f2fs: Remove unnecessary unlikely()
  f2fs: init dirty_secmap incorrectly
  f2fs: remove buffer_head which has 32bits limit
  f2fs: fix wrong block count instead of bytes
  f2fs: use new conversion functions between blks and bytes
  f2fs: rename logical_to_blk and blk_to_logical
  f2fs: fix kbytes written stat for multi-device case
  ...

18 files changed:
1  2 
MAINTAINERS
fs/crypto/fname.c
fs/crypto/fscrypt_private.h
fs/crypto/hooks.c
fs/ext4/dir.c
fs/ext4/ext4.h
fs/ext4/namei.c
fs/ext4/super.c
fs/f2fs/checkpoint.c
fs/f2fs/dir.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/super.c
fs/f2fs/sysfs.c
fs/libfs.c
fs/ubifs/dir.c
include/linux/fs.h
include/linux/fscrypt.h

diff --cc MAINTAINERS
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc fs/ext4/dir.c
@@@ -655,12 -664,6 +655,5 @@@ const struct file_operations ext4_dir_o
        .compat_ioctl   = ext4_compat_ioctl,
  #endif
        .fsync          = ext4_sync_file,
 -      .open           = ext4_dir_open,
        .release        = ext4_release_dir,
  };
- #ifdef CONFIG_UNICODE
- const struct dentry_operations ext4_dentry_ops = {
-       .d_hash = generic_ci_d_hash,
-       .d_compare = generic_ci_d_compare,
- };
- #endif
diff --cc fs/ext4/ext4.h
Simple merge
diff --cc fs/ext4/namei.c
Simple merge
diff --cc fs/ext4/super.c
Simple merge
@@@ -1385,6 -1385,27 +1385,26 @@@ static void commit_checkpoint(struct f2
        f2fs_submit_merged_write(sbi, META_FLUSH);
  }
  
 -      return bdev->bd_part ?
 -              (u64)part_stat_read(bdev->bd_part, sectors[STAT_WRITE]) : 0;
+ static inline u64 get_sectors_written(struct block_device *bdev)
+ {
++      return (u64)part_stat_read(bdev, sectors[STAT_WRITE]);
+ }
+ u64 f2fs_get_sectors_written(struct f2fs_sb_info *sbi)
+ {
+       if (f2fs_is_multi_device(sbi)) {
+               u64 sectors = 0;
+               int i;
+               for (i = 0; i < sbi->s_ndevs; i++)
+                       sectors += get_sectors_written(FDEV(i).bdev);
+               return sectors;
+       }
+       return get_sectors_written(sbi->sb->s_bdev);
+ }
  static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
  {
        struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
diff --cc fs/f2fs/dir.c
Simple merge
diff --cc fs/f2fs/f2fs.h
Simple merge
diff --cc fs/f2fs/file.c
Simple merge
diff --cc fs/f2fs/super.c
Simple merge
diff --cc fs/f2fs/sysfs.c
@@@ -90,9 -90,15 +90,10 @@@ static ssize_t free_segments_show(struc
  static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a,
                struct f2fs_sb_info *sbi, char *buf)
  {
 -      struct super_block *sb = sbi->sb;
 -
 -      if (!sb->s_bdev->bd_part)
 -              return sprintf(buf, "0\n");
 -
        return sprintf(buf, "%llu\n",
                        (unsigned long long)(sbi->kbytes_written +
-                       BD_PART_WRITTEN(sbi)));
+                       ((f2fs_get_sectors_written(sbi) -
+                               sbi->sectors_written_start) >> 1)));
  }
  
  static ssize_t features_show(struct f2fs_attr *a,
diff --cc fs/libfs.c
Simple merge
diff --cc fs/ubifs/dir.c
Simple merge
Simple merge
@@@ -753,12 -738,14 +753,15 @@@ static inline int fscrypt_prepare_renam
   *
   * Prepare for ->lookup() in a directory which may be encrypted by determining
   * the name that will actually be used to search the directory on-disk.  If the
 - * directory's encryption key is available, then the lookup is assumed to be by
 - * plaintext name; otherwise, it is assumed to be by no-key name.
 + * directory's encryption policy is supported by this kernel and its encryption
 + * key is available, then the lookup is assumed to be by plaintext name;
 + * otherwise, it is assumed to be by no-key name.
   *
-  * This also installs a custom ->d_revalidate() method which will invalidate the
-  * dentry if it was created without the key and the key is later added.
+  * This will set DCACHE_NOKEY_NAME on the dentry if the lookup is by no-key
+  * name.  In this case the filesystem must assign the dentry a dentry_operations
+  * which contains fscrypt_d_revalidate (or contains a d_revalidate method that
+  * calls fscrypt_d_revalidate), so that the dentry will be invalidated if the
+  * directory's encryption key is later added.
   *
   * Return: 0 on success; -ENOENT if the directory's key is unavailable but the
   * filename isn't a valid no-key name, so a negative dentry should be created;