1. 12 9月, 2020 2 次提交
    • D
      f2fs: change compr_blocks of superblock info to 64bit · ae999bb9
      Daeho Jeong 提交于
      Current compr_blocks of superblock info is not 64bit value. We are
      accumulating each i_compr_blocks count of inodes to this value and
      those are 64bit values. So, need to change this to 64bit value.
      Signed-off-by: NDaeho Jeong <daehojeong@google.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      ae999bb9
    • C
      f2fs: support age threshold based garbage collection · 093749e2
      Chao Yu 提交于
      There are several issues in current background GC algorithm:
      - valid blocks is one of key factors during cost overhead calculation,
      so if segment has less valid block, however even its age is young or
      it locates hot segment, CB algorithm will still choose the segment as
      victim, it's not appropriate.
      - GCed data/node will go to existing logs, no matter in-there datas'
      update frequency is the same or not, it may mix hot and cold data
      again.
      - GC alloctor mainly use LFS type segment, it will cost free segment
      more quickly.
      
      This patch introduces a new algorithm named age threshold based
      garbage collection to solve above issues, there are three steps
      mainly:
      
      1. select a source victim:
      - set an age threshold, and select candidates beased threshold:
      e.g.
       0 means youngest, 100 means oldest, if we set age threshold to 80
       then select dirty segments which has age in range of [80, 100] as
       candiddates;
      - set candidate_ratio threshold, and select candidates based the
      ratio, so that we can shrink candidates to those oldest segments;
      - select target segment with fewest valid blocks in order to
      migrate blocks with minimum cost;
      
      2. select a target victim:
      - select candidates beased age threshold;
      - set candidate_radius threshold, search candidates whose age is
      around source victims, searching radius should less than the
      radius threshold.
      - select target segment with most valid blocks in order to avoid
      migrating current target segment.
      
      3. merge valid blocks from source victim into target victim with
      SSR alloctor.
      
      Test steps:
      - create 160 dirty segments:
       * half of them have 128 valid blocks per segment
       * left of them have 384 valid blocks per segment
      - run background GC
      
      Benefit: GC count and block movement count both decrease obviously:
      
      - Before:
        - Valid: 86
        - Dirty: 1
        - Prefree: 11
        - Free: 6001 (6001)
      
      GC calls: 162 (BG: 220)
        - data segments : 160 (160)
        - node segments : 2 (2)
      Try to move 41454 blocks (BG: 41454)
        - data blocks : 40960 (40960)
        - node blocks : 494 (494)
      
      IPU: 0 blocks
      SSR: 0 blocks in 0 segments
      LFS: 41364 blocks in 81 segments
      
      - After:
      
        - Valid: 87
        - Dirty: 0
        - Prefree: 4
        - Free: 6008 (6008)
      
      GC calls: 75 (BG: 76)
        - data segments : 74 (74)
        - node segments : 1 (1)
      Try to move 12813 blocks (BG: 12813)
        - data blocks : 12544 (12544)
        - node blocks : 269 (269)
      
      IPU: 0 blocks
      SSR: 12032 blocks in 77 segments
      LFS: 855 blocks in 2 segments
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: fix a bug along with pinfile in-mem segment & clean up]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      093749e2
  2. 11 9月, 2020 7 次提交
    • D
      f2fs: Use generic casefolding support · eca4873e
      Daniel Rosenberg 提交于
      This switches f2fs over to the generic support provided in
      the previous patch.
      
      Since casefolded dentries behave the same in ext4 and f2fs, we decrease
      the maintenance burden by unifying them, and any optimizations will
      immediately apply to both.
      Signed-off-by: NDaniel Rosenberg <drosen@google.com>
      Reviewed-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      eca4873e
    • C
      f2fs: compress: use more readable atomic_t type for {cic,dic}.ref · e6c3948d
      Chao Yu 提交于
      refcount_t type variable should never be less than one, so it's a
      little bit hard to understand when we use it to indicate pending
      compressed page count, let's change to use atomic_t for better
      readability.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      e6c3948d
    • C
      f2fs: support 64-bits key in f2fs rb-tree node entry · 2e9b2bb2
      Chao Yu 提交于
      then, we can add specified entry into rb-tree with 64-bits segment time
      as key.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      2e9b2bb2
    • C
      f2fs: inherit mtime of original block during GC · c5d02785
      Chao Yu 提交于
      Don't let f2fs inner GC ruins original aging degree of segment.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      c5d02785
    • C
      f2fs: introduce inmem curseg · d0b9e42a
      Chao Yu 提交于
      Previous implementation of aligned pinfile allocation will:
      - allocate new segment on cold data log no matter whether last used
      segment is partially used or not, it makes IOs more random;
      - force concurrent cold data/GCed IO going into warm data area, it
      can make a bad effect on hot/cold data separation;
      
      In this patch, we introduce a new type of log named 'inmem curseg',
      the differents from normal curseg is:
      - it reuses existed segment type (CURSEG_XXX_NODE/DATA);
      - it only exists in memory, its segno, blkofs, summary will not b
       persisted into checkpoint area;
      
      With this new feature, we can enhance scalability of log, special
      allocators can be created for purposes:
      - pure lfs allocator for aligned pinfile allocation or file
      defragmentation
      - pure ssr allocator for later feature
      
      So that, let's update aligned pinfile allocation to use this new
      inmem curseg fwk.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      d0b9e42a
    • X
      f2fs: remove duplicated type casting · e90027d2
      Xiaojun Wang 提交于
      Since DUMMY_WRITTEN_PAGE and ATOMIC_WRITTEN_PAGE have already been
      converted as unsigned long type, we don't need do type casting again.
      Signed-off-by: NXiaojun Wang <wangxiaojun11@huawei.com>
      Reported-by: NJack Qiu <jack.qiu@huawei.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      e90027d2
    • A
      f2fs: support zone capacity less than zone size · de881df9
      Aravind Ramesh 提交于
      NVMe Zoned Namespace devices can have zone-capacity less than zone-size.
      Zone-capacity indicates the maximum number of sectors that are usable in
      a zone beginning from the first sector of the zone. This makes the sectors
      sectors after the zone-capacity till zone-size to be unusable.
      This patch set tracks zone-size and zone-capacity in zoned devices and
      calculate the usable blocks per segment and usable segments per section.
      
      If zone-capacity is less than zone-size mark only those segments which
      start before zone-capacity as free segments. All segments at and beyond
      zone-capacity are treated as permanently used segments. In cases where
      zone-capacity does not align with segment size the last segment will start
      before zone-capacity and end beyond the zone-capacity of the zone. For
      such spanning segments only sectors within the zone-capacity are used.
      
      During writes and GC manage the usable segments in a section and usable
      blocks per segment. Segments which are beyond zone-capacity are never
      allocated, and do not need to be garbage collected, only the segments
      which are before zone-capacity needs to garbage collected.
      For spanning segments based on the number of usable blocks in that
      segment, write to blocks only up to zone-capacity.
      
      Zone-capacity is device specific and cannot be configured by the user.
      Since NVMe ZNS device zones are sequentially write only, a block device
      with conventional zones or any normal block device is needed along with
      the ZNS device for the metadata operations of F2fs.
      
      A typical nvme-cli output of a zoned device shows zone start and capacity
      and write pointer as below:
      
      SLBA: 0x0     WP: 0x0     Cap: 0x18800 State: EMPTY Type: SEQWRITE_REQ
      SLBA: 0x20000 WP: 0x20000 Cap: 0x18800 State: EMPTY Type: SEQWRITE_REQ
      SLBA: 0x40000 WP: 0x40000 Cap: 0x18800 State: EMPTY Type: SEQWRITE_REQ
      
      Here zone size is 64MB, capacity is 49MB, WP is at zone start as the zones
      are in EMPTY state. For each zone, only zone start + 49MB is usable area,
      any lba/sector after 49MB cannot be read or written to, the drive will fail
      any attempts to read/write. So, the second zone starts at 64MB and is
      usable till 113MB (64 + 49) and the range between 113 and 128MB is
      again unusable. The next zone starts at 128MB, and so on.
      Signed-off-by: NAravind Ramesh <aravind.ramesh@wdc.com>
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: NNiklas Cassel <niklas.cassel@wdc.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      de881df9
  3. 24 8月, 2020 1 次提交
  4. 04 8月, 2020 1 次提交
  5. 26 7月, 2020 1 次提交
  6. 24 7月, 2020 1 次提交
  7. 22 7月, 2020 1 次提交
    • D
      f2fs: add F2FS_IOC_SEC_TRIM_FILE ioctl · 9af84648
      Daeho Jeong 提交于
      Added a new ioctl to send discard commands or/and zero out
      to selected data area of a regular file for security reason.
      
      The way of handling range.len of F2FS_IOC_SEC_TRIM_FILE:
      1. Added -1 value support for range.len to secure trim the whole blocks
         starting from range.start regardless of i_size.
      2. If the end of the range passes over the end of file, it means until
         the end of file (i_size).
      3. ignored the case of that range.len is zero to prevent the function
         from making end_addr zero and triggering different behaviour of
         the function.
      Signed-off-by: NDaeho Jeong <daehojeong@google.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      9af84648
  8. 21 7月, 2020 1 次提交
  9. 09 7月, 2020 1 次提交
  10. 08 7月, 2020 8 次提交
    • D
      f2fs: add GC_URGENT_LOW mode in gc_urgent · 0e5e8111
      Daeho Jeong 提交于
      Added a new gc_urgent mode, GC_URGENT_LOW, in which mode
      F2FS will lower the bar of checking idle in order to
      process outstanding discard commands and GC a little bit
      aggressively.
      Signed-off-by: NDaeho Jeong <daehojeong@google.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0e5e8111
    • J
      f2fs: avoid readahead race condition · 6b12367d
      Jaegeuk Kim 提交于
      If two readahead threads having same offset enter in readpages, every read
      IOs are split and issued to the disk which giving lower bandwidth.
      
      This patch tries to avoid redundant readahead calls.
      
      Fixes one build error reported by Randy.
      Fix build error when F2FS_FS_COMPRESSION is not set/enabled.
      This label is needed in either case.
      
      ../fs/f2fs/data.c: In function ‘f2fs_mpage_readpages’:
      ../fs/f2fs/data.c:2327:5: error: label ‘next_page’ used but not defined
           goto next_page;
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6b12367d
    • C
      f2fs: split f2fs_allocate_new_segments() · 901d745f
      Chao Yu 提交于
      to two independent functions:
      - f2fs_allocate_new_segment() for specified type segment allocation
      - f2fs_allocate_new_segments() for all data type segments allocation
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      901d745f
    • Y
      f2fs: fix an oops in f2fs_is_compressed_page · 29b993c7
      Yu Changchun 提交于
      This patch is to fix a crash:
      
       #3 [ffffb6580689f898] oops_end at ffffffffa2835bc2
       #4 [ffffb6580689f8b8] no_context at ffffffffa28766e7
       #5 [ffffb6580689f920] async_page_fault at ffffffffa320135e
          [exception RIP: f2fs_is_compressed_page+34]
          RIP: ffffffffa2ba83a2  RSP: ffffb6580689f9d8  RFLAGS: 00010213
          RAX: 0000000000000001  RBX: fffffc0f50b34bc0  RCX: 0000000000002122
          RDX: 0000000000002123  RSI: 0000000000000c00  RDI: fffffc0f50b34bc0
          RBP: ffff97e815a40178   R8: 0000000000000000   R9: ffff97e83ffc9000
          R10: 0000000000032300  R11: 0000000000032380  R12: ffffb6580689fa38
          R13: fffffc0f50b34bc0  R14: ffff97e825cbd000  R15: 0000000000000c00
          ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
       #6 [ffffb6580689f9d8] __is_cp_guaranteed at ffffffffa2b7ea98
       #7 [ffffb6580689f9f0] f2fs_submit_page_write at ffffffffa2b81a69
       #8 [ffffb6580689fa30] f2fs_do_write_meta_page at ffffffffa2b99777
       #9 [ffffb6580689fae0] __f2fs_write_meta_page at ffffffffa2b75f1a
       #10 [ffffb6580689fb18] f2fs_sync_meta_pages at ffffffffa2b77466
       #11 [ffffb6580689fc98] do_checkpoint at ffffffffa2b78e46
       #12 [ffffb6580689fd88] f2fs_write_checkpoint at ffffffffa2b79c29
       #13 [ffffb6580689fdd0] f2fs_sync_fs at ffffffffa2b69d95
       #14 [ffffb6580689fe20] sync_filesystem at ffffffffa2ad2574
       #15 [ffffb6580689fe30] generic_shutdown_super at ffffffffa2a9b582
       #16 [ffffb6580689fe48] kill_block_super at ffffffffa2a9b6d1
       #17 [ffffb6580689fe60] kill_f2fs_super at ffffffffa2b6abe1
       #18 [ffffb6580689fea0] deactivate_locked_super at ffffffffa2a9afb6
       #19 [ffffb6580689feb8] cleanup_mnt at ffffffffa2abcad4
       #20 [ffffb6580689fee0] task_work_run at ffffffffa28bca28
       #21 [ffffb6580689ff00] exit_to_usermode_loop at ffffffffa28050b7
       #22 [ffffb6580689ff38] do_syscall_64 at ffffffffa280560e
       #23 [ffffb6580689ff50] entry_SYSCALL_64_after_hwframe at ffffffffa320008c
      
      This occurred when umount f2fs if enable F2FS_FS_COMPRESSION
      with F2FS_IO_TRACE. Fixes it by adding IS_IO_TRACED_PAGE to check
      validity of pid for page_private.
      Signed-off-by: NYu Changchun <yuchangchun1@huawei.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      29b993c7
    • C
      f2fs: fix to wait page writeback before update · a6d601f3
      Chao Yu 提交于
      Filesystem including f2fs should support stable page for special
      device like software raid, however there is one missing path that
      page could be updated while it is writeback state as below, fix
      this.
      
      - gc_node_segment
       - f2fs_move_node_page
        - __write_node_page
         - set_page_writeback
      
      - do_read_inode
       - f2fs_init_extent_tree
        - __f2fs_init_extent_tree
          i_ext->len = 0;
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      a6d601f3
    • C
      f2fs: show more debug info for per-temperature log · 0759e2c1
      Chao Yu 提交于
      - Add to account and show per-log dirty_seg, full_seg and valid_blocks
      in debugfs.
      - reformat printed info.
      
          TYPE            segno    secno   zoneno  dirty_seg   full_seg  valid_blk
        - COLD   data:     1523     1523     1523          1          0        399
        - WARM   data:      769      769      769         20        255     133098
        - HOT    data:      767      767      767          9          0        167
        - Dir   dnode:       22       22       22          3          0         70
        - File  dnode:      722      722      722         14         10       6505
        - Indir nodes:        2        2        2          1          0          3
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0759e2c1
    • C
      f2fs: clean up parameter of f2fs_allocate_data_block() · f608c38c
      Chao Yu 提交于
      Use validation of @fio to inidcate whether caller want to serialize IOs
      in io.io_list or not, then @add_list will be redundant, remove it.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      f608c38c
    • C
      f2fs: add prefix for exported symbols · 0ef81833
      Chao Yu 提交于
      to avoid polluting global symbol namespace.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0ef81833
  11. 09 6月, 2020 2 次提交
    • J
      f2fs: add node_io_flag for bio flags likewise data_io_flag · 32b6aba8
      Jaegeuk Kim 提交于
      This patch adds another way to attach bio flags to node writes.
      
      Description:   Give a way to attach REQ_META|FUA to node writes
                     given temperature-based bits. Now the bits indicate:
                     *      REQ_META     |      REQ_FUA      |
                     *    5 |    4 |   3 |    2 |    1 |   0 |
                     * Cold | Warm | Hot | Cold | Warm | Hot |
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      32b6aba8
    • E
      f2fs: don't return vmalloc() memory from f2fs_kmalloc() · 0b6d4ca0
      Eric Biggers 提交于
      kmalloc() returns kmalloc'ed memory, and kvmalloc() returns either
      kmalloc'ed or vmalloc'ed memory.  But the f2fs wrappers, f2fs_kmalloc()
      and f2fs_kvmalloc(), both return both kinds of memory.
      
      It's redundant to have two functions that do the same thing, and also
      breaking the standard naming convention is causing bugs since people
      assume it's safe to kfree() memory allocated by f2fs_kmalloc().  See
      e.g. the various allocations in fs/f2fs/compress.c.
      
      Fix this by making f2fs_kmalloc() just use kmalloc().  And to avoid
      re-introducing the allocation failures that the vmalloc fallback was
      intended to fix, convert the largest allocations to use f2fs_kvmalloc().
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0b6d4ca0
  12. 03 6月, 2020 2 次提交
  13. 19 5月, 2020 2 次提交
    • E
      fscrypt: support test_dummy_encryption=v2 · ed318a6c
      Eric Biggers 提交于
      v1 encryption policies are deprecated in favor of v2, and some new
      features (e.g. encryption+casefolding) are only being added for v2.
      
      Therefore, the "test_dummy_encryption" mount option (which is used for
      encryption I/O testing with xfstests) needs to support v2 policies.
      
      To do this, extend its syntax to be "test_dummy_encryption=v1" or
      "test_dummy_encryption=v2".  The existing "test_dummy_encryption" (no
      argument) also continues to be accepted, to specify the default setting
      -- currently v1, but the next patch changes it to v2.
      
      To cleanly support both v1 and v2 while also making it easy to support
      specifying other encryption settings in the future (say, accepting
      "$contents_mode:$filenames_mode:v2"), make ext4 and f2fs maintain a
      pointer to the dummy fscrypt_context rather than using mount flags.
      
      To avoid concurrency issues, don't allow test_dummy_encryption to be set
      or changed during a remount.  (The former restriction is new, but
      xfstests doesn't run into it, so no one should notice.)
      
      Tested with 'gce-xfstests -c {ext4,f2fs}/encrypt -g auto'.  On ext4,
      there are two regressions, both of which are test bugs: ext4/023 and
      ext4/028 fail because they set an xattr and expect it to be stored
      inline, but the increase in size of the fscrypt_context from
      24 to 40 bytes causes this xattr to be spilled into an external block.
      
      Link: https://lore.kernel.org/r/20200512233251.118314-4-ebiggers@kernel.orgAcked-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Reviewed-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      ed318a6c
    • J
      f2fs: fix checkpoint=disable:%u%% · 1ae18f71
      Jaegeuk Kim 提交于
      When parsing the mount option, we don't have sbi->user_block_count.
      Should do it after getting it.
      
      Cc: <stable@vger.kernel.org>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      1ae18f71
  14. 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