1. 23 Feb, 2016 18 commits
    • Hou Pengyang's avatar
      f2fs: reconstruct the code to free an extent_node · a03f01f2
      Hou Pengyang authored
      There are three steps to free an extent node:
      1) list_del_init, 2)__detach_extent_node, 3) kmem_cache_free
      
      In path f2fs_destroy_extent_tree, 1->2->3 to free a node,
      But in path f2fs_update_extent_tree_range, it is 2->1->3.
      
      This patch makes all the order to be: 1->2->3
      It makes sense, since in the next patch, we import a victim list in the
      path shrink_extent_tree, we could check if the extent_node is in the victim
      list by checking the list_empty(). So it is necessary to put 1) first.
      Signed-off-by: default avatarHou Pengyang <houpengyang@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      a03f01f2
    • Jaegeuk Kim's avatar
      f2fs: use wq_has_sleeper for cp_wait wait_queue · 7c506896
      Jaegeuk Kim authored
      We need to use wq_has_sleeper including smp_mb to consider cp_wait concurrency.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7c506896
    • Fan Li's avatar
      f2fs: avoid unnecessary search while finding victim in gc · 688159b6
      Fan Li authored
      variable nsearched in get_victim_by_default() indicates the number of
      dirty segments we already checked. There are 2 problems about the way
      it updates:
      1. When p.ofs_unit is greater than 1, the victim we find consists
         of multiple segments, possibly more than 1 dirty segment.
         But nsearched always increases by 1.
      2. If segments have been found but not been chosen, nsearched won't
         increase. So even we have checked all dirty segments, nsearched
         may still less than p.max_search.
      All these problems could cause unnecessary search after all dirty
      segments have already been checked.
      Signed-off-by: default avatarFan li <fanofcode.li@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      688159b6
    • Yunlei He's avatar
      f2fs: delete unnecessary wait for page writeback · 85ead818
      Yunlei He authored
      no need to wait inline file page writeback for no one
      use it, so this patch delete unnecessary wait.
      Signed-off-by: default avatarYunlei He <heyunlei@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      85ead818
    • Jaegeuk Kim's avatar
      f2fs: use wait_for_stable_page to avoid contention · fec1d657
      Jaegeuk Kim authored
      In write_begin, if storage supports stable_page, we don't need to wait for
      writeback to update its contents.
      This patch introduces to use wait_for_stable_page instead of
      wait_on_page_writeback.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      fec1d657
    • Chao Yu's avatar
      f2fs: enhance foreground GC · 718e53fa
      Chao Yu authored
      If we configure section consist of multiple segments, foreground GC will
      do the garbage collection with following approach:
      
      	for each segment in victim section
      		blk_start_plug
      		for each valid block in segment
      			write out by OPU method
      		submit bio cache   <---
      		blk_finish_plug   <---
      
      There are two issue:
      1) for most of the time, 'submit bio cache' will break the merging in
      current bio buffer from writes of next segments, making a smaller bio
      submitting.
      2) block plug only cover IO submitting in one segment, which reduce
      opportunity of merging IOs in plug with multiple segments.
      
      So refactor the code as below structure to strive for biggest
      opportunity of merging IOs:
      
      	blk_start_plug
      	for each segment in victim section
      		for each valid block in segment
      			write out by OPU method
      	submit bio cache
      	blk_finish_plug
      
      Test method:
      1. mkfs.f2fs -s 8 /dev/sdX
      2. touch 32 files
      3. write 2M data into each file
      4. punch 1.5M data from offset 0 for each file
      5. trigger foreground gc through ioctl
      
      Before patch, there are totoally 40 bios submitted.
      f2fs_submit_write_bio: dev = (8,32), WRITE_SYNC, DATA, sector = 65536, size = 122880
      f2fs_submit_write_bio: dev = (8,32), WRITE_SYNC, DATA, sector = 65776, size = 122880
      f2fs_submit_write_bio: dev = (8,32), WRITE_SYNC, DATA, sector = 66016, size = 122880
      f2fs_submit_write_bio: dev = (8,32), WRITE_SYNC, DATA, sector = 66256, size = 122880
      f2fs_submit_write_bio: dev = (8,32), WRITE_SYNC, DATA, sector = 66496, size = 32768
      ----repeat for 8 times
      
      After patch, there are totally 35 bios submitted.
      f2fs_submit_write_bio: dev = (8,32), WRITE_SYNC, DATA, sector = 65536, size = 122880
      ----repeat 34 times
      f2fs_submit_write_bio: dev = (8,32), WRITE_SYNC, DATA, sector = 73696, size = 16384
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      718e53fa
    • Jaegeuk Kim's avatar
      f2fs: don't need to call set_page_dirty for io error · e3ef1876
      Jaegeuk Kim authored
      If end_io gets an error, we don't need to set the page as dirty, since we
      already set f2fs_stop_checkpoint which will not flush any data.
      
      This will resolve the following warning.
      
      ======================================================
      [ INFO: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected ]
      4.4.0+ #9 Tainted: G           O
      ------------------------------------------------------
      xfs_io/26773 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
       (&(&sbi->inode_lock[i])->rlock){+.+...}, at: [<ffffffffc025483f>] update_dirty_page+0x6f/0xd0 [f2fs]
      
      and this task is already holding:
       (&(&q->__queue_lock)->rlock){-.-.-.}, at: [<ffffffff81396ea2>] blk_queue_bio+0x422/0x490
      which would create a new lock dependency:
       (&(&q->__queue_lock)->rlock){-.-.-.} -> (&(&sbi->inode_lock[i])->rlock){+.+...}
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e3ef1876
    • Jaegeuk Kim's avatar
      f2fs: avoid needless sync_inode_page when reading inline_data · ae96e7bd
      Jaegeuk Kim authored
      In write_begin, if there is an inline_data, f2fs loads it into 0'th data page.
      Since it's the read path, we don't need to sync its inode page.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      ae96e7bd
    • Jaegeuk Kim's avatar
      f2fs: don't need to sync node page at every time · 52f80337
      Jaegeuk Kim authored
      In write_end, we don't need to sync inode page at every time.
      Instead, we can expect f2fs_write_inode will update later.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      52f80337
    • Jaegeuk Kim's avatar
      f2fs: avoid multiple node page writes due to inline_data · 2049d4fc
      Jaegeuk Kim authored
      The sceanrio is:
      1. create fully node blocks
      2. flush node blocks
      3. write inline_data for all the node blocks again
      4. flush node blocks redundantly
      
      So, this patch tries to flush inline_data when flushing node blocks.
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2049d4fc
    • Jaegeuk Kim's avatar
      f2fs: do f2fs_balance_fs when block is allocated · 3c082b7b
      Jaegeuk Kim authored
      We should consider data block allocation to trigger f2fs_balance_fs.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      3c082b7b
    • Jaegeuk Kim's avatar
      f2fs: fix to overcome inline_data floods · 6e17bfbc
      Jaegeuk Kim authored
      The scenario is:
      1. create lots of node blocks
      2. sync
      3. write lots of inline_data
      -> got panic due to no free space
      
      In that case, we should flush node blocks when writing inline_data in #3,
      and trigger gc as well.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      6e17bfbc
    • Jaegeuk Kim's avatar
      f2fs: use writepages->lock for WB_SYNC_ALL · 25c13551
      Jaegeuk Kim authored
      If there are many writepages calls by multiple threads in background, we don't
      need to serialize to merge all the bios, since it's background.
      In such the case, it'd better to run writepages concurrently.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      25c13551
    • Jaegeuk Kim's avatar
      f2fs: remove needless condition check · b483fadf
      Jaegeuk Kim authored
      This patch removes needless condition variable.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      b483fadf
    • Chao Yu's avatar
      f2fs: correct search area in get_new_segment · 0ab14356
      Chao Yu authored
      get_new_segment starts from current segment position, tries to search a
      free segment among its right neighbors locate in same section.
      
      But previously our search area was set as [current segment, max segment],
      which means we have to search to more bits in free_segmap bitmap for some
      worse cases. So here we correct the search area to [current segment, last
      segment in section] to avoid unnecessary searching.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      0ab14356
    • Chao Yu's avatar
      f2fs: export dirty_nats_ratio in sysfs · 2304cb0c
      Chao Yu authored
      This patch exports a new sysfs entry 'dirty_nat_ratio' to control threshold
      of dirty nat entries, if current ratio exceeds configured threshold,
      checkpoint will be triggered in f2fs_balance_fs_bg for flushing dirty nats.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2304cb0c
    • Chao Yu's avatar
      f2fs: flush dirty nat entries when exceeding threshold · 7d768d2c
      Chao Yu authored
      When testing f2fs with xfstest, generic/251 is stuck for long time,
      the case uses below serials to obtain fresh released space in device,
      in order to prepare for following fstrim test.
      
      1. rm -rf /mnt/dir
      2. mkdir /mnt/dir/
      3. cp -axT `pwd`/ /mnt/dir/
      4. goto 1
      
      During preparing step, all nat entries will be cached in nat cache,
      most of them are dirty entries with invalid blkaddr, which means
      nodes related to these entries have been truncated, and they could
      be reused after the dirty entries been checkpointed.
      
      However, there was no checkpoint been triggered, so nid allocators
      (e.g. mkdir, creat) will run into long journey of iterating all NAT
      pages, looking for free nids in alloc_nid->build_free_nids.
      
      Here, in f2fs_balance_fs_bg we give another chance to do checkpoint
      to flush nat entries for reusing them in free nid cache when dirty
      entry count exceeds 10% of max count.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7d768d2c
    • Chao Yu's avatar
      f2fs: relocate is_merged_page · 0fd785eb
      Chao Yu authored
      Operations in is_merged_page is related to inner bio cache, move it to
      data.c.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      0fd785eb
  2. 22 Feb, 2016 22 commits