gc.c (e3c55d406bd8df1a878546002c93db90c42be10c) gc.c (7bd59381c82defe19875284c48b1ac9dacd16e8f)
1/*
2 * fs/f2fs/gc.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 222 unchanged lines hidden (view full) ---

231 sit_i->max_mtime = mtime;
232 if (sit_i->max_mtime != sit_i->min_mtime)
233 age = 100 - div64_u64(100 * (mtime - sit_i->min_mtime),
234 sit_i->max_mtime - sit_i->min_mtime);
235
236 return UINT_MAX - ((100 * (100 - u) * age) / (100 + u));
237}
238
1/*
2 * fs/f2fs/gc.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 222 unchanged lines hidden (view full) ---

231 sit_i->max_mtime = mtime;
232 if (sit_i->max_mtime != sit_i->min_mtime)
233 age = 100 - div64_u64(100 * (mtime - sit_i->min_mtime),
234 sit_i->max_mtime - sit_i->min_mtime);
235
236 return UINT_MAX - ((100 * (100 - u) * age) / (100 + u));
237}
238
239static unsigned int get_gc_cost(struct f2fs_sb_info *sbi, unsigned int segno,
240 struct victim_sel_policy *p)
239static inline unsigned int get_gc_cost(struct f2fs_sb_info *sbi,
240 unsigned int segno, struct victim_sel_policy *p)
241{
242 if (p->alloc_mode == SSR)
243 return get_seg_entry(sbi, segno)->ckpt_valid_blocks;
244
245 /* alloc_mode == LFS */
246 if (p->gc_mode == GC_GREEDY)
247 return get_valid_blocks(sbi, segno, sbi->segs_per_sec);
248 else

--- 39 unchanged lines hidden (view full) ---

288 if (segno >= TOTAL_SEGS(sbi)) {
289 if (sbi->last_victim[p.gc_mode]) {
290 sbi->last_victim[p.gc_mode] = 0;
291 p.offset = 0;
292 continue;
293 }
294 break;
295 }
241{
242 if (p->alloc_mode == SSR)
243 return get_seg_entry(sbi, segno)->ckpt_valid_blocks;
244
245 /* alloc_mode == LFS */
246 if (p->gc_mode == GC_GREEDY)
247 return get_valid_blocks(sbi, segno, sbi->segs_per_sec);
248 else

--- 39 unchanged lines hidden (view full) ---

288 if (segno >= TOTAL_SEGS(sbi)) {
289 if (sbi->last_victim[p.gc_mode]) {
290 sbi->last_victim[p.gc_mode] = 0;
291 p.offset = 0;
292 continue;
293 }
294 break;
295 }
296 p.offset = ((segno / p.ofs_unit) * p.ofs_unit) + p.ofs_unit;
296
297 p.offset = segno + p.ofs_unit;
298 if (p.ofs_unit > 1)
299 p.offset -= segno % p.ofs_unit;
300
297 secno = GET_SECNO(sbi, segno);
298
299 if (sec_usage_check(sbi, secno))
300 continue;
301 if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap))
302 continue;
303
304 cost = get_gc_cost(sbi, segno, &p);
305
306 if (p.min_cost > cost) {
307 p.min_segno = segno;
308 p.min_cost = cost;
301 secno = GET_SECNO(sbi, segno);
302
303 if (sec_usage_check(sbi, secno))
304 continue;
305 if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap))
306 continue;
307
308 cost = get_gc_cost(sbi, segno, &p);
309
310 if (p.min_cost > cost) {
311 p.min_segno = segno;
312 p.min_cost = cost;
313 } else if (unlikely(cost == max_cost)) {
314 continue;
309 }
310
315 }
316
311 if (cost == max_cost)
312 continue;
313
314 if (nsearched++ >= p.max_search) {
315 sbi->last_victim[p.gc_mode] = segno;
316 break;
317 }
318 }
319 if (p.min_segno != NULL_SEGNO) {
320got_it:
321 if (p.alloc_mode == LFS) {

--- 31 unchanged lines hidden (view full) ---

353static void add_gc_inode(struct inode *inode, struct list_head *ilist)
354{
355 struct inode_entry *new_ie;
356
357 if (inode == find_gc_inode(inode->i_ino, ilist)) {
358 iput(inode);
359 return;
360 }
317 if (nsearched++ >= p.max_search) {
318 sbi->last_victim[p.gc_mode] = segno;
319 break;
320 }
321 }
322 if (p.min_segno != NULL_SEGNO) {
323got_it:
324 if (p.alloc_mode == LFS) {

--- 31 unchanged lines hidden (view full) ---

356static void add_gc_inode(struct inode *inode, struct list_head *ilist)
357{
358 struct inode_entry *new_ie;
359
360 if (inode == find_gc_inode(inode->i_ino, ilist)) {
361 iput(inode);
362 return;
363 }
361repeat:
362 new_ie = kmem_cache_alloc(winode_slab, GFP_NOFS);
363 if (!new_ie) {
364 cond_resched();
365 goto repeat;
366 }
364
365 new_ie = f2fs_kmem_cache_alloc(winode_slab, GFP_NOFS);
367 new_ie->inode = inode;
368 list_add_tail(&new_ie->list, ilist);
369}
370
371static void put_gc_inode(struct list_head *ilist)
372{
373 struct inode_entry *ie, *next_ie;
374 list_for_each_entry_safe(ie, next_ie, ilist, list) {

--- 375 unchanged lines hidden ---
366 new_ie->inode = inode;
367 list_add_tail(&new_ie->list, ilist);
368}
369
370static void put_gc_inode(struct list_head *ilist)
371{
372 struct inode_entry *ie, *next_ie;
373 list_for_each_entry_safe(ie, next_ie, ilist, list) {

--- 375 unchanged lines hidden ---