1. 06 11月, 2017 10 次提交
    • C
      f2fs: fix summary info corruption · 2b60311d
      Chao Yu 提交于
      Sometimes, after running generic/270 of fstest, fsck reports summary
      info and actual position of block address in direct node becoming
      inconsistent.
      
      The root cause is race in between __f2fs_replace_block and change_curseg
      as below:
      
      Thread A				Thread B
      - __clone_blkaddrs
       - f2fs_replace_block
        - __f2fs_replace_block
         - segnoA = GET_SEGNO(sbi, blkaddrA);
         - type = se->type:=CURSEG_HOT_DATA
         - if (!IS_CURSEG(sbi, segnoA))
               type = CURSEG_WARM_DATA
      					- allocate_data_block
      					 - allocate_segment
      					  - get_ssr_segment
      					  - change_curseg(segnoA, CURSEG_HOT_DATA)
         - change_curseg(segnoA, CURSEG_WARM_DATA)
          - reset_curseg
           - __set_sit_entry_type
            - change se->type from CURSEG_HOT_DATA to CURSEG_WARM_DATA
      
      So finally, hot curseg locates in segnoA, but type of segnoA becomes
      CURSEG_WARM_DATA.
      
      Then if we invoke __f2fs_replace_block(blkaddrB, blkaddrA, true, false),
      as blkaddrA locates in segnoA, so we will move warm type curseg to segnoA,
      then change its summary cache and writeback it to summary block.
      
      But segnoA is used by hot type curseg too, once it moves or persist, it
      will cover summary block content with inner old summary cache, result in
      inconsistent status.
      
      This patch tries to fix this issue by introduce global curseg lock to avoid
      race in between __f2fs_replace_block and change_curseg.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      2b60311d
    • J
      f2fs: support quota sys files · ea676733
      Jaegeuk Kim 提交于
      This patch supports hidden quota files in the system, which will be used for
      Android. It requires up-to-date f2fs-tools later than v1.9.0.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      ea676733
    • J
      f2fs: add quota_ino feature infra · 234a9689
      Jaegeuk Kim 提交于
      This patch adds quota_ino feature infra to be used for quota files.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      234a9689
    • Y
      Revert "f2fs: handle dirty segments inside refresh_sit_entry" · 65f1b80b
      Yunlong Song 提交于
      This reverts commit 5e443818
      
      The commit should be reverted because call sequence of below two parts
      of code must be kept:
      a. update sit information, it needs to be updated before segment
      allocation since latter allocation may trigger SSR, and SSR allocation
      needs latest valid block information of all segments.
      b. update segment status, it needs to be updated after segment allocation
      since we can skip updating current opened segment status.
      
      Fixes: 5e443818 ("f2fs: handle dirty segments inside refresh_sit_entry")
      Suggested-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: remove refresh_sit_entry function]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      65f1b80b
    • C
      f2fs: export SSR allocation threshold · a2a12b67
      Chao Yu 提交于
      This patch exports min_ssr_segments threshold in sysfs to let user
      control triggering SSR allocation flexibly.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      a2a12b67
    • C
      f2fs: give correct trimmed blocks in fstrim · 0ea80512
      Chao Yu 提交于
      We have supported to issue discard in specified range during fstrim,
      it needs to return caller with successfully trimmed bytes in that
      range instead of bytes of invalid blocks which are scanned in
      checkpoint.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0ea80512
    • C
      f2fs: support bio allocation error injection · d62fe971
      Chao Yu 提交于
      This patch adds to support bio allocation error injection to simulate
      out-of-memory test scenario.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      d62fe971
    • C
      f2fs: support get_page error injection · 01eccef7
      Chao Yu 提交于
      This patch adds to support get_page error injection to simulate
      out-of-memory test scenario.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      01eccef7
    • Y
      f2fs: support soft block reservation · 80d42145
      Yunlong Song 提交于
      It supports to extend reserved_blocks sysfs interface to be soft
      threshold, which allows user configure it exceeding current available
      user space. This patch also introduces a new sysfs interface called
      current_reserved_blocks, which shows the current blocks that have
      already been reserved.
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      80d42145
    • 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
  2. 26 10月, 2017 8 次提交
  3. 11 10月, 2017 4 次提交
  4. 03 10月, 2017 1 次提交
    • C
      f2fs: fix potential panic during fstrim · 638164a2
      Chao Yu 提交于
      As Ju Hyung Park reported:
      
      "When 'fstrim' is called for manual trim, a BUG() can be triggered
      randomly with this patch.
      
      I'm seeing this issue on both x86 Desktop and arm64 Android phone.
      
      On x86 Desktop, this was caused during Ubuntu boot-up. I have a
      cronjob installed which calls 'fstrim -v /' during boot. On arm64
      Android, this was caused during GC looping with 1ms gc_min_sleep_time
      & gc_max_sleep_time."
      
      Root cause of this issue is that f2fs_wait_discard_bios can only be
      used by f2fs_put_super, because during put_super there must be no
      other referrers, so it can ignore discard entry's reference count
      when removing the entry, otherwise in other caller we will hit bug_on
      in __remove_discard_cmd as there may be other issuer added reference
      count in discard entry.
      
      Thread A				Thread B
      					- issue_discard_thread
      - f2fs_ioc_fitrim
       - f2fs_trim_fs
        - f2fs_wait_discard_bios
         - __issue_discard_cmd
          - __submit_discard_cmd
      					 - __wait_discard_cmd
      					  - dc->ref++
      					  - __wait_one_discard_bio
         - __wait_discard_cmd
          - __remove_discard_cmd
           - f2fs_bug_on(sbi, dc->ref)
      
      Fixes: 969d1b18Reported-by: NJu Hyung Park <qkrwngud825@gmail.com>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      638164a2
  5. 12 9月, 2017 1 次提交
  6. 08 9月, 2017 1 次提交
  7. 06 9月, 2017 2 次提交
  8. 22 8月, 2017 3 次提交
    • C
      f2fs: introduce discard_granularity sysfs entry · 969d1b18
      Chao Yu 提交于
      Commit d618ebaf ("f2fs: enable small discard by default") enables
      f2fs to issue 4K size discard in real-time discard mode. However, issuing
      smaller discard may cost more lifetime but releasing less free space in
      flash device. Since f2fs has ability of separating hot/cold data and
      garbage collection, we can expect that small-sized invalid region would
      expand soon with OPU, deletion or garbage collection on valid datas, so
      it's better to delay or skip issuing smaller size discards, it could help
      to reduce overmuch consumption of IO bandwidth and lifetime of flash
      storage.
      
      This patch makes f2fs selectng 64K size as its default minimal
      granularity, and issue discard with the size which is not smaller than
      minimal granularity. Also it exposes discard granularity as sysfs entry
      for configuration in different scenario.
      
      Jaegeuk Kim:
       We must issue all the accumulated discard commands when fstrim is called.
       So, I've added pend_list_tag[] to indicate whether we should issue the
       commands or not. If tag sets P_ACTIVE or P_TRIM, we have to issue them.
       P_TRIM is set once at a time, given fstrim trigger.
       In addition, issue_discard_thread is calling too much due to the number of
       discard commands remaining in the pending list. I added a timer to control
       it likewise gc_thread.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      969d1b18
    • Q
      f2fs: merge equivalent flags F2FS_GET_BLOCK_[READ|DIO] · f2220c7f
      Qiuyang Sun 提交于
      Currently, the two flags F2FS_GET_BLOCK_[READ|DIO] are totally equivalent
      and can be used interchangably in all scenarios they are involved in.
      Neither of the flags is referenced in f2fs_map_blocks(), making them both
      the default case. To remove the ambiguity, this patch merges both flags
      into F2FS_GET_BLOCK_DEFAULT, and introduces an enum for all distinct flags.
      Signed-off-by: NQiuyang Sun <sunqiuyang@huawei.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      f2220c7f
    • C
      f2fs: support journalled quota · 4b2414d0
      Chao Yu 提交于
      This patch supports to enable f2fs to accept quota information through
      mount option:
      - {usr,grp,prj}jquota=<quota file path>
      - jqfmt=<quota type>
      
      Then, in ->mount flow, we can recover quota file during log replaying,
      by this, journelled quota can be supported.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: Fix wrong return values.]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      4b2414d0
  9. 10 8月, 2017 1 次提交
  10. 04 8月, 2017 2 次提交
  11. 01 8月, 2017 6 次提交
    • C
      f2fs: support F2FS_IOC_FS{GET,SET}XATTR · 2c1d0305
      Chao Yu 提交于
      This patch adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR ioctl interface
      support for f2fs. The interface is kept consistent with the one
      of ext4/xfs.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      2c1d0305
    • J
      f2fs: avoid naming confusion of sysfs init · dc6b2055
      Jaegeuk Kim 提交于
      This patch changes the function names of sysfs init to follow ext4.
      
      f2fs_init_sysfs <-> f2fs_register_sysfs
      f2fs_exit_sysfs <-> f2fs_unregister_sysfs
      Suggested-by: NChao Yu <yuchao0@huawei.com>
      Reivewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      dc6b2055
    • C
      f2fs: support project quota · 5c57132e
      Chao Yu 提交于
      This patch adds to support plain project quota.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      5c57132e
    • C
      f2fs: enhance on-disk inode structure scalability · 7a2af766
      Chao Yu 提交于
      This patch add new flag F2FS_EXTRA_ATTR storing in inode.i_inline
      to indicate that on-disk structure of current inode is extended.
      
      In order to extend, we changed the inode structure a bit:
      
      Original one:
      
      struct f2fs_inode {
      	...
      	struct f2fs_extent i_ext;
      	__le32 i_addr[DEF_ADDRS_PER_INODE];
      	__le32 i_nid[DEF_NIDS_PER_INODE];
      }
      
      Extended one:
      
      struct f2fs_inode {
              ...
              struct f2fs_extent i_ext;
      	union {
      		struct {
      			__le16 i_extra_isize;
      			__le16 i_padding;
      			__le32 i_extra_end[0];
      		};
      		__le32 i_addr[DEF_ADDRS_PER_INODE];
      	};
              __le32 i_nid[DEF_NIDS_PER_INODE];
      }
      
      Once F2FS_EXTRA_ATTR is set, we will steal four bytes in the head of
      i_addr field for storing i_extra_isize and i_padding. with i_extra_isize,
      we can calculate actual size of reserved space in i_addr, available
      attribute fields included in total extra attribute fields for current
      inode can be described as below:
      
        +--------------------+
        | .i_mode            |
        | ...                |
        | .i_ext             |
        +--------------------+
        | .i_extra_isize     |-----+
        | .i_padding         |     |
        | .i_prjid           |     |
        | .i_atime_extra     |     |
        | .i_ctime_extra     |     |
        | .i_mtime_extra     |<----+
        | .i_inode_cs        |<----- store blkaddr/inline from here
        | .i_xattr_cs        |
        | ...                |
        +--------------------+
        |                    |
        |    block address   |
        |                    |
        +--------------------+
        | .i_nid             |
        +--------------------+
        |   node_footer      |
        | (nid, ino, offset) |
        +--------------------+
      
      Hence, with this patch, we would enhance scalability of f2fs inode for
      storing more newly added attribute.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7a2af766
    • C
      f2fs: make max inline size changeable · f2470371
      Chao Yu 提交于
      This patch tries to make below macros calculating max inline size,
      inline dentry field size considerring reserving size-changeable
      space:
      - MAX_INLINE_DATA
      - NR_INLINE_DENTRY
      - INLINE_DENTRY_BITMAP_SIZE
      - INLINE_RESERVED_SIZE
      
      Then, when inline_{data,dentry} options is enabled, it allows us to
      reserve inline space with different size flexibly for adding newly
      introduced inode attribute.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      f2470371
    • J
      f2fs: add ioctl to expose current features · e65ef207
      Jaegeuk Kim 提交于
      This patch adds an ioctl to provide feature information to user.
      For exapmle, SQLite can use this ioctl to detect whether f2fs support atomic
      write or not.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      e65ef207
  12. 29 7月, 2017 1 次提交