1. 01 6月, 2018 2 次提交
    • C
      f2fs: don't use GFP_ZERO for page caches · 81114baa
      Chao Yu 提交于
      Related to https://lkml.org/lkml/2018/4/8/661
      
      Sometimes, we need to write meta data to new allocated block address,
      then we will allocate a zeroed page in inner inode's address space, and
      fill partial data in it, and leave other place with zero value which means
      some fields are initial status.
      
      There are two inner inodes (meta inode and node inode) setting __GFP_ZERO,
      I have just checked them, for both of them, we can avoid using __GFP_ZERO,
      and do initialization by ourselves to avoid unneeded/redundant zeroing
      from mm.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      81114baa
    • C
      f2fs: introduce private inode status mapping · 59c84408
      Chao Yu 提交于
      Previously, we use generic FS_*_FL defined by vfs to indicate inode status
      for each bit of i_flags, so f2fs's flag status definition is tied to vfs'
      one, it will be hard for f2fs to reuse bits f2fs never used to indicate
      new status..
      
      In order to solve this issue, we introduce private inode status mapping,
      Note, for these bits have already been persisted into disk, we should
      never change their definition, for other ones, we can remap them for
      later new coming status.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      59c84408
  2. 04 4月, 2018 1 次提交
  3. 17 3月, 2018 1 次提交
  4. 13 3月, 2018 1 次提交
  5. 26 1月, 2018 1 次提交
  6. 19 1月, 2018 1 次提交
    • D
      f2fs: prevent newly created inode from being dirtied incorrectly · 9ac1e2d8
      Daeho Jeong 提交于
      Now, we invoke f2fs_mark_inode_dirty_sync() to make an inode dirty in
      advance of creating a new node page for the inode. By this, some inodes
      whose node page is not created yet can be linked into the global dirty
      list.
      
      If the checkpoint is executed at this moment, the inode will be written
      back by writeback_single_inode() and finally update_inode_page() will
      fail to detach the inode from the global dirty list because the inode
      doesn't have a node page.
      
      The problem is that the inode's state in VFS layer will become clean
      after execution of writeback_single_inode() and it's still linked in
      the global dirty list of f2fs and this will cause a kernel panic.
      
      So, we will prevent the newly created inode from being dirtied during
      the FI_NEW_INODE flag of the inode is set. We will make it dirty
      right after the flag is cleared.
      Signed-off-by: NDaeho Jeong <daeho.jeong@samsung.com>
      Signed-off-by: NYoungjin Gil <youngjin.gil@samsung.com>
      Tested-by: NHobin Woo <hobin.woo@samsung.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      9ac1e2d8
  7. 12 1月, 2018 1 次提交
  8. 03 1月, 2018 1 次提交
    • Y
      f2fs: fix an error case of missing update inode page · 211a6fa0
      Yunlei He 提交于
      -Thread A                             Thread B
      
      -write_checkpoint
       -block_operations
        -f2fs_unlock_all                    -f2fs_sync_file
                                             -f2fs_write_inode
                                              -f2fs_inode_synced
          -f2fs_sync_inode_meta
           -sync_node_pages
                                              -set_page_drity
      
      In this case, if sudden power off without next new checkpoint,
      the last inode page update will lost. wb_writeback is same with
      fsync.
      
      Yunlei also reproduced the bug by:
      
      @@ -366,7 +366,7 @@ int update_inode(struct inode *inode, struct page *node_page)
              struct extent_tree *et = F2FS_I(inode)->extent_tree;
      
              f2fs_inode_synced(inode);
      -
      +       msleep(10000);
              f2fs_wait_on_page_writeback(node_page, NODE, true);
      
      shell 1:                                       shell2:
      
      dd if=/dev/zero of=./test bs=1M count=10
      sync
      echo "hello" >> ./test
      fsync test  // sleep 10s
                                                     sync //return quickly
      echo c > /proc/sysrq-trigger
      Signed-off-by: NYunlei He <heyunlei@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      211a6fa0
  9. 06 11月, 2017 1 次提交
    • 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
  10. 26 10月, 2017 1 次提交
  11. 19 10月, 2017 1 次提交
    • 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
  12. 11 10月, 2017 1 次提交
    • C
      f2fs: enhance multiple device flush · 39d787be
      Chao Yu 提交于
      When multiple device feature is enabled, during ->fsync we will issue
      flush in all devices to make sure node/data of the file being persisted
      into storage. But some flushes of device could be unneeded as file's
      data may be not writebacked into those devices. So this patch adds and
      manage bitmap per inode in global cache to indicate which device is
      dirty and it needs to issue flush during ->fsync, hence, we could improve
      performance of fsync in scenario of multiple device.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      39d787be
  13. 13 9月, 2017 1 次提交
  14. 06 9月, 2017 1 次提交
  15. 04 8月, 2017 1 次提交
  16. 01 8月, 2017 3 次提交
    • 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
  17. 09 7月, 2017 1 次提交
    • C
      f2fs: support plain user/group quota · 0abd675e
      Chao Yu 提交于
      This patch adds to support plain user/group quota.
      
      Change Note by Jaegeuk Kim.
      
      - Use f2fs page cache for quota files in order to consider garbage collection.
        so, quota files are not tolerable for sudden power-cuts, so user needs to do
        quotacheck.
      
      - setattr() calls dquot_transfer which will transfer inode->i_blocks.
        We can't reclaim that during f2fs_evict_inode(). So, we need to count
        node blocks as well in order to match i_blocks with dquot's space.
      
        Note that, Chao wrote a patch to count inode->i_blocks without inode block.
        (f2fs: don't count inode block in in-memory inode.i_blocks)
      
      - in f2fs_remount, we need to make RW in prior to dquot_resume.
      
      - handle fault_injection case during f2fs_quota_off_umount
      
      - TODO: Project quota
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0abd675e
  18. 08 7月, 2017 1 次提交
    • C
      f2fs: don't count inode block in in-memory inode.i_blocks · 000519f2
      Chao Yu 提交于
      Previously, we count all inode consumed blocks including inode block,
      xattr block, index block, data block into i_blocks, for other generic
      filesystems, they won't count inode block into i_blocks, so for
      userspace applications or quota system, they may detect incorrect block
      count according to i_blocks value in inode.
      
      This patch changes to count all blocks into inode.i_blocks excluding
      inode block, for on-disk i_blocks, we keep counting inode block for
      backward compatibility.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      000519f2
  19. 04 7月, 2017 2 次提交
    • C
      f2fs: measure inode.i_blocks as generic filesystem · 0eb0adad
      Chao Yu 提交于
      Both in memory or on disk, generic filesystems record i_blocks with
      512bytes sized sector count, also VFS sub module such as disk quota
      follows this rule, but f2fs records it with 4096bytes sized block
      count, this difference leads to that once we use dquota's function
      which inc/dec iblocks, it will make i_blocks of f2fs being inconsistent
      between in memory and on disk.
      
      In order to resolve this issue, this patch changes to make in-memory
      i_blocks of f2fs recording sector count instead of block count,
      meanwhile leaving on-disk i_blocks recording block count.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0eb0adad
    • J
      f2fs: remove false-positive bug_on · d8c4256c
      Jaegeuk Kim 提交于
      For example,
      
      f2fs_create
       - new_node_page is failed
       - handle_failed_inode
        - skip to add it into orphan list, since ni.blk_addr == NULL_ADDR
         : set_inode_flag(inode, FI_FREE_NID)
      
      f2fs_evict_inode
       - EIO due to fault injection
       - f2fs_bug_on() is triggered
      
      So, we don't need to call f2fs_bug_on in this case.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      d8c4256c
  20. 24 5月, 2017 1 次提交
    • J
      f2fs: load inode's flag from disk · 93607124
      Jaegeuk Kim 提交于
      This patch fixes missing inode flag loaded from disk, reported by Tom.
      
      [tom@localhost ~]$ sudo mount /dev/loop0 /mnt/
      [tom@localhost ~]$ sudo chown tom:tom /mnt/
      [tom@localhost ~]$ touch /mnt/testfile
      [tom@localhost ~]$ sudo chattr +i /mnt/testfile
      [tom@localhost ~]$ echo test > /mnt/testfile
      bash: /mnt/testfile: Operation not permitted
      [tom@localhost ~]$ rm /mnt/testfile
      rm: cannot remove '/mnt/testfile': Operation not permitted
      [tom@localhost ~]$ sudo umount /mnt/
      [tom@localhost ~]$ sudo mount /dev/loop0 /mnt/
      [tom@localhost ~]$ lsattr /mnt/testfile
      ----i-------------- /mnt/testfile
      [tom@localhost ~]$ echo test > /mnt/testfile
      [tom@localhost ~]$ rm /mnt/testfile
      [tom@localhost ~]$ sudo umount /mnt/
      
      Cc: stable@vger.kernel.org
      Reported-by: NTom Yan <tom.ty89@outlook.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      93607124
  21. 25 4月, 2017 1 次提交
    • J
      f2fs: fix out-of free segments · a7881893
      Jaegeuk Kim 提交于
      This patch also reverts d0db7703 ("f2fs: do SSR in higher priority").
      
      This patch fixes out of free segments caused by many small file creation by
      1) mkfs -s 1 2G
      2) mount
      3) untar
       - preoduce 60000 small files burstly
      4) sync
       - flush node pages
       - flush imeta
      
      Here, when we do f2fs_balance_fs, we missed # of imeta blocks, resulting in
      skipping to check has_not_enough_free_secs.
      
      Another test is done by
      1) mkfs -s 12 2G
      2) mount
      3) untar
       - preoduce 60000 small files burstly
      4) sync
       - flush node pages
       - flush imeta
      
      In this case, this patch also fixes wrong block allocation under large section
      size.
      Reported-by: NWilliam Brana <wbrana@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      a7881893
  22. 13 4月, 2017 1 次提交
    • J
      f2fs: fix fs corruption due to zero inode page · 9bb02c36
      Jaegeuk Kim 提交于
      This patch fixes the following scenario.
      
      - f2fs_create/f2fs_mkdir             - write_checkpoint
       - f2fs_mark_inode_dirty_sync         - block_operations
                                             - f2fs_lock_all
                                             - f2fs_sync_inode_meta
                                              - f2fs_unlock_all
                                              - sync_inode_metadata
       - f2fs_lock_op
                                               - f2fs_write_inode
                                                - update_inode_page
                                                 - get_node_page
                                                   return -ENOENT
       - new_inode_page
        - fill_node_footer
       - f2fs_mark_inode_dirty_sync
       - ...
       - f2fs_unlock_op
                                                - f2fs_inode_synced
                                             - f2fs_lock_all
                                             - do_checkpoint
      
      In this checkpoint, we can get an inode page which contains zeros having valid
      node footer only.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      9bb02c36
  23. 22 3月, 2017 2 次提交
  24. 28 2月, 2017 1 次提交
  25. 24 11月, 2016 5 次提交
  26. 01 10月, 2016 1 次提交
    • C
      f2fs: support configuring fault injection per superblock · 1ecc0c5c
      Chao Yu 提交于
      Previously, we only support global fault injection configuration, so that
      when we configure type/rate of fault injection through sysfs, mount
      option, it will influence all f2fs partition which is being used.
      
      It is not make sence, since it will be not convenient if developer want
      to test separated partitions with different fault injection rate/type
      simultaneously, also it's not possible to enable fault injection in one
      partition and disable fault injection in other one.
      
      >From now on, we move global configuration of fault injection in module
      into per-superblock, hence injection testing can be more flexible.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      1ecc0c5c
  27. 14 9月, 2016 1 次提交
  28. 09 7月, 2016 1 次提交
  29. 07 7月, 2016 1 次提交
  30. 08 6月, 2016 2 次提交