An error occurred fetching the project authors.
  1. 12 May, 2020 6 commits
    • YueHaibing's avatar
      f2fs: Fix wrong stub helper update_sit_info · 48abe91a
      YueHaibing authored
      update_sit_info should be f2fs_update_sit_info,
      otherwise build fails while no CONFIG_F2FS_STAT_FS.
      
      Fixes: fc7100ea ("f2fs: Add f2fs stats to sysfs")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      48abe91a
    • Chao Yu's avatar
      f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS · ef8d563f
      Chao Yu authored
      There are still reserved blocks on compressed inode, this patch
      introduce a new ioctl to help release reserved blocks back to
      filesystem, so that userspace can reuse those freed space.
      
      ----
      Daeho fixed a bug like below.
      
      Now, if writing pages and releasing compress blocks occur
      simultaneously, and releasing cblocks is executed more than one time
      to a file, then total block count of filesystem and block count of the
      file could be incorrect and damaged.
      
      We have to execute releasing compress blocks only one time for a file
      without being interfered by writepages path.
      ---
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarDaeho Jeong <daehojeong@google.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      ef8d563f
    • Eric Biggers's avatar
      f2fs: rework filename handling · 43c780ba
      Eric Biggers authored
      Rework f2fs's handling of filenames to use a new 'struct f2fs_filename'.
      Similar to 'struct ext4_filename', this stores the usr_fname, disk_name,
      dirhash, crypto_buf, and casefolded name.  Some of these names can be
      NULL in some cases.  'struct f2fs_filename' differs from
      'struct fscrypt_name' mainly in that the casefolded name is included.
      
      For user-initiated directory operations like lookup() and create(),
      initialize the f2fs_filename by translating the corresponding
      fscrypt_name, then computing the dirhash and casefolded name if needed.
      
      This makes the dirhash and casefolded name be cached for each syscall,
      so we don't have to recompute them repeatedly.  (Previously, f2fs
      computed the dirhash once per directory level, and the casefolded name
      once per directory block.)  This improves performance.
      
      This rework also makes it much easier to correctly handle all
      combinations of normal, encrypted, casefolded, and encrypted+casefolded
      directories.  (The fourth isn't supported yet but is being worked on.)
      
      The only other cases where an f2fs_filename gets initialized are for two
      filesystem-internal operations: (1) when converting an inline directory
      to a regular one, we grab the needed disk_name and hash from an existing
      f2fs_dir_entry; and (2) when roll-forward recovering a new dentry, we
      grab the needed disk_name from f2fs_inode::i_name and compute the hash.
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      43c780ba
    • Eric Biggers's avatar
      f2fs: split f2fs_d_compare() from f2fs_match_name() · f874fa1c
      Eric Biggers authored
      Sharing f2fs_ci_compare() between comparing cached dentries
      (f2fs_d_compare()) and comparing on-disk dentries (f2fs_match_name())
      doesn't work as well as intended, as these actions fundamentally differ
      in several ways (e.g. whether the task may sleep, whether the directory
      is stable, whether the casefolded name was precomputed, whether the
      dentry will need to be decrypted once we allow casefold+encrypt, etc.)
      
      Just make f2fs_d_compare() implement what it needs directly, and rework
      f2fs_ci_compare() to be specialized for f2fs_match_name().
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      f874fa1c
    • Chao Yu's avatar
      f2fs: compress: support lzo-rle compress algorithm · 6d92b201
      Chao Yu authored
      LZO-RLE extension (run length encoding) was introduced to improve
      performance of LZO algorithm in scenario of data contains many zeros,
      zram has changed to use this extended algorithm by default, this
      patch adds to support this algorithm extension, to enable this
      extension, it needs to enable F2FS_FS_LZO and F2FS_FS_LZORLE config,
      and specifies "compress_algorithm=lzo-rle" mountoption.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      6d92b201
    • Chao Yu's avatar
      f2fs: introduce mempool for {,de}compress intermediate page allocation · 5e6bbde9
      Chao Yu authored
      If compression feature is on, in scenario of no enough free memory,
      page refault ratio is higher than before, the root cause is:
      - {,de}compression flow needs to allocate intermediate pages to store
      compressed data in cluster, so during their allocation, vm may reclaim
      mmaped pages.
      - if above reclaimed pages belong to compressed cluster, during its
      refault, it may cause more intermediate pages allocation, result in
      reclaiming more mmaped pages.
      
      So this patch introduces a mempool for intermediate page allocation,
      in order to avoid high refault ratio, by default, number of
      preallocated page in pool is 512, user can change the number by
      assigning 'num_compress_pages' parameter during module initialization.
      
      Ma Feng found warnings in the original patch and fixed like below.
      
      Fix the following sparse warning:
      fs/f2fs/compress.c:501:5: warning: symbol 'num_compress_pages' was not declared.
       Should it be static?
      fs/f2fs/compress.c:530:6: warning: symbol 'f2fs_compress_free_page' was not
      declared. Should it be static?
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarMa Feng <mafeng.ma@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      5e6bbde9
  2. 08 May, 2020 3 commits
  3. 17 Apr, 2020 2 commits
  4. 16 Apr, 2020 1 commit
  5. 03 Apr, 2020 3 commits
  6. 31 Mar, 2020 4 commits
    • Chao Yu's avatar
      f2fs: fix potential .flags overflow on 32bit architecture · 7653b9d8
      Chao Yu authored
      f2fs_inode_info.flags is unsigned long variable, it has 32 bits
      in 32bit architecture, since we introduced FI_MMAP_FILE flag
      when we support data compression, we may access memory cross
      the border of .flags field, corrupting .i_sem field, result in
      below deadlock.
      
      To fix this issue, let's expand .flags as an array to grab enough
      space to store new flags.
      
      Call Trace:
       __schedule+0x8d0/0x13fc
       ? mark_held_locks+0xac/0x100
       schedule+0xcc/0x260
       rwsem_down_write_slowpath+0x3ab/0x65d
       down_write+0xc7/0xe0
       f2fs_drop_nlink+0x3d/0x600 [f2fs]
       f2fs_delete_inline_entry+0x300/0x440 [f2fs]
       f2fs_delete_entry+0x3a1/0x7f0 [f2fs]
       f2fs_unlink+0x500/0x790 [f2fs]
       vfs_unlink+0x211/0x490
       do_unlinkat+0x483/0x520
       sys_unlink+0x4a/0x70
       do_fast_syscall_32+0x12b/0x683
       entry_SYSENTER_32+0xaa/0x102
      
      Fixes: 4c8ff709 ("f2fs: support data compression")
      Tested-by: default avatarOndrej Jirman <megous@megous.com>
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7653b9d8
    • Chao Yu's avatar
      f2fs: don't trigger data flush in foreground operation · 7bcd0cfa
      Chao Yu authored
      Data flush can generate heavy IO and cause long latency during
      flush, so it's not appropriate to trigger it in foreground
      operation.
      
      And also, we may face below potential deadlock during data flush:
      - f2fs_write_multi_pages
       - f2fs_write_raw_pages
        - f2fs_write_single_data_page
         - f2fs_balance_fs
          - f2fs_balance_fs_bg
           - f2fs_sync_dirty_inodes
            - filemap_fdatawrite   -- stuck on flush same cluster
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7bcd0cfa
    • Chao Yu's avatar
      f2fs: clean up f2fs_may_encrypt() · 8c7d4b57
      Chao Yu authored
      Merge below two conditions into f2fs_may_encrypt() for cleanup
      - IS_ENCRYPTED()
      - DUMMY_ENCRYPTION_ENABLED()
      
      Check IS_ENCRYPTED(inode) condition in f2fs_init_inode_metadata()
      is enough since we have already set encrypt flag in f2fs_new_inode().
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      8c7d4b57
    • Chao Yu's avatar
      f2fs: don't mark compressed inode dirty during f2fs_iget() · 530e0704
      Chao Yu authored
      - f2fs_iget
       - do_read_inode
        - set_inode_flag(, FI_COMPRESSED_FILE)
         - __mark_inode_dirty_flag(, true)
      
      It's unnecessary, so let's just mark compressed inode dirty while
      compressed inode conversion.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      530e0704
  7. 25 Mar, 2020 1 commit
  8. 23 Mar, 2020 1 commit
  9. 19 Mar, 2020 8 commits
  10. 11 Mar, 2020 2 commits
  11. 10 Mar, 2020 2 commits
    • Chao Yu's avatar
      f2fs: fix inconsistent comments · 7a88ddb5
      Chao Yu authored
      Lack of maintenance on comments may mislead developers, fix them.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7a88ddb5
    • Chao Yu's avatar
      f2fs: cover last_disk_size update with spinlock · c10c9820
      Chao Yu authored
      This change solves below hangtask issue:
      
      INFO: task kworker/u16:1:58 blocked for more than 122 seconds.
            Not tainted 5.6.0-rc2-00590-g9983bdae4974e #11
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      kworker/u16:1   D    0    58      2 0x00000000
      Workqueue: writeback wb_workfn (flush-179:0)
      Backtrace:
       (__schedule) from [<c0913234>] (schedule+0x78/0xf4)
       (schedule) from [<c017ec74>] (rwsem_down_write_slowpath+0x24c/0x4c0)
       (rwsem_down_write_slowpath) from [<c0915f2c>] (down_write+0x6c/0x70)
       (down_write) from [<c0435b80>] (f2fs_write_single_data_page+0x608/0x7ac)
       (f2fs_write_single_data_page) from [<c0435fd8>] (f2fs_write_cache_pages+0x2b4/0x7c4)
       (f2fs_write_cache_pages) from [<c043682c>] (f2fs_write_data_pages+0x344/0x35c)
       (f2fs_write_data_pages) from [<c0267ee8>] (do_writepages+0x3c/0xd4)
       (do_writepages) from [<c0310cbc>] (__writeback_single_inode+0x44/0x454)
       (__writeback_single_inode) from [<c03112d0>] (writeback_sb_inodes+0x204/0x4b0)
       (writeback_sb_inodes) from [<c03115cc>] (__writeback_inodes_wb+0x50/0xe4)
       (__writeback_inodes_wb) from [<c03118f4>] (wb_writeback+0x294/0x338)
       (wb_writeback) from [<c0312dac>] (wb_workfn+0x35c/0x54c)
       (wb_workfn) from [<c014f2b8>] (process_one_work+0x214/0x544)
       (process_one_work) from [<c014f634>] (worker_thread+0x4c/0x574)
       (worker_thread) from [<c01564fc>] (kthread+0x144/0x170)
       (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
      Reported-and-tested-by: default avatarOndřej Jirman <megi@xff.cz>
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      c10c9820
  12. 27 Feb, 2020 3 commits
  13. 23 Jan, 2020 1 commit
    • Hridya Valsaraju's avatar
      f2fs: Add f2fs stats to sysfs · fc7100ea
      Hridya Valsaraju authored
      Currently f2fs stats are only available from /d/f2fs/status. This patch
      adds some of the f2fs stats to sysfs so that they are accessible even
      when debugfs is not mounted.
      
      The following sysfs nodes are added:
      -/sys/fs/f2fs/<disk>/free_segments
      -/sys/fs/f2fs/<disk>/cp_foreground_calls
      -/sys/fs/f2fs/<disk>/cp_background_calls
      -/sys/fs/f2fs/<disk>/gc_foreground_calls
      -/sys/fs/f2fs/<disk>/gc_background_calls
      -/sys/fs/f2fs/<disk>/moved_blocks_foreground
      -/sys/fs/f2fs/<disk>/moved_blocks_background
      -/sys/fs/f2fs/<disk>/avg_vblocks
      Signed-off-by: default avatarHridya Valsaraju <hridya@google.com>
      [Jaegeuk Kim: allow STAT_FS without DEBUG_FS]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      fc7100ea
  14. 18 Jan, 2020 3 commits
    • Chao Yu's avatar
      f2fs: change to use rwsem for gc_mutex · fb24fea7
      Chao Yu authored
      Mutex lock won't serialize callers, in order to avoid starving of unlucky
      caller, let's use rwsem lock instead.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      fb24fea7
    • Jaegeuk Kim's avatar
      f2fs: convert inline_dir early before starting rename · b06af2af
      Jaegeuk Kim authored
      If we hit an error during rename, we'll get two dentries in different
      directories.
      
      Chao adds to check the room in inline_dir which can avoid needless
      inversion. This should be done by inode_lock(&old_dir).
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      b06af2af
    • Chao Yu's avatar
      f2fs: support data compression · 4c8ff709
      Chao Yu authored
      This patch tries to support compression in f2fs.
      
      - New term named cluster is defined as basic unit of compression, file can
      be divided into multiple clusters logically. One cluster includes 4 << n
      (n >= 0) logical pages, compression size is also cluster size, each of
      cluster can be compressed or not.
      
      - In cluster metadata layout, one special flag is used to indicate cluster
      is compressed one or normal one, for compressed cluster, following metadata
      maps cluster to [1, 4 << n - 1] physical blocks, in where f2fs stores
      data including compress header and compressed data.
      
      - In order to eliminate write amplification during overwrite, F2FS only
      support compression on write-once file, data can be compressed only when
      all logical blocks in file are valid and cluster compress ratio is lower
      than specified threshold.
      
      - To enable compression on regular inode, there are three ways:
      * chattr +c file
      * chattr +c dir; touch dir/file
      * mount w/ -o compress_extension=ext; touch file.ext
      
      Compress metadata layout:
                                   [Dnode Structure]
                   +-----------------------------------------------+
                   | cluster 1 | cluster 2 | ......... | cluster N |
                   +-----------------------------------------------+
                   .           .                       .           .
             .                       .                .                      .
        .         Compressed Cluster       .        .        Normal Cluster            .
      +----------+---------+---------+---------+  +---------+---------+---------+---------+
      |compr flag| block 1 | block 2 | block 3 |  | block 1 | block 2 | block 3 | block 4 |
      +----------+---------+---------+---------+  +---------+---------+---------+---------+
                 .                             .
               .                                           .
             .                                                           .
            +-------------+-------------+----------+----------------------------+
            | data length | data chksum | reserved |      compressed data       |
            +-------------+-------------+----------+----------------------------+
      
      Changelog:
      
      20190326:
      - fix error handling of read_end_io().
      - remove unneeded comments in f2fs_encrypt_one_page().
      
      20190327:
      - fix wrong use of f2fs_cluster_is_full() in f2fs_mpage_readpages().
      - don't jump into loop directly to avoid uninitialized variables.
      - add TODO tag in error path of f2fs_write_cache_pages().
      
      20190328:
      - fix wrong merge condition in f2fs_read_multi_pages().
      - check compressed file in f2fs_post_read_required().
      
      20190401
      - allow overwrite on non-compressed cluster.
      - check cluster meta before writing compressed data.
      
      20190402
      - don't preallocate blocks for compressed file.
      
      - add lz4 compress algorithm
      - process multiple post read works in one workqueue
        Now f2fs supports processing post read work in multiple workqueue,
        it shows low performance due to schedule overhead of multiple
        workqueue executing orderly.
      
      20190921
      - compress: support buffered overwrite
      C: compress cluster flag
      V: valid block address
      N: NEW_ADDR
      
      One cluster contain 4 blocks
      
       before overwrite   after overwrite
      
      - VVVV		->	CVNN
      - CVNN		->	VVVV
      
      - CVNN		->	CVNN
      - CVNN		->	CVVV
      
      - CVVV		->	CVNN
      - CVVV		->	CVVV
      
      20191029
      - add kconfig F2FS_FS_COMPRESSION to isolate compression related
      codes, add kconfig F2FS_FS_{LZO,LZ4} to cover backend algorithm.
      note that: will remove lzo backend if Jaegeuk agreed that too.
      - update codes according to Eric's comments.
      
      20191101
      - apply fixes from Jaegeuk
      
      20191113
      - apply fixes from Jaegeuk
      - split workqueue for fsverity
      
      20191216
      - apply fixes from Jaegeuk
      
      20200117
      - fix to avoid NULL pointer dereference
      
      [Jaegeuk Kim]
      - add tracepoint for f2fs_{,de}compress_pages()
      - fix many bugs and add some compression stats
      - fix overwrite/mmap bugs
      - address 32bit build error, reported by Geert.
      - bug fixes when handling errors and i_compressed_blocks
      
      Reported-by: <noreply@ellerman.id.au>
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      4c8ff709