1. 03 5月, 2018 3 次提交
    • J
      f2fs: check cap_resource only for data blocks · a90a0884
      Jaegeuk Kim 提交于
      This patch changes the rule to check cap_resource for data blocks, not inode
      or node blocks in order to avoid selinux denial.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      a90a0884
    • J
      Revert "f2fs: introduce f2fs_set_page_dirty_nobuffer" · b87078ad
      Jaegeuk Kim 提交于
      This patch reverts copied f2fs_set_page_dirty_nobuffer to use generic function
      for stability.
      
      This reverts commit fe76b796.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      b87078ad
    • E
      f2fs: refactor read path to allow multiple postprocessing steps · 6dbb1796
      Eric Biggers 提交于
      Currently f2fs's ->readpage() and ->readpages() assume that either the
      data undergoes no postprocessing, or decryption only.  But with
      fs-verity, there will be an additional authenticity verification step,
      and it may be needed either by itself, or combined with decryption.
      
      To support this, store a 'struct bio_post_read_ctx' in ->bi_private
      which contains a work struct, a bitmask of postprocessing steps that are
      enabled, and an indicator of the current step.  The bio completion
      routine, if there was no I/O error, enqueues the first postprocessing
      step.  When that completes, it continues to the next step.  Pages that
      fail any postprocessing step have PageError set.  Once all steps have
      completed, pages without PageError set are set Uptodate, and all pages
      are unlocked.
      
      Also replace f2fs_encrypted_file() with a new function
      f2fs_post_read_required() in places like direct I/O and garbage
      collection that really should be testing whether the file needs special
      I/O processing, not whether it is encrypted specifically.
      
      This may also be useful for other future f2fs features such as
      compression.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6dbb1796
  2. 04 4月, 2018 1 次提交
  3. 03 4月, 2018 2 次提交
  4. 29 3月, 2018 1 次提交
    • E
      f2fs: reserve bits for fs-verity · 53fedcc0
      Eric Biggers 提交于
      Reserve an F2FS feature flag and inode flag for fs-verity.  This is an
      in-development feature that is planned be discussed at LSF/MM 2018 [1].
      It will provide file-based integrity and authenticity for read-only
      files.  Most code will be in a filesystem-independent module, with
      smaller changes needed to individual filesystems that opt-in to
      supporting the feature.  An early prototype supporting F2FS is available
      [2].  Reserving the F2FS on-disk bits for fs-verity will prevent users
      of the prototype from conflicting with other new F2FS features.
      
      Note that we're reserving the inode flag in f2fs_inode.i_advise, which
      isn't really appropriate since it's not a hint or advice.  But
      ->i_advise is already being used to hold the 'encrypt' flag; and F2FS's
      ->i_flags uses the generic FS_* values, so it seems ->i_flags can't be
      used for an F2FS-specific flag without additional work to remove the
      assumption that ->i_flags uses the generic flags namespace.
      
      [1] https://marc.info/?l=linux-fsdevel&m=151690752225644
      [2] https://git.kernel.org/pub/scm/linux/kernel/git/mhalcrow/linux.git/log/?h=fs-verity-devSigned-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      53fedcc0
  5. 19 3月, 2018 1 次提交
  6. 17 3月, 2018 8 次提交
  7. 13 3月, 2018 9 次提交
    • C
      f2fs: support hot file extension · b6a06cbb
      Chao Yu 提交于
      This patch supports to recognize hot file extension in f2fs, so that we
      can allocate proper hot segment location for its data, which can lead to
      better hot/cold seperation in filesystem.
      
      In addition, we changes a bit on query/add/del operation method for
      extension_list sysfs entry as below:
      
      - Query: cat /sys/fs/f2fs/<disk>/extension_list
      - Add: echo 'extension' > /sys/fs/f2fs/<disk>/extension_list
      - Del: echo '!extension' > /sys/fs/f2fs/<disk>/extension_list
      - Add: echo '[h/c]extension' > /sys/fs/f2fs/<disk>/extension_list
      - Del: echo '[h/c]!extension' > /sys/fs/f2fs/<disk>/extension_list
      - [h] means add/del hot file extension
      - [c] means add/del cold file extension
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      b6a06cbb
    • J
      f2fs: add mount option for segment allocation policy · 07939627
      Jaegeuk Kim 提交于
      This patch adds an mount option, "alloc_mode=%s" having two options, "default"
      and "reuse".
      
      In "alloc_mode=reuse" case, f2fs starts to allocate segments from 0'th segment
      all the time to reassign segments. It'd be useful for small-sized eMMC parts.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      07939627
    • C
      f2fs: expose extension_list sysfs entry · 846ae671
      Chao Yu 提交于
      This patch adds a sysfs entry 'extension_list' to support
      query/add/del item in extension list.
      
      Query:
      cat /sys/fs/f2fs/<device>/extension_list
      
      Add:
      echo 'extension' > /sys/fs/f2fs/<device>/extension_list
      
      Del:
      echo '!extension' > /sys/fs/f2fs/<device>/extension_list
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      846ae671
    • C
      f2fs: introduce sb_lock to make encrypt pwsalt update exclusive · d0d3f1b3
      Chao Yu 提交于
      f2fs_super_block.encrypt_pw_salt can be udpated and persisted
      concurrently, result in getting different pwsalt in separated
      threads, so let's introduce sb_lock to exclude concurrent
      accessers.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      d0d3f1b3
    • S
      f2fs: clean up f2fs_sb_has_xxx functions · ccd31cb2
      Sheng Yong 提交于
      This patch introduces F2FS_FEATURE_FUNCS to clean up the definitions of
      different f2fs_sb_has_xxx functions.
      Signed-off-by: NSheng Yong <shengyong1@huawei.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      ccd31cb2
    • H
      f2fs: support passing down write hints to block layer with F2FS policy · f2e703f9
      Hyunchul Lee 提交于
      Add 'whint_mode=fs-based' mount option. In this mode, F2FS passes
      down write hints with its policy.
      
      * whint_mode=fs-based. F2FS passes down hints with its policy.
      
      User                  F2FS                     Block
      ----                  ----                     -----
                            META                     WRITE_LIFE_MEDIUM;
                            HOT_NODE                 WRITE_LIFE_NOT_SET
                            WARM_NODE                "
                            COLD_NODE                WRITE_LIFE_NONE
      ioctl(COLD)           COLD_DATA                WRITE_LIFE_EXTREME
      extension list        "                        "
      
      -- buffered io
      WRITE_LIFE_EXTREME    COLD_DATA                WRITE_LIFE_EXTREME
      WRITE_LIFE_SHORT      HOT_DATA                 WRITE_LIFE_SHORT
      WRITE_LIFE_NOT_SET    WARM_DATA                WRITE_LIFE_LONG
      WRITE_LIFE_NONE       "                        "
      WRITE_LIFE_MEDIUM     "                        "
      WRITE_LIFE_LONG       "                        "
      
      -- direct io
      WRITE_LIFE_EXTREME    COLD_DATA                WRITE_LIFE_EXTREME
      WRITE_LIFE_SHORT      HOT_DATA                 WRITE_LIFE_SHORT
      WRITE_LIFE_NOT_SET    WARM_DATA                WRITE_LIFE_NOT_SET
      WRITE_LIFE_NONE       "                        WRITE_LIFE_NONE
      WRITE_LIFE_MEDIUM     "                        WRITE_LIFE_MEDIUM
      WRITE_LIFE_LONG       "                        WRITE_LIFE_LONG
      
      Many thanks to Chao Yu and Jaegeuk Kim for comments to
      implement this patch.
      Signed-off-by: NHyunchul Lee <cheol.lee@lge.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      f2e703f9
    • H
      f2fs: support passing down write hints given by users to block layer · 0cdd3195
      Hyunchul Lee 提交于
      Add the 'whint_mode' mount option that controls which write
      hints are passed down to block layer. There are "off" and
      "user-based" mode. The default mode is "off".
      
      1) whint_mode=off. F2FS only passes down WRITE_LIFE_NOT_SET.
      
      2) whint_mode=user-based. F2FS tries to pass down hints given
      by users.
      
      User                  F2FS                     Block
      ----                  ----                     -----
                            META                     WRITE_LIFE_NOT_SET
                            HOT_NODE                 "
                            WARM_NODE                "
                            COLD_NODE                "
      ioctl(COLD)           COLD_DATA                WRITE_LIFE_EXTREME
      extension list        "                        "
      
      -- buffered io
      WRITE_LIFE_EXTREME    COLD_DATA                WRITE_LIFE_EXTREME
      WRITE_LIFE_SHORT      HOT_DATA                 WRITE_LIFE_SHORT
      WRITE_LIFE_NOT_SET    WARM_DATA                WRITE_LIFE_NOT_SET
      WRITE_LIFE_NONE       "                        "
      WRITE_LIFE_MEDIUM     "                        "
      WRITE_LIFE_LONG       "                        "
      
      -- direct io
      WRITE_LIFE_EXTREME    COLD_DATA                WRITE_LIFE_EXTREME
      WRITE_LIFE_SHORT      HOT_DATA                 WRITE_LIFE_SHORT
      WRITE_LIFE_NOT_SET    WARM_DATA                WRITE_LIFE_NOT_SET
      WRITE_LIFE_NONE       "                        WRITE_LIFE_NONE
      WRITE_LIFE_MEDIUM     "                        WRITE_LIFE_MEDIUM
      WRITE_LIFE_LONG       "                        WRITE_LIFE_LONG
      
      Many thanks to Chao Yu and Jaegeuk Kim for comments to
      implement this patch.
      Signed-off-by: NHyunchul Lee <cheol.lee@lge.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: avoid build warning]
      [Chao Yu: fix to restore whint_mode in ->remount_fs]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0cdd3195
    • C
      f2fs: support large nat bitmap · 199bc3fe
      Chao Yu 提交于
      Previously, we will store all nat version bitmap in checkpoint pack block,
      so our total node entry number has a limitation which caused total node
      number can not exceed (3900 * 8) block * 455 node/block = 14196000. So
      that once user wants to create more nodes in large size image, it becomes
      a bottleneck, that's unreasonable.
      
      This patch detects the new layout of nat/sit version bitmap in image in
      order to enable supporting large nat bitmap.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      199bc3fe
    • Y
      f2fs: don't put dentry page in pagecache into highmem · bdbc90fa
      Yunlong Song 提交于
      Previous dentry page uses highmem, which will cause panic in platforms
      using highmem (such as arm), since the address space of dentry pages
      from highmem directly goes into the decryption path via the function
      fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not
      from highmem, and then cause panic since it doesn't call kmap_high but
      kunmap_high is triggered at the end. To fix this problem in a simple
      way, this patch avoids to put dentry page in pagecache into highmem.
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: fix coding style]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      bdbc90fa
  8. 26 1月, 2018 1 次提交
  9. 23 1月, 2018 6 次提交
  10. 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
  11. 17 1月, 2018 4 次提交
  12. 04 1月, 2018 1 次提交
  13. 03 1月, 2018 2 次提交
    • J
      f2fs: recover directory operations by fsync · 0a007b97
      Jaegeuk Kim 提交于
      This fixes generic/342 which doesn't recover renamed file which was fsynced
      before. It will be done via another fsync on newly created file.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0a007b97
    • 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