1. 19 5月, 2020 1 次提交
  2. 12 5月, 2020 10 次提交
    • C
      f2fs: add compressed/gc data read IO stat · 9c122384
      Chao Yu 提交于
      in order to account data read IOs more accurately.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      9c122384
    • J
      f2fs: refactor resize_fs to avoid meta updates in progress · b4b10061
      Jaegeuk Kim 提交于
      Sahitya raised an issue:
      - prevent meta updates while checkpoint is in progress
      
      allocate_segment_for_resize() can cause metapage updates if
      it requires to change the current node/data segments for resizing.
      Stop these meta updates when there is a checkpoint already
      in progress to prevent inconsistent CP data.
      Signed-off-by: NSahitya Tummala <stummala@codeaurora.org>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      b4b10061
    • C
      f2fs: introduce F2FS_IOC_RESERVE_COMPRESS_BLOCKS · c75488fb
      Chao Yu 提交于
      This patch introduces a new ioctl to rollback all compress inode
      status:
      - add reserved blocks in dnode blocks
      - increase i_compr_blocks, i_blocks, total_valid_block_count
      - remove immutable flag
      
      Then compress inode can be restored to support overwrite
      functionality again.
      Signee-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      c75488fb
    • S
      f2fs: Avoid double lock for cp_rwsem during checkpoint · 34c061ad
      Sayali Lokhande 提交于
      There could be a scenario where f2fs_sync_node_pages gets
      called during checkpoint, which in turn tries to flush
      inline data and calls iput(). This results in deadlock as
      iput() tries to hold cp_rwsem, which is already held at the
      beginning by checkpoint->block_operations().
      
      Call stack :
      
      Thread A		Thread B
      f2fs_write_checkpoint()
      - block_operations(sbi)
       - f2fs_lock_all(sbi);
        - down_write(&sbi->cp_rwsem);
      
                              - open()
                               - igrab()
                              - write() write inline data
                              - unlink()
      - f2fs_sync_node_pages()
       - if (is_inline_node(page))
        - flush_inline_data()
         - ilookup()
           page = f2fs_pagecache_get_page()
           if (!page)
            goto iput_out;
           iput_out:
      			-close()
      			-iput()
             iput(inode);
             - f2fs_evict_inode()
              - f2fs_truncate_blocks()
               - f2fs_lock_op()
                 - down_read(&sbi->cp_rwsem);
      
      Fixes: 2049d4fc ("f2fs: avoid multiple node page writes due to inline_data")
      Signed-off-by: NSayali Lokhande <sayalil@codeaurora.org>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      34c061ad
    • Y
      f2fs: Fix wrong stub helper update_sit_info · 48abe91a
      YueHaibing 提交于
      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: NYueHaibing <yuehaibing@huawei.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      48abe91a
    • C
      f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS · ef8d563f
      Chao Yu 提交于
      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: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NDaeho Jeong <daehojeong@google.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      ef8d563f
    • E
      f2fs: rework filename handling · 43c780ba
      Eric Biggers 提交于
      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: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      43c780ba
    • E
      f2fs: split f2fs_d_compare() from f2fs_match_name() · f874fa1c
      Eric Biggers 提交于
      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: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      f874fa1c
    • C
      f2fs: compress: support lzo-rle compress algorithm · 6d92b201
      Chao Yu 提交于
      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: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6d92b201
    • C
      f2fs: introduce mempool for {,de}compress intermediate page allocation · 5e6bbde9
      Chao Yu 提交于
      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: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NMa Feng <mafeng.ma@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      5e6bbde9
  3. 08 5月, 2020 3 次提交
  4. 18 4月, 2020 2 次提交
  5. 17 4月, 2020 1 次提交
  6. 04 4月, 2020 3 次提交
  7. 31 3月, 2020 4 次提交
    • C
      f2fs: fix potential .flags overflow on 32bit architecture · 7653b9d8
      Chao Yu 提交于
      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: NOndrej Jirman <megous@megous.com>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7653b9d8
    • C
      f2fs: don't trigger data flush in foreground operation · 7bcd0cfa
      Chao Yu 提交于
      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: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7bcd0cfa
    • C
      f2fs: clean up f2fs_may_encrypt() · 8c7d4b57
      Chao Yu 提交于
      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: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      8c7d4b57
    • C
      f2fs: don't mark compressed inode dirty during f2fs_iget() · 530e0704
      Chao Yu 提交于
      - 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: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      530e0704
  8. 25 3月, 2020 1 次提交
  9. 23 3月, 2020 1 次提交
  10. 20 3月, 2020 8 次提交
  11. 11 3月, 2020 4 次提交
    • C
      f2fs: fix to check dirty pages during compressed inode conversion · 6cfdf15f
      Chao Yu 提交于
      Compressed cluster can be generated during dirty data writeback,
      if there is dirty pages on compressed inode, it needs to disable
      converting compressed inode to non-compressed one.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6cfdf15f
    • C
      f2fs: fix to account compressed inode correctly · 96f5b4fa
      Chao Yu 提交于
      stat_inc_compr_inode() needs to check FI_COMPRESSED_FILE flag, so
      in f2fs_disable_compressed_file(), we should call stat_dec_compr_inode()
      before clearing FI_COMPRESSED_FILE flag.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      96f5b4fa
    • C
      f2fs: fix inconsistent comments · 7a88ddb5
      Chao Yu 提交于
      Lack of maintenance on comments may mislead developers, fix them.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7a88ddb5
    • C
      f2fs: cover last_disk_size update with spinlock · c10c9820
      Chao Yu 提交于
      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: NOndřej Jirman <megi@xff.cz>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      c10c9820
  12. 28 2月, 2020 2 次提交