1. 21 8月, 2015 1 次提交
    • J
      f2fs: handle failed bio allocation · 740432f8
      Jaegeuk Kim 提交于
      As the below comment of bio_alloc_bioset, f2fs can allocate multiple bios at the
      same time. So, we can't guarantee that bio is allocated all the time.
      
      "
       *   When @bs is not NULL, if %__GFP_WAIT is set then bio_alloc will always be
       *   able to allocate a bio. This is due to the mempool guarantees. To make this
       *   work, callers must never allocate more than 1 bio at a time from this pool.
       *   Callers that need to allocate more than 1 bio must always submit the
       *   previously allocated bio for IO before attempting to allocate a new one.
       *   Failure to do so can cause deadlocks under memory pressure.
      "
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      740432f8
  2. 12 8月, 2015 2 次提交
    • C
      f2fs: remove inmem radix tree · decd36b6
      Chao Yu 提交于
      Previously, we use radix tree to index all registered page entries for
      atomic file, but now we only use radix tree to see whether current page
      is indexed or not, since the other user of radix tree is gone in commit
      042b7816 ("f2fs: remove unnecessary call to invalidate inmemory pages").
      
      So in this patch, we try to use one more efficient way:
      Introducing a macro ATOMIC_WRITTEN_PAGE, and setting it as page private
      value to indicate page indexing status. By using this way, we can save
      memory and lookup time.
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      decd36b6
    • C
      f2fs: report EINVAL for unalignment direct IO · c15e8599
      Chao Yu 提交于
      We run ltp testcase with f2fs and obtain a TFAIL in diotest4, the result in
      detail is as fallow:
      
      dio04
      
      <<<test_start>>>
      tag=dio04 stime=1432278894
      cmdline="diotest4"
      contacts=""
      analysis=exit
      <<<test_output>>>
      diotest4    1  TPASS  :  Negative Offset
      diotest4    2  TPASS  :  removed
      diotest4    3  TFAIL  :  diotest4.c:129: write allows odd count.returns 1: Success
      diotest4    4  TFAIL  :  diotest4.c:183: Odd count of read and write
      diotest4    5  TPASS  :  Read beyond the file size
      ......
      
      the result of ext4 with same environment:
      
      dio04
      
      <<<test_start>>>
      tag=dio04 stime=1432259643
      cmdline="diotest4"
      contacts=""
      analysis=exit
      <<<test_output>>>
      diotest4    1  TPASS  :  Negative Offset
      diotest4    2  TPASS  :  removed
      diotest4    3  TPASS  :  Odd count of read and write
      diotest4    4  TPASS  :  Read beyond the file size
      ......
      
      The reason is that when triggering DIO in f2fs, we will return zero value
      in ->direct_IO if writer's buffer offset, file offset and transfer size is
      not alignment to block size of filesystem, resulting in falling back into
      buffered write instead of returning -EINVAL.
      
      This patch fixes that problem by returning correct error number for above
      case, and removing the judgement condition in check_direct_IO to make sure
      the verification will be enabled for direct reader too.
      
      Besides, Jaegeuk Kim pointed out that there is expectional cases we should
      always make direct-io falling back into buffered write, such as dio in
      encrypted file.
      Signed-off-by: NYunlei He <heyunlei@huawei.com>
      [Chao Yu make small change and add detail description in commit message]
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      c15e8599
  3. 06 8月, 2015 1 次提交
  4. 05 8月, 2015 17 次提交
    • C
      f2fs: fix to release inode page correctly · 470f00e9
      Chao Yu 提交于
      In following call path, we will pass a locked and referenced ipage
      pointer to get_new_data_page:
       - init_inode_metadata
        - make_empty_dir
         - get_new_data_page
      
      There are two exit paths in get_new_data_page when error occurs:
      1) grab_cache_page fails, ipage will not be released;
      2) f2fs_reserve_block fails, ipage will be released in callee.
      
      So, it's not consistent for error handling in get_new_data_page.
      
      For f2fs_reserve_block, it's not very easy to change the rule
      of error handling, since it's already complicated.
      
      Here we deside to choose an easy way to fix this issue:
      If any error occur in get_new_data_page, we will ensure releasing
      ipage in this function.
      
      The same issue is in f2fs_convert_inline_dir, fix that too.
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      470f00e9
    • F
      f2fs: change the timing of f2fs_wait_on_page_writeback · 5768dcdd
      Fan Li 提交于
      some backing devices need pages to be stable during writeback. It doesn't
      matter if
      the page is completely overwritten or already uptodate, it needs to wait
      before write.
      Signed-off-by: NFan li <fanofcode.li@samsung.com>
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      5768dcdd
    • C
      f2fs: skip writing in ->writepages when no dirty pages exist · 6a290544
      Chao Yu 提交于
      When flushing comes from background, if there is no dirty page in the
      mapping of inode, we'd better to skip seeking dirty page from mapping
      for writebacking.
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6a290544
    • T
      f2fs: optimize f2fs_write_cache_pages · 737f1899
      Tiezhu Yang 提交于
      The if statement "goto continue_unlock" is exactly the same when
      each if condition is true that is depended on the value of both
      "step" and "is_cold_data(page)" are 0 or 1. That means when the
      value of "step" equals to "is_cold_data(page)", the if condition
      is true and the if statement "goto continue_unlock" appears only
      once, so it can be optimized to reduce the duplicated code.
      Signed-off-by: NTiezhu Yang <kernelpatch@126.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      737f1899
    • J
      f2fs: callers take care of the page from bio error · 86531d6b
      Jaegeuk Kim 提交于
      This patch changes for a caller to handle the page after its bio gets an error.
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      86531d6b
    • C
      f2fs: expose f2fs_write_cache_pages · 8f46dcae
      Chao Yu 提交于
      If there are gced dirty pages and normal dirty pages in the mapping
      of one inode, we might writeback them alternately with discontinuous
      block address, resulting in low performance.
      
      This patch introduces f2fs_write_cache_pages with codes copied from
      write_cache_pages in mm/page-writeback.c.
      
      In this function, we refactor flow with two steps:
      1) writeback all cold type pages.
      2) writeback all non-cold type pages.
      
      By using this method, f2fs will writeback dirty pages with the same
      temperature in bunch mode, it makes writeouted block being with
      more continuous address, so they can be merged as much as possible
      in f2fs bio cache, and also it will reduce the chance of submiting
      small IO from block layer.
      
      Test environment: 8g nokia sd card (very old sd card, but it shows
      better effect when testing with this patch, and with a 32g kingston
      sd card, I didn't see much more improvement).
      
      Test step:
      1. touch testfile;
      2. truncate -s 512K testfile;
      3. write all pages with odd index;
      4. trigger gc by ioctl;
      5. write all pages with even index;
      6. time fsync testfile.
      
      before:
      real	0m0.402s
      user	0m0.000s
      sys	0m0.000s
      
      after:
      real	0m0.143s
      user	0m0.004s
      sys	0m0.004s
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      8f46dcae
    • C
      f2fs: maintain extent cache in separated file · a28ef1f5
      Chao Yu 提交于
      This patch moves extent cache related code from data.c into extent_cache.c
      since extent cache is independent feature, and its codes are not relate to
      others in data.c, it's better for us to maintain them in separated place.
      
      There is no functionality change, but several small coding style fixes
      including:
      * rename __drop_largest_extent to f2fs_drop_largest_extent for exporting;
      * rename misspelled word 'untill' to 'until';
      * remove unneeded 'return' in the end of f2fs_destroy_extent_tree().
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      a28ef1f5
    • F
      f2fs: don't try to split extents shorter than F2FS_MIN_EXTENT_LEN · 3c7df87d
      Fan Li 提交于
      Since only parts of extents longer than F2FS_MIN_EXTENT_LEN will
      be kept in extent cache after split, extents already shorter than
      F2FS_MIN_EXTENT_LEN don't need to try split at all.
      Signed-off-by: NFan Li <fanofcode.li@samsung.com>
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      3c7df87d
    • C
      f2fs: fix to update page flag · 90d4388a
      Chao Yu 提交于
      This patch fixes to update page flag (e.g. Uptodate/cold flag) in
      ->write_begin.
      
      Otherwise, page will be non-uptodate when we try to write entire
      page, and cold data flag in page will not be clean when gced page
      is being rewritten.
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      90d4388a
    • J
      f2fs: shrink unreferenced extent_caches first · 7023a1ad
      Jaegeuk Kim 提交于
      If an extent_tree entry has a zero reference count, we can drop it from the
      cache in higher priority rather than currently referencing entries.
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7023a1ad
    • C
      f2fs: enhance multithread performance · bb96a8d5
      Chao Yu 提交于
      In ->writepages, we use writepages mutex lock to serialize all block
      address allocation and page submitting pairs from different inodes.
      This method makes our delayed dirty pages of one inode being written
      continously as many as possible.
      
      But there is one problem that we did not submit current cached bio in
      protection region of writepages mutex lock, so there is a small chance
      that we submit the one of other thread's as below, resulting in
      splitting more bios.
      
      thread 1			thread 2
      ->writepages
        lock(writepages)
        ->write_cache_pages
        unlock(writepages)
      				  lock(writepages)
      				  ->write_cache_pages
        ->f2fs_submit_merged_bio
      				    ->writepage
      				  unlock(writepages)
      
      fs_mark-6535  [002] ....  2242.270230: f2fs_submit_write_bio: dev = (1,0), WRITE_SYNC, DATA, sector = 5766152, size = 524288
      fs_mark-6536  [000] ....  2242.270361: f2fs_submit_write_bio: dev = (1,0), WRITE_SYNC, DATA, sector = 5767176, size = 4096
      fs_mark-6536  [000] ....  2242.270370: f2fs_submit_write_bio: dev = (1,0), WRITE_SYNC, NODE, sector = 8138112, size = 4096
      fs_mark-6535  [002] ....  2242.270776: f2fs_submit_write_bio: dev = (1,0), WRITE_SYNC, DATA, sector = 5767184, size = 516096
      
      This may really increase time of block layer works, and may cause
      larger IO lantency.
      
      This patch moves the submitting operation into region of writepages
      mutex lock to avoid bio splits when concurrently writebacking is
      intensive.
      
      my test environment: virtual machine,
      intel cpu i5 2500, 8GB size memory, 4GB size ramdisk
      
      time fs_mark  -t  16  -L  1  -s  524288  -S  1  -d  /mnt/f2fs/
      
      before:
      real	0m4.244s
      user	0m0.088s
      sys	0m12.336s
      
      after:
      real	0m3.822s
      user	0m0.072s
      sys	0m10.760s
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      bb96a8d5
    • J
      f2fs: check the largest extent at look-up time · 84bc926c
      Jaegeuk Kim 提交于
      Because of the extent shrinker or other -ENOMEM scenarios, it cannot guarantee
      that the largest extent would be cached in the tree all the time.
      
      Instead of relying on extent_tree, we can simply check the cached one in extent
      tree accordingly.
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      84bc926c
    • J
      f2fs: use extent_cache by default · 3e72f721
      Jaegeuk Kim 提交于
      We don't need to handle the duplicate extent information.
      
      The integrated rule is:
       - update on-disk extent with largest one tracked by in-memory extent_cache
       - destroy extent_tree for the truncation case
       - drop per-inode extent_cache by shrinker
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      3e72f721
    • J
      f2fs: shrink extent_cache entries · 554df79e
      Jaegeuk Kim 提交于
      This patch registers shrinking extent_caches.
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      554df79e
    • J
      f2fs: set cached_en after checking finally · 244f4fc1
      Jaegeuk Kim 提交于
      This patch relocates cached_en not only to be covered by spin_lock, but also
      to set once after checking out completely.
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      244f4fc1
    • J
      f2fs: update on-disk extents even under extent_cache · cbe91923
      Jaegeuk Kim 提交于
      Previously, f2fs_update_extent_cache() updates in-memory extent_cache all the
      time, and then finally preserves its up-to-date extent into on-disk one during
      f2fs_evict_inode.
      
      But, in the following scenario:
      
      1. mount
      2. open & write an extent X
      3. f2fs_evict_inode; on-disk extent is X
      4. open & update the extent X with Y
      5. sync; trigger checkpoint
      6. power-cut
      
      after power-on, f2fs should serve extent Y, but we have an on-disk extent X.
      
      This causes a failure on xfstests/311.
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      cbe91923
    • J
      f2fs: fix wrong block address calculation for a split extent · 7a2cb678
      Jaegeuk Kim 提交于
      This patch fixes wrong calculation on block address field when an extent is
      split.
      Reviewed-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7a2cb678
  5. 25 7月, 2015 1 次提交
    • J
      f2fs: call set_page_dirty to attach i_wb for cgroup · 6282adbf
      Jaegeuk Kim 提交于
      The cgroup attaches inode->i_wb via mark_inode_dirty and when set_page_writeback
      is called, __inc_wb_stat() updates i_wb's stat.
      
      So, we need to explicitly call set_page_dirty->__mark_inode_dirty in prior to
      any writebacking pages.
      
      This patch should resolve the following kernel panic reported by Andreas Reis.
      
      https://bugzilla.kernel.org/show_bug.cgi?id=101801
      
      --- Comment #2 from Andreas Reis <andreas.reis@gmail.com> ---
      BUG: unable to handle kernel NULL pointer dereference at 00000000000000a8
      IP: [<ffffffff8149deea>] __percpu_counter_add+0x1a/0x90
      PGD 2951ff067 PUD 2df43f067 PMD 0
      Oops: 0000 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 7 PID: 10356 Comm: gcc Tainted: G        W       4.2.0-1-cu #1
      Hardware name: Gigabyte Technology Co., Ltd. G1.Sniper M5/G1.Sniper M5, BIOS
      T01 02/03/2015
      task: ffff880295044f80 ti: ffff880295140000 task.ti: ffff880295140000
      RIP: 0010:[<ffffffff8149deea>]  [<ffffffff8149deea>]
      __percpu_counter_add+0x1a/0x90
      RSP: 0018:ffff880295143ac8  EFLAGS: 00010082
      RAX: 0000000000000003 RBX: ffffea000a526d40 RCX: 0000000000000001
      RDX: 0000000000000020 RSI: 0000000000000001 RDI: 0000000000000088
      RBP: ffff880295143ae8 R08: 0000000000000000 R09: ffff88008f69bb30
      R10: 00000000fffffffa R11: 0000000000000000 R12: 0000000000000088
      R13: 0000000000000001 R14: ffff88041d099000 R15: ffff880084a205d0
      FS:  00007f8549374700(0000) GS:ffff88042f3c0000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000000000a8 CR3: 000000033e1d5000 CR4: 00000000001406e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Stack:
       0000000000000000 ffffea000a526d40 ffff880084a20738 ffff880084a20750
       ffff880295143b48 ffffffff811cc91e ffff880000000000 0000000000000296
       0000000000000000 ffff880417090198 0000000000000000 ffffea000a526d40
      Call Trace:
       [<ffffffff811cc91e>] __test_set_page_writeback+0xde/0x1d0
       [<ffffffff813fee87>] do_write_data_page+0xe7/0x3a0
       [<ffffffff813faeea>] gc_data_segment+0x5aa/0x640
       [<ffffffff813fb0b8>] do_garbage_collect+0x138/0x150
       [<ffffffff813fb3fe>] f2fs_gc+0x1be/0x3e0
       [<ffffffff81405541>] f2fs_balance_fs+0x81/0x90
       [<ffffffff813ee357>] f2fs_unlink+0x47/0x1d0
       [<ffffffff81239329>] vfs_unlink+0x109/0x1b0
       [<ffffffff8123e3d7>] do_unlinkat+0x287/0x2c0
       [<ffffffff8123ebc6>] SyS_unlink+0x16/0x20
       [<ffffffff81942e2e>] entry_SYSCALL_64_fastpath+0x12/0x71
      Code: 41 5e 5d c3 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 41 55 49
      89 f5 41 54 49 89 fc 53 48 83 ec 08 65 ff 05 e6 d9 b6 7e <48> 8b 47 20 48 63 ca
      65 8b 18 48 63 db 48 01 f3 48 39 cb 7d 0a
      RIP  [<ffffffff8149deea>] __percpu_counter_add+0x1a/0x90
       RSP <ffff880295143ac8>
      CR2: 00000000000000a8
      ---[ end trace 5132449a58ed93a3 ]---
      note: gcc[10356] exited with preempt_count 2
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6282adbf
  6. 02 6月, 2015 1 次提交
  7. 29 5月, 2015 8 次提交
    • J
      f2fs crypto: add encryption support in read/write paths · 4375a336
      Jaegeuk Kim 提交于
      This patch adds encryption support in read and write paths.
      
      Note that, in f2fs, we need to consider cleaning operation.
      In cleaning procedure, we must avoid encrypting and decrypting written blocks.
      So, this patch implements move_encrypted_block().
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      4375a336
    • J
      f2fs crypto: activate encryption support for fs APIs · fcc85a4d
      Jaegeuk Kim 提交于
      This patch activates the following APIs for encryption support.
      
      The rules quoted by ext4 are:
       - An unencrypted directory may contain encrypted or unencrypted files
         or directories.
       - All files or directories in a directory must be protected using the
         same key as their containing directory.
       - Encrypted inode for regular file should not have inline_data.
       - Encrypted symlink and directory may have inline_data and inline_dentry.
      
      This patch activates the following APIs.
      1. f2fs_link              : validate context
      2. f2fs_lookup            :      ''
      3. f2fs_rename            :      ''
      4. f2fs_create/f2fs_mkdir : inherit its dir's context
      5. f2fs_direct_IO         : do buffered io for regular files
      6. f2fs_open              : check encryption info
      7. f2fs_file_mmap         :      ''
      8. f2fs_setattr           :      ''
      9. f2fs_file_write_iter   :      ''           (Called by sys_io_submit)
      10. f2fs_fallocate        : do not support fcollapse
      11. f2fs_evict_inode      : free_encryption_info
      Signed-off-by: NMichael Halcrow <mhalcrow@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      fcc85a4d
    • J
      f2fs: report unwritten area in f2fs_fiemap · 7f63eb77
      Jaegeuk Kim 提交于
      This patch slightly changes f2fs_fiemap function to report unwritten area.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7f63eb77
    • J
      f2fs: split find_data_page according to specific purposes · 43f3eae1
      Jaegeuk Kim 提交于
      This patch splits find_data_page as follows.
      
      1. f2fs_gc
       - use get_read_data_page() with read only
      
      2. find_in_level
       - use find_data_page without locked page
      
      3. truncate_partial_page
       - In the case cache_only mode, just drop cached page.
       - Ohterwise, use get_lock_data_page() and guarantee to truncate
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      43f3eae1
    • J
      f2fs: fix race on allocating and deallocating a dentry block · 01f28610
      Jaegeuk Kim 提交于
      There are two threads:
       f2fs_delete_entry()              get_new_data_page()
                                        f2fs_reserve_block()
      				  dn.blkaddr = XXX
       lock_page(dentry_block)
       truncate_hole()
       dn.blkaddr = NULL
       unlock_page(dentry_block)
                                        lock_page(dentry_block)
                                        fill the block from XXX address
                                        add new dentries
                                        unlock_page(dentry_block)
      
      Later, f2fs_write_data_page() will truncate the dentry_block, since
      its block address is NULL.
      
      The reason for this was due to the wrong lock order.
      In this case, we should do f2fs_reserve_block() after locking its dentry block.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      01f28610
    • J
      f2fs: add sbi and page pointer in f2fs_io_info · 05ca3632
      Jaegeuk Kim 提交于
      This patch adds f2fs_sb_info and page pointers in f2fs_io_info structure.
      With this change, we can reduce a lot of parameters for IO functions.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      05ca3632
    • J
      f2fs: expose f2fs_mpage_readpages · f1e88660
      Jaegeuk Kim 提交于
      This patch implements f2fs_mpage_readpages for further optimization on
      encryption support.
      
      The basic code was taken from fs/mpage.c, and changed to be simple by adjusting
      that block_size is equal to page_size in f2fs.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      f1e88660
    • J
      f2fs: add f2fs_map_blocks · 003a3e1d
      Jaegeuk Kim 提交于
      This patch introduces f2fs_map_blocks structure likewise ext4_map_blocks.
      Now, f2fs uses f2fs_map_blocks when handling get_block.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      003a3e1d
  8. 05 5月, 2015 1 次提交
  9. 12 4月, 2015 3 次提交
  10. 11 4月, 2015 5 次提交
    • C
      f2fs: limit b_size of mapped bh in f2fs_map_bh · 1b3e27a9
      Chao Yu 提交于
      Map bh over max size which caller defined is not needed, limit it in
      f2fs_map_bh.
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      1b3e27a9
    • C
      f2fs: preallocate fallocated blocks for direct IO · df6136ef
      Chao Yu 提交于
      Normally, due to DIO_SKIP_HOLES flag is set by default, blockdev_direct_IO in
      f2fs_direct_IO tries to skip DIO in holes when writing inside i_size, this
      makes us falling back to buffered IO which shows lower performance.
      
      So in commit 59b802e5 ("f2fs: allocate data blocks in advance for
      f2fs_direct_IO"), we improve perfromance by allocating data blocks in advance
      if we meet holes no matter in i_size or not, since with it we can avoid falling
      back to buffered IO.
      
      But we forget to consider for unwritten fallocated block in this commit.
      This patch tries to fix it for fallocate case, this helps to improve
      performance.
      
      Test result:
      Storage info: sandisk ultra 64G micro sd card.
      
      touch /mnt/f2fs/file
      truncate -s 67108864 /mnt/f2fs/file
      fallocate -o 0 -l 67108864 /mnt/f2fs/file
      time dd if=/dev/zero of=/mnt/f2fs/file bs=1M count=64 conv=notrunc oflag=direct
      
      Time before applying the patch:
      67108864 bytes (67 MB) copied, 36.16 s, 1.9 MB/s
      real    0m36.162s
      user    0m0.000s
      sys     0m0.180s
      
      Time after applying the patch:
      67108864 bytes (67 MB) copied, 27.7776 s, 2.4 MB/s
      real    0m27.780s
      user    0m0.000s
      sys     0m0.036s
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      df6136ef
    • C
      f2fs: preserve extent info for extent cache · 0bdee482
      Chao Yu 提交于
      This patch tries to preserve last extent info in extent tree cache into on-disk
      inode, so this can help us to reuse the last extent info next time for
      performance.
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0bdee482
    • C
      f2fs: initialize extent tree with on-disk extent info of inode · 028a41e8
      Chao Yu 提交于
      With normal extent info cache, we records largest extent mapping between logical
      block and physical block into extent info, and we persist extent info in on-disk
      inode.
      
      When we enable extent tree cache, if extent info of on-disk inode is exist, and
      the extent is not a small fragmented mapping extent. We'd better to load the
      extent info into extent tree cache when inode is loaded. By this way we can have
      more chance to hit extent tree cache rather than taking more time to read dnode
      page for block address.
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      028a41e8
    • C
      f2fs: introduce __{find,grab}_extent_tree · 93dfc526
      Chao Yu 提交于
      This patch introduces __{find,grab}_extent_tree for reusing by following
      patches.
      Signed-off-by: NChao Yu <chao2.yu@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      93dfc526