f2fs: reorganise the function get_victim_by_default
authorNamjae Jeon <namjae.jeon@samsung.com>
Sat, 1 Jun 2013 07:20:26 +0000 (16:20 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Thu, 6 Jun 2013 05:20:46 +0000 (14:20 +0900)
commitb2b3460a9404136e0a99b9f7cb56e08ec41ea933
tree7e3385fba02fb10ebacecaa3a5c3c7edfcabf44e
parent1e03e38b35b8e72d65fd5d931627bd6ff02926c1
f2fs: reorganise the function get_victim_by_default

Fix the function get_victim_by_default, where it checks
for the condition  that p.min_segno != NULL_SEGNO as
shown:

if (p.min_segno != NULL_SEGNO)
           goto got_it;

and if above condition is true then

got_it:
        if (p.min_segno != NULL_SEGNO) {

So this condition is being checked twice. Hence move the goto
statement after the if condition so that duplication of condition
check is avoided.

Also this function makes a call to get_max_cost() to compute
the max cost based on the f2fs_sbi_info and victim policy. Since
get_max_cost depends on on three parameters of victim_sel_policy
=> alloc_mode, gc_mode & ofs_unit, once this victim policy is
initialised, these value will not change till the execution
time of get_victim_by_default() & also f2fs_sbi_info structure
parameters will not change.

Hence making calls to get_max_cost() in while loop does not seems to
be a good point. Instead we can call it once in begining and store
the results in local variable, which later can serve our purpose
for comparing the cost with max cost inside the while loop.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Pankaj Kumar <pankaj.km@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/gc.c