08 Jan, 2014

1 commit

  • Previously during SSR and GC, the maximum number of retrials to find a victim
    segment was hard-coded by MAX_VICTIM_SEARCH, 4096 by default.

    This number makes an effect on IO locality, when SSR mode is activated, which
    results in performance fluctuation on some low-end devices.

    If max_victim_search = 4, the victim will be searched like below.
    ("D" represents a dirty segment, and "*" indicates a selected victim segment.)

    D1 D2 D3 D4 D5 D6 D7 D8 D9
    [ * ]
    [ * ]
    [ * ]
    [ ....]

    This patch adds a sysfs entry to control the number dynamically through:
    /sys/fs/f2fs/$dev/max_victim_search

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     

05 Sep, 2013

1 commit

  • This patch improves the gc efficiency by optimizing the victim
    selection policy. With this optimization, the random re-write
    performance could increase up to 20%.

    For f2fs, when disk is in shortage of free spaces, gc will selects
    dirty segments and moves valid blocks around for making more space
    available. The gc cost of a segment is determined by the valid blocks
    in the segment. The less the valid blocks, the higher the efficiency.
    The ideal victim segment is the one that has the most garbage blocks.

    Currently, it searches up to 20 dirty segments for a victim segment.
    The selected victim is not likely the best victim for gc when there
    are much more dirty segments. Why not searching more dirty segments
    for a better victim? The cost of searching dirty segments is
    negligible in comparison to moving blocks.

    In this patch, it enlarges the MAX_VICTIM_SEARCH to 4096 to make
    the search more aggressively for a possible better victim. Since
    it also applies to victim selection for SSR, it will likely improve
    the SSR efficiency as well.

    The test case is simple. It creates as many files until the disk full.
    The size for each file is 32KB. Then it writes as many as 100000
    records of 4KB size to random offsets of random files in sync mode.
    The testing was done on a 2GB partition of a SDHC card. Let's see the
    test result of f2fs without and with the patch.

    ---------------------------------------
    2GB partition, SDHC
    create 52023 files of size 32768 bytes
    random re-write 100000 records of 4KB
    ---------------------------------------
    | file creation (s) | rewrite time (s) | gc count | gc garbage blocks |
    [no patch] 341 4227 1174 174840
    [patched] 324 2958 645 106682

    It's obvious that, with the patch, f2fs finishes the test in 20+% less
    time than without the patch. And internally it does much less gc with
    higher efficiency than before.

    Since the performance improvement is related to gc, it might not be so
    obvious for other tests that do not trigger gc as often as this one (
    This is because f2fs selects dirty segments for SSR use most of the
    time when free space is in shortage). The well-known iozone test tool
    was not used for benchmarking the patch becuase it seems do not have
    a test case that performs random re-write on a full disk.

    This patch is the revised version based on the suggestion from
    Jaegeuk Kim.

    Signed-off-by: Jin Xu
    [Jaegeuk Kim: suggested simpler solution]
    Reviewed-by: Jaegeuk Kim
    Signed-off-by: Jaegeuk Kim

    Jin Xu
     

06 Aug, 2013

2 commits

  • Add sysfs entry gc_idle to control the gc policy. Where
    gc_idle = 1 corresponds to selecting a cost benefit approach,
    while gc_idle = 2 corresponds to selecting a greedy approach
    to garbage collection. The selection is mutually exclusive one
    approach will work at any point. If gc_idle = 0, then this
    option is disabled.

    Cc: Gu Zheng
    Signed-off-by: Namjae Jeon
    Signed-off-by: Pankaj Kumar
    Reviewed-by: Gu Zheng
    [Jaegeuk Kim: change the select_gc_type() flow slightly]
    Signed-off-by: Jaegeuk Kim

    Namjae Jeon
     
  • Add sysfs entries to control the timing parameters for
    f2fs gc thread.

    Various Sysfs options introduced are:
    gc_min_sleep_time: Min Sleep time for GC in ms
    gc_max_sleep_time: Max Sleep time for GC in ms
    gc_no_gc_sleep_time: Default Sleep time for GC in ms

    Cc: Gu Zheng
    Signed-off-by: Namjae Jeon
    Signed-off-by: Pankaj Kumar
    Reviewed-by: Gu Zheng
    [Jaegeuk Kim: fix an umount bug and some minor changes]
    Signed-off-by: Jaegeuk Kim

    Namjae Jeon
     

26 Apr, 2013

1 commit


12 Feb, 2013

3 commits

  • 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: Jaegeuk Kim

    Jaegeuk Kim
     
  • Introduce accessor to get the sections based upon the block type
    (node,dents...) and modify the functions : should_do_checkpoint,
    has_not_enough_free_secs to use this accessor function to get
    the node sections and dent sections.

    Signed-off-by: Namjae Jeon
    Signed-off-by: Amit Sahrawat
    Signed-off-by: Jaegeuk Kim

    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: Namjae Jeon
    Signed-off-by: Amit Sahrawat
    Signed-off-by: Jaegeuk Kim

    Namjae Jeon
     

11 Dec, 2012

2 commits

  • As pointed out by Randy Dunlap, this patch removes all usage of "/**" for comment
    blocks. Instead, just use "/*".

    Signed-off-by: Jaegeuk Kim

    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: Jaegeuk Kim

    Jaegeuk Kim