1. 09 4月, 2013 2 次提交
    • J
      f2fs: write checkpoint before starting FG_GC · d64f8047
      Jaegeuk Kim 提交于
      In order to be aware of prefree and free sections during FG_GC, let's start with
      write_checkpoint().
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      d64f8047
    • J
      f2fs: introduce a new global lock scheme · 39936837
      Jaegeuk Kim 提交于
      In the previous version, f2fs uses global locks according to the usage types,
      such as directory operations, block allocation, block write, and so on.
      
      Reference the following lock types in f2fs.h.
      enum lock_type {
      	RENAME,		/* for renaming operations */
      	DENTRY_OPS,	/* for directory operations */
      	DATA_WRITE,	/* for data write */
      	DATA_NEW,	/* for data allocation */
      	DATA_TRUNC,	/* for data truncate */
      	NODE_NEW,	/* for node allocation */
      	NODE_TRUNC,	/* for node truncate */
      	NODE_WRITE,	/* for node write */
      	NR_LOCK_TYPE,
      };
      
      In that case, we lose the performance under the multi-threading environment,
      since every types of operations must be conducted one at a time.
      
      In order to address the problem, let's share the locks globally with a mutex
      array regardless of any types.
      So, let users grab a mutex and perform their jobs in parallel as much as
      possbile.
      
      For this, I propose a new global lock scheme as follows.
      
      0. Data structure
       - f2fs_sb_info -> mutex_lock[NR_GLOBAL_LOCKS]
       - f2fs_sb_info -> node_write
      
      1. mutex_lock_op(sbi)
       - try to get an avaiable lock from the array.
       - returns the index of the gottern lock variable.
      
      2. mutex_unlock_op(sbi, index of the lock)
       - unlock the given index of the lock.
      
      3. mutex_lock_all(sbi)
       - grab all the locks in the array before the checkpoint.
      
      4. mutex_unlock_all(sbi)
       - release all the locks in the array after checkpoint.
      
      5. block_operations()
       - call mutex_lock_all()
       - sync_dirty_dir_inodes()
       - grab node_write
       - sync_node_pages()
      
      Note that,
       the pairs of mutex_lock_op()/mutex_unlock_op() and
       mutex_lock_all()/mutex_unlock_all() should be used together.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      39936837
  2. 03 4月, 2013 3 次提交
  3. 20 3月, 2013 1 次提交
  4. 12 2月, 2013 8 次提交
    • J
      f2fs: fix calculation of max. gc cost in the SSR case · b7250d2d
      Jaegeuk Kim 提交于
      In the SSR case, the max gc cost should be the number of pages in a segment.
      Otherwise, f2fs is able to fail getting dirty segments frequently for SSR.
      
      In get_victim_by_default() previously,
      
      while(1) {
         ...
         cost = get_gc_cost(); <- cost is between 0 ~ 512.
         ...
         if (cost == get_max_cost(sbi, &p)) <- max cost is UINT_MAX due to GC_CB type
      	continue;
      
         if (nsearched++ >= MAX_VICTIM_SEARCH)
      	break;
      }
      
      So, if there are a number of fully valid segments in series, f2fs cannot skip
      those segments by comparing the cost and max cost of each segment.
      
      Note that, the cost is the number of valid blocks at the time of the last
      checkpoint.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      b7250d2d
    • J
      f2fs: clarify and enhance the f2fs_gc flow · 43727527
      Jaegeuk Kim 提交于
      This patch makes clearer the ambiguous f2fs_gc flow as follows.
      
      1. Remove intermediate checkpoint condition during f2fs_gc
       (i.e., should_do_checkpoint() and GC_BLOCKED)
      
      2. Remove unnecessary return values of f2fs_gc because of #1.
       (i.e., GC_NODE, GC_OK, etc)
      
      3. Simplify write_checkpoint() because of #2.
      
      4. Clarify the main f2fs_gc flow.
       o monitor how many freed sections during one iteration of do_garbage_collect().
       o do GC more without checkpoints if we can't get enough free sections.
       o do checkpoint once we've got enough free sections through forground GCs.
      
      5. Adopt thread-logging (Slack-Space-Recycle) scheme more aggressively on data
        log types. See. get_ssr_segement()
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      43727527
    • N
      f2fs: mark gc_thread as NULL when thread creation is failed · 25718423
      Namjae Jeon 提交于
      When gc thread creation is failed, mark gc_thread as NULL to avoid
      crash while trying to stop invalid thread in stop_gc_thread->kthread_stop.
      Instead make it return from:
      	if (!gc_th)
             return;
      Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NAmit Sahrawat <a.sahrawat@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      25718423
    • N
      f2fs: name gc task as per the block device · ec7b1f2d
      Namjae Jeon 提交于
      Currently GC task is started for each f2fs formatted/mounted device.
      But, when we check the task list, using 'ps', there is no distinguishing
      factor between the tasks. So, name the task as per the block device just
      like the flusher threads.
      Also, remove the macro GC_THREAD_NAME and instead use the name: f2fs_gc
      to avoid name length truncation, as the command length is 16
      -> TASK_COMM_LEN 16 and example name like:
      f2fs_gc_task:8:16 -> this exceeds name length
      
      Before Patch for 2 F2FS formatted partitions:
      root  28061  0.0  0.0  0 0 ? S 10:31   0:00 [f2fs_gc_task]
      root  28087  0.0  0.0  0 0 ? S 10:32   0:00 [f2fs_gc_task]
      
      After Patch:
      root  16756  0.0  0.0  0  0 ?  S  14:57   0:00 [f2fs_gc-8:18]
      root  16765  0.0  0.0  0  0 ?  S  14:57   0:00 [f2fs_gc-8:19]
      Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NAmit Sahrawat <a.sahrawat@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      ec7b1f2d
    • C
      f2fs: remove unnecessary gc option check and balance_fs · 48600e44
      Changman Lee 提交于
       1. If f2fs is mounted with background_gc_off option, checking
          BG_GC is not redundant.
       2. f2fs_balance_fs is checked in f2fs_gc, so this is also redundant.
      Signed-off-by: NChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NAmit Sahrawat <a.sahrawat@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      48600e44
    • J
      f2fs: avoid balanc_fs during evict_inode · d4686d56
      Jaegeuk Kim 提交于
      1. Background
      
      Previously, if f2fs tries to move data blocks of an *evicting* inode during the
      cleaning process, it stops the process incompletely and then restarts the whole
      process, since it needs a locked inode to grab victim data pages in its address
      space. In order to get a locked inode, iget_locked() by f2fs_iget() is normally
      used, but, it waits if the inode is on freeing.
      
      So, here is a deadlock scenario.
      1. f2fs_evict_inode()       <- inode "A"
        2. f2fs_balance_fs()
          3. f2fs_gc()
            4. gc_data_segment()
              5. f2fs_iget()      <- inode "A" too!
      
      If step #1 and #5 treat a same inode "A", step #5 would fall into deadlock since
      the inode "A" is on freeing. In order to resolve this, f2fs_iget_nowait() which
      skips __wait_on_freeing_inode() was introduced in step #5, and stops f2fs_gc()
      to complete f2fs_evict_inode().
      
      1. f2fs_evict_inode()           <- inode "A"
        2. f2fs_balance_fs()
          3. f2fs_gc()
            4. gc_data_segment()
              5. f2fs_iget_nowait()   <- inode "A", then stop f2fs_gc() w/ -ENOENT
      
      2. Problem and Solution
      
      In the above scenario, however, f2fs cannot finish f2fs_evict_inode() only if:
       o there are not enough free sections, and
       o f2fs_gc() tries to move data blocks of the *evicting* inode repeatedly.
      
      So, the final solution is to use f2fs_iget() and remove f2fs_balance_fs() in
      f2fs_evict_inode().
      The f2fs_evict_inode() actually truncates all the data and node blocks, which
      means that it doesn't produce any dirty node pages accordingly.
      So, we don't need to do f2fs_balance_fs() in practical.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      d4686d56
    • N
      f2fs: avoid redundant call to has_not_enough_free_secs in f2fs_gc · 3786dfdf
      Namjae Jeon 提交于
      After doing a write_checkpoint from garbage collection path if there is still
      need to do more garbage collection, gc_more label is used to jump and start
      the process again. And in that process, first step before getting victim is to
      check if there are not enough free sections, which is already done before
      doing a jump to gc_more. We can avoid the redundant call to check free
      sections, by checking the gc_type flag which will remain FG_GC(value 1) under
      this condition.
      Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NAmit Sahrawat <a.sahrawat@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      3786dfdf
    • C
      f2fs: add un/freeze_fs into super_operations · d6212a5f
      Changman Lee 提交于
      This patch supports ioctl FIFREEZE and FITHAW to snapshot filesystem.
      Before calling f2fs_freeze, all writers would be suspended and sync_fs
      would be completed. So no f2fs has to do something.
      Just background gc operation should be skipped due to generate dirty
      nodes and data until unfreeze.
      Signed-off-by: NChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      d6212a5f
  5. 22 1月, 2013 2 次提交
  6. 10 1月, 2013 1 次提交
    • J
      f2fs: revisit the f2fs_gc flow · 408e9375
      Jaegeuk Kim 提交于
      I'd like to revisit the f2fs_gc flow and rewrite as follows.
      
      1. In practical, the nGC parameter of f2fs_gc is meaningless. So, let's
        remove it.
      2. Background GC marks victim blocks as dirty one at a time.
      3. Foreground GC should do cleaning job until acquiring enough free
        sections. Afterwards, it needs to do checkpoint.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      408e9375
  7. 28 12月, 2012 2 次提交
  8. 11 12月, 2012 3 次提交
    • N
      f2fs: remove unneeded initialization · 1042d60f
      Namjae Jeon 提交于
      No need to initialize  "struct f2fs_gc_kthread *gc_th = NULL",
      as gc_th = NULL, will be taken care by the return values of kmalloc().
      And fix codes in other places.
      Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NAmit Sahrawat <a.sahrawat@samsung.com>
      1042d60f
    • J
      f2fs: adjust kernel coding style · 0a8165d7
      Jaegeuk Kim 提交于
      As pointed out by Randy Dunlap, this patch removes all usage of "/**" for comment
      blocks. Instead, just use "/*".
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      0a8165d7
    • J
      f2fs: add garbage collection functions · 7bc09003
      Jaegeuk Kim 提交于
      This adds on-demand and background cleaning functions.
      
      - The basic background cleaning policy is trying to do cleaning jobs as much as
        possible whenever the system is idle. Once the background cleaning is done,
        the cleaner sleeps an amount of time not to interfere with VFS calls. The time
        is dynamically adjusted according to the status of whole segments, which is
        decreased when the following conditions are satisfied.
      
        . GC is not conducted currently, and
        . IO subsystem is idle by checking the number of requets in bdev's request
           list, and
        . There are enough dirty segments.
      
        Otherwise, the time is increased incrementally until to the maximum time.
        Note that, min and max times are 10 secs and 30 secs by default.
      
      - F2FS adopts a default victim selection policy where background cleaning uses
        a cost-benefit algorithm, while on-demand cleaning uses a greedy algorithm.
      
      - The method of moving data during the cleaning is slightly different between
        background and on-demand cleaning schemes. In the case of background cleaning,
        F2FS loads the data, and marks them as dirty. Then, F2FS expects that the data
        will be moved by flusher or VM. In the case of on-demand cleaning, F2FS should
        move the data right away.
      
      - In order to identify valid blocks in a victim segment, F2FS scans the bitmap
        of the segment managed as an SIT entry.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      7bc09003