1. 28 11月, 2017 1 次提交
    • L
      Rename superblock flags (MS_xyz -> SB_xyz) · 1751e8a6
      Linus Torvalds 提交于
      This is a pure automated search-and-replace of the internal kernel
      superblock flags.
      
      The s_flags are now called SB_*, with the names and the values for the
      moment mirroring the MS_* flags that they're equivalent to.
      
      Note how the MS_xyz flags are the ones passed to the mount system call,
      while the SB_xyz flags are what we then use in sb->s_flags.
      
      The script to do this was:
      
          # places to look in; re security/*: it generally should *not* be
          # touched (that stuff parses mount(2) arguments directly), but
          # there are two places where we really deal with superblock flags.
          FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
                  include/linux/fs.h include/uapi/linux/bfs_fs.h \
                  security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
          # the list of MS_... constants
          SYMS="RDONLY NOSUID NODEV NOEXEC SYNCHRONOUS REMOUNT MANDLOCK \
                DIRSYNC NOATIME NODIRATIME BIND MOVE REC VERBOSE SILENT \
                POSIXACL UNBINDABLE PRIVATE SLAVE SHARED RELATIME KERNMOUNT \
                I_VERSION STRICTATIME LAZYTIME SUBMOUNT NOREMOTELOCK NOSEC BORN \
                ACTIVE NOUSER"
      
          SED_PROG=
          for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done
      
          # we want files that contain at least one of MS_...,
          # with fs/namespace.c and fs/pnode.c excluded.
          L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')
      
          for f in $L; do sed -i $f $SED_PROG; done
      Requested-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1751e8a6
  2. 14 11月, 2017 2 次提交
  3. 07 11月, 2017 1 次提交
  4. 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
  5. 26 10月, 2017 8 次提交
  6. 19 10月, 2017 2 次提交
    • E
      fs, fscrypt: add an S_ENCRYPTED inode flag · 2ee6a576
      Eric Biggers 提交于
      Introduce a flag S_ENCRYPTED which can be set in ->i_flags to indicate
      that the inode is encrypted using the fscrypt (fs/crypto/) mechanism.
      
      Checking this flag will give the same information that
      inode->i_sb->s_cop->is_encrypted(inode) currently does, but will be more
      efficient.  This will be useful for adding higher-level helper functions
      for filesystems to use.  For example we'll be able to replace this:
      
      	if (ext4_encrypted_inode(inode)) {
      		ret = fscrypt_get_encryption_info(inode);
      		if (ret)
      			return ret;
      		if (!fscrypt_has_encryption_key(inode))
      			return -ENOKEY;
      	}
      
      with this:
      
      	ret = fscrypt_require_key(inode);
      	if (ret)
      		return ret;
      
      ... since we'll be able to retain the fast path for unencrypted files as
      a single flag check, using an inline function.  This wasn't possible
      before because we'd have had to frequently call through the
      ->i_sb->s_cop->is_encrypted function pointer, even when the encryption
      support was disabled or not being used.
      
      Note: we don't define S_ENCRYPTED to 0 if CONFIG_FS_ENCRYPTION is
      disabled because we want to continue to return an error if an encrypted
      file is accessed without encryption support, rather than pretending that
      it is unencrypted.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Acked-by: NDave Chinner <dchinner@redhat.com>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      2ee6a576
    • D
      fscrypt: clean up include file mess · 734f0d24
      Dave Chinner 提交于
      Filesystems have to include different header files based on whether they
      are compiled with encryption support or not. That's nasty and messy.
      
      Instead, rationalise the headers so we have a single include fscrypt.h
      and let it decide what internal implementation to include based on the
      __FS_HAS_ENCRYPTION define.  Filesystems set __FS_HAS_ENCRYPTION to 1
      before including linux/fscrypt.h if they are built with encryption
      support.  Otherwise, they must set __FS_HAS_ENCRYPTION to 0.
      
      Add guards to prevent fscrypt_supp.h and fscrypt_notsupp.h from being
      directly included by filesystems.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      [EB: use 1 and 0 rather than defined/undefined]
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      734f0d24
  7. 11 10月, 2017 4 次提交
  8. 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
  9. 12 9月, 2017 1 次提交
  10. 08 9月, 2017 1 次提交
  11. 06 9月, 2017 2 次提交
  12. 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
  13. 10 8月, 2017 1 次提交
  14. 04 8月, 2017 2 次提交
  15. 01 8月, 2017 1 次提交