f2fs: add garbage collection functions
authorJaegeuk Kim <jaegeuk.kim@samsung.com>
Fri, 2 Nov 2012 08:13:01 +0000 (17:13 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Tue, 11 Dec 2012 04:43:41 +0000 (13:43 +0900)
commit7bc0900347e069a1676d28ad6f98cafaf8cfd6e9
treed1c89e27d39e9137dbed44af293af8f7ce8da29e
parentaf48b85b8cd3fbb12c9b6759c16db6d69c0b03da
f2fs: add garbage collection functions

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: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/gc.c [new file with mode: 0644]
fs/f2fs/gc.h [new file with mode: 0644]