1. 13 3月, 2019 2 次提交
    • C
      f2fs: fix to adapt small inline xattr space in __find_inline_xattr() · 2c28aba8
      Chao Yu 提交于
      With below testcase, we will fail to find existed xattr entry:
      
      1. mkfs.f2fs -O extra_attr -O flexible_inline_xattr /dev/zram0
      2. mount -t f2fs -o inline_xattr_size=1 /dev/zram0 /mnt/f2fs/
      3. touch /mnt/f2fs/file
      4. setfattr -n "user.name" -v 0 /mnt/f2fs/file
      5. getfattr -n "user.name" /mnt/f2fs/file
      
      /mnt/f2fs/file: user.name: No such attribute
      
      The reason is for inode which has very small inline xattr size,
      __find_inline_xattr() will fail to traverse any entry due to first
      entry may not be loaded from xattr node yet, later, we may skip to
      check entire xattr datas in __find_xattr(), result in such wrong
      condition.
      
      This patch adds condition to check such case to avoid this issue.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      2c28aba8
    • C
      f2fs: fix to use kvfree instead of kzfree · 2a6a7e72
      Chao Yu 提交于
      As Jiqun Li reported in bugzilla:
      
      https://bugzilla.kernel.org/show_bug.cgi?id=202747
      
      System can panic due to using wrong allocate/free function pair
      in xattr interface:
      - use kvmalloc to allocate memory
      - use kzfree to free memory
      
      Let's fix to use kvfree instead of kzfree, BTW, we are safe to
      get rid of kzfree, since there is no such confidential data stored
      as xattr, we don't need to zero it before free memory.
      
      Fixes: 5222595d ("f2fs: use kvmalloc, if kmalloc is failed")
      Reported-by: NJiqun Li <jiqun.li@unisoc.com>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      2a6a7e72
  2. 16 2月, 2019 1 次提交
  3. 27 12月, 2018 2 次提交
  4. 13 9月, 2018 1 次提交
  5. 02 8月, 2018 2 次提交
  6. 01 6月, 2018 1 次提交
    • C
      f2fs: clean up symbol namespace · 4d57b86d
      Chao Yu 提交于
      As Ted reported:
      
      "Hi, I was looking at f2fs's sources recently, and I noticed that there
      is a very large number of non-static symbols which don't have a f2fs
      prefix.  There's well over a hundred (see attached below).
      
      As one example, in fs/f2fs/dir.c there is:
      
      unsigned char get_de_type(struct f2fs_dir_entry *de)
      
      This function is clearly only useful for f2fs, but it has a generic
      name.  This means that if any other file system tries to have the same
      symbol name, there will be a symbol conflict and the kernel would not
      successfully build.  It also means that when someone is looking f2fs
      sources, it's not at all obvious whether a function such as
      read_data_page(), invalidate_blocks(), is a generic kernel function
      found in the fs, mm, or block layers, or a f2fs specific function.
      
      You might want to fix this at some point.  Hopefully Kent's bcachefs
      isn't similarly using genericly named functions, since that might
      cause conflicts with f2fs's functions --- but just as this would be a
      problem that we would rightly insist that Kent fix, this is something
      that we should have rightly insisted that f2fs should have fixed
      before it was integrated into the mainline kernel.
      
      acquire_orphan_inode
      add_ino_entry
      add_orphan_inode
      allocate_data_block
      allocate_new_segments
      alloc_nid
      alloc_nid_done
      alloc_nid_failed
      available_free_memory
      ...."
      
      This patch adds "f2fs_" prefix for all non-static symbols in order to:
      a) avoid conflict with other kernel generic symbols;
      b) to indicate the function is f2fs specific one instead of generic
      one;
      Reported-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      4d57b86d
  7. 23 1月, 2018 1 次提交
  8. 03 1月, 2018 2 次提交
  9. 06 11月, 2017 3 次提交
    • J
      f2fs: handle error case when adding xattr entry · bf9c1427
      Jaegeuk Kim 提交于
      This patch fixes recovering incomplete xattr entries remaining in inline xattr
      and xattr block, caused by any kind of errors.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      bf9c1427
    • C
      f2fs: support flexible inline xattr size · 6afc662e
      Chao Yu 提交于
      Now, in product, more and more features based on file encryption were
      introduced, their demand of xattr space is increasing, however, inline
      xattr has fixed-size of 200 bytes, once inline xattr space is full, new
      increased xattr data would occupy additional xattr block which may bring
      us more space usage and performance regression during persisting.
      
      In order to resolve above issue, it's better to expand inline xattr size
      flexibly according to user's requirement.
      
      So this patch introduces new filesystem feature 'flexible inline xattr',
      and new mount option 'inline_xattr_size=%u', once mkfs enables the
      feature, we can use the option to make f2fs supporting flexible inline
      xattr size.
      
      To support this feature, we add extra attribute i_inline_xattr_size in
      inode layout, indicating that how many space inline xattr borrows from
      block address mapping space in inode layout, by this, we can easily
      locate and store flexible-sized inline xattr data in inode.
      
      Inode disk layout:
        +----------------------+
        | .i_mode              |
        | ...                  |
        | .i_ext               |
        +----------------------+
        | .i_extra_isize       |
        | .i_inline_xattr_size |-----------+
        | ...                  |           |
        +----------------------+           |
        | .i_addr              |           |
        |  - block address or  |           |
        |  - inline data       |           |
        +----------------------+<---+      v
        |    inline xattr      |    +---inline xattr range
        +----------------------+<---+
        | .i_nid               |
        +----------------------+
        |   node_footer        |
        | (nid, ino, offset)   |
        +----------------------+
      
      Note that, we have to cnosider backward compatibility which reserved
      inline_data space, 200 bytes, all the time, reported by Sheng Yong.
      
      Previous inline data or directory always reserved 200 bytes in inode layout,
      even if inline_xattr is disabled. In order to keep inline_dentry's structure
      for backward compatibility, we get the space back only from inline_data.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Reported-by: NSheng Yong <shengyong1@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6afc662e
    • J
      f2fs: add missing quota_initialize · d8d1389e
      Jaegeuk Kim 提交于
      This patch adds to call quota_intialize in f2fs_set_acl, f2fs_unlink,
      and f2fs_rename.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      d8d1389e
  10. 26 10月, 2017 1 次提交
  11. 11 10月, 2017 2 次提交
  12. 08 9月, 2017 1 次提交
  13. 27 7月, 2017 1 次提交
  14. 25 3月, 2017 2 次提交
    • C
      f2fs: don't reserve additional space in xattr block · 22588f87
      Chao Yu 提交于
      In this patch, we change xattr block disk layout as below:
      
      Before:
      			xattr node block layout
      +---------------------------------------------+---------------+-------------+
      |           node block xattr entries          |   reserved    | node footer |
      |                  4068 Bytes                 |    4 Bytes    |  24 Bytes   |
      
      			In memory layout
      +--------------------+---------------------------------+--------------------+
      |    inline xattr    |     node block xattr entries    |      reserved      |
      |     200 Bytes      |         4068 Bytes              |      4 Bytes       |
      
      After:
      			xattr node block layout
      +-------------------------------------------------------------+-------------+
      |                  node block xattr entries                   | node footer |
      |                         4072 Bytes                          |  24 Bytes   |
      
      			In memory layout
      +--------------------+---------------------------------+--------------------+
      |    inline xattr    |     node block xattr entries    |      reserved      |
      |     200 Bytes      |         4072 Bytes              |      4 Bytes       |
      
      With this change, we don't need to reserve additional space in node block,
      just keep reserved space in logical in-memory layout. So that it would help
      to enlarge valid free space of xattr node block.
      
      As tested, generic/026 shows max stored xattr entires number increases from
      531 to 532 when inline_xattr option is enabled.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      22588f87
    • C
      f2fs: clean up xattr operation · 89e9eabd
      Chao Yu 提交于
      1. don't allocate redundant memory in read_all_xattrs.
      2. introduce RESERVED_XATTR_SIZE for cleanup.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Reviewed-by: NKinglong Mee <kinglongmee@gmail.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      89e9eabd
  15. 22 3月, 2017 1 次提交
  16. 28 2月, 2017 2 次提交
  17. 24 2月, 2017 1 次提交
    • C
      f2fs: change recovery policy of xattr node block · d260081c
      Chao Yu 提交于
      Currently, if we call fsync after updating the xattr date belongs to the
      file, f2fs needs to trigger checkpoint to keep xattr data consistent. But,
      this policy cause low performance as checkpoint will block most foreground
      operations and cause unneeded and unrelated IOs around checkpoint.
      
      This patch will reuse regular file recovery policy for xattr node block,
      so, we change to write xattr node block tagged with fsync flag to warm
      area instead of cold area, and during recovery, we search warm node chain
      for fsynced xattr block, and do the recovery.
      
      So, for below application IO pattern, performance can be improved
      obviously:
      - touch file
      - create/update/delete xattr entry in file
      - fsync file
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      d260081c
  18. 23 2月, 2017 1 次提交
    • C
      f2fs: enhance lookup xattr · ba38c27e
      Chao Yu 提交于
      Previously, in getxattr we will load all entries both in inline xattr and
      xattr node block, and then do the lookup in all entries, but our lookup
      flow shows low efficiency, since if we can lookup and hit in inline xattr
      of inode page cache first, we don't need to load and lookup xattr node
      block, which can obviously save cpu time and IO latency.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: initialize NULL to avoid warning]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      ba38c27e
  19. 24 11月, 2016 1 次提交
  20. 28 9月, 2016 1 次提交
  21. 23 9月, 2016 1 次提交
  22. 08 9月, 2016 1 次提交
    • J
      f2fs: fix lost xattrs of directories · bbf156f7
      Jaegeuk Kim 提交于
      This patch enhances the xattr consistency of dirs from suddern power-cuts.
      
      Possible scenario would be:
      1. dir->setxattr used by per-file encryption
      2. file->setxattr goes into inline_xattr
      3. file->fsync
      
      In that case, we should do checkpoint for #1.
      Otherwise we'd lose dir's key information for the file given #2.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      bbf156f7
  23. 09 7月, 2016 2 次提交
  24. 03 6月, 2016 3 次提交
  25. 28 5月, 2016 1 次提交
  26. 08 5月, 2016 1 次提交
  27. 15 4月, 2016 1 次提交
  28. 11 4月, 2016 1 次提交