f2fs: clarify and enhance the f2fs_gc flow
[linux-2.6-block.git] / fs / f2fs / gc.c
CommitLineData
0a8165d7 1/*
7bc09003
JK
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
9 * published by the Free Software Foundation.
10 */
11#include <linux/fs.h>
12#include <linux/module.h>
13#include <linux/backing-dev.h>
14#include <linux/proc_fs.h>
15#include <linux/init.h>
16#include <linux/f2fs_fs.h>
17#include <linux/kthread.h>
18#include <linux/delay.h>
19#include <linux/freezer.h>
20#include <linux/blkdev.h>
21
22#include "f2fs.h"
23#include "node.h"
24#include "segment.h"
25#include "gc.h"
26
27static struct kmem_cache *winode_slab;
28
29static int gc_thread_func(void *data)
30{
31 struct f2fs_sb_info *sbi = data;
32 wait_queue_head_t *wq = &sbi->gc_thread->gc_wait_queue_head;
33 long wait_ms;
34
35 wait_ms = GC_THREAD_MIN_SLEEP_TIME;
36
37 do {
38 if (try_to_freeze())
39 continue;
40 else
41 wait_event_interruptible_timeout(*wq,
42 kthread_should_stop(),
43 msecs_to_jiffies(wait_ms));
44 if (kthread_should_stop())
45 break;
46
d6212a5f
CL
47 if (sbi->sb->s_writers.frozen >= SB_FREEZE_WRITE) {
48 wait_ms = GC_THREAD_MAX_SLEEP_TIME;
49 continue;
50 }
51
7bc09003
JK
52 /*
53 * [GC triggering condition]
54 * 0. GC is not conducted currently.
55 * 1. There are enough dirty segments.
56 * 2. IO subsystem is idle by checking the # of writeback pages.
57 * 3. IO subsystem is idle by checking the # of requests in
58 * bdev's request list.
59 *
60 * Note) We have to avoid triggering GCs too much frequently.
61 * Because it is possible that some segments can be
62 * invalidated soon after by user update or deletion.
63 * So, I'd like to wait some time to collect dirty segments.
64 */
65 if (!mutex_trylock(&sbi->gc_mutex))
66 continue;
67
68 if (!is_idle(sbi)) {
69 wait_ms = increase_sleep_time(wait_ms);
70 mutex_unlock(&sbi->gc_mutex);
71 continue;
72 }
73
74 if (has_enough_invalid_blocks(sbi))
75 wait_ms = decrease_sleep_time(wait_ms);
76 else
77 wait_ms = increase_sleep_time(wait_ms);
78
79 sbi->bg_gc++;
80
43727527
JK
81 /* if return value is not zero, no victim was selected */
82 if (f2fs_gc(sbi))
7bc09003
JK
83 wait_ms = GC_THREAD_NOGC_SLEEP_TIME;
84 else if (wait_ms == GC_THREAD_NOGC_SLEEP_TIME)
85 wait_ms = GC_THREAD_MAX_SLEEP_TIME;
86
87 } while (!kthread_should_stop());
88 return 0;
89}
90
91int start_gc_thread(struct f2fs_sb_info *sbi)
92{
1042d60f 93 struct f2fs_gc_kthread *gc_th;
ec7b1f2d 94 dev_t dev = sbi->sb->s_bdev->bd_dev;
7bc09003 95
48600e44
CL
96 if (!test_opt(sbi, BG_GC))
97 return 0;
7bc09003
JK
98 gc_th = kmalloc(sizeof(struct f2fs_gc_kthread), GFP_KERNEL);
99 if (!gc_th)
100 return -ENOMEM;
101
102 sbi->gc_thread = gc_th;
103 init_waitqueue_head(&sbi->gc_thread->gc_wait_queue_head);
104 sbi->gc_thread->f2fs_gc_task = kthread_run(gc_thread_func, sbi,
ec7b1f2d 105 "f2fs_gc-%u:%u", MAJOR(dev), MINOR(dev));
7bc09003
JK
106 if (IS_ERR(gc_th->f2fs_gc_task)) {
107 kfree(gc_th);
25718423 108 sbi->gc_thread = NULL;
7bc09003
JK
109 return -ENOMEM;
110 }
111 return 0;
112}
113
114void stop_gc_thread(struct f2fs_sb_info *sbi)
115{
116 struct f2fs_gc_kthread *gc_th = sbi->gc_thread;
117 if (!gc_th)
118 return;
119 kthread_stop(gc_th->f2fs_gc_task);
120 kfree(gc_th);
121 sbi->gc_thread = NULL;
122}
123
124static int select_gc_type(int gc_type)
125{
126 return (gc_type == BG_GC) ? GC_CB : GC_GREEDY;
127}
128
129static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
130 int type, struct victim_sel_policy *p)
131{
132 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
133
134 if (p->alloc_mode) {
135 p->gc_mode = GC_GREEDY;
136 p->dirty_segmap = dirty_i->dirty_segmap[type];
137 p->ofs_unit = 1;
138 } else {
139 p->gc_mode = select_gc_type(gc_type);
140 p->dirty_segmap = dirty_i->dirty_segmap[DIRTY];
141 p->ofs_unit = sbi->segs_per_sec;
142 }
143 p->offset = sbi->last_victim[p->gc_mode];
144}
145
146static unsigned int get_max_cost(struct f2fs_sb_info *sbi,
147 struct victim_sel_policy *p)
148{
149 if (p->gc_mode == GC_GREEDY)
150 return (1 << sbi->log_blocks_per_seg) * p->ofs_unit;
151 else if (p->gc_mode == GC_CB)
152 return UINT_MAX;
153 else /* No other gc_mode */
154 return 0;
155}
156
157static unsigned int check_bg_victims(struct f2fs_sb_info *sbi)
158{
159 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
160 unsigned int segno;
161
162 /*
163 * If the gc_type is FG_GC, we can select victim segments
164 * selected by background GC before.
165 * Those segments guarantee they have small valid blocks.
166 */
167 segno = find_next_bit(dirty_i->victim_segmap[BG_GC],
168 TOTAL_SEGS(sbi), 0);
169 if (segno < TOTAL_SEGS(sbi)) {
170 clear_bit(segno, dirty_i->victim_segmap[BG_GC]);
171 return segno;
172 }
173 return NULL_SEGNO;
174}
175
176static unsigned int get_cb_cost(struct f2fs_sb_info *sbi, unsigned int segno)
177{
178 struct sit_info *sit_i = SIT_I(sbi);
179 unsigned int secno = GET_SECNO(sbi, segno);
180 unsigned int start = secno * sbi->segs_per_sec;
181 unsigned long long mtime = 0;
182 unsigned int vblocks;
183 unsigned char age = 0;
184 unsigned char u;
185 unsigned int i;
186
187 for (i = 0; i < sbi->segs_per_sec; i++)
188 mtime += get_seg_entry(sbi, start + i)->mtime;
189 vblocks = get_valid_blocks(sbi, segno, sbi->segs_per_sec);
190
191 mtime = div_u64(mtime, sbi->segs_per_sec);
192 vblocks = div_u64(vblocks, sbi->segs_per_sec);
193
194 u = (vblocks * 100) >> sbi->log_blocks_per_seg;
195
196 /* Handle if the system time is changed by user */
197 if (mtime < sit_i->min_mtime)
198 sit_i->min_mtime = mtime;
199 if (mtime > sit_i->max_mtime)
200 sit_i->max_mtime = mtime;
201 if (sit_i->max_mtime != sit_i->min_mtime)
202 age = 100 - div64_u64(100 * (mtime - sit_i->min_mtime),
203 sit_i->max_mtime - sit_i->min_mtime);
204
205 return UINT_MAX - ((100 * (100 - u) * age) / (100 + u));
206}
207
208static unsigned int get_gc_cost(struct f2fs_sb_info *sbi, unsigned int segno,
209 struct victim_sel_policy *p)
210{
211 if (p->alloc_mode == SSR)
212 return get_seg_entry(sbi, segno)->ckpt_valid_blocks;
213
214 /* alloc_mode == LFS */
215 if (p->gc_mode == GC_GREEDY)
216 return get_valid_blocks(sbi, segno, sbi->segs_per_sec);
217 else
218 return get_cb_cost(sbi, segno);
219}
220
0a8165d7 221/*
7bc09003
JK
222 * This function is called from two pathes.
223 * One is garbage collection and the other is SSR segment selection.
224 * When it is called during GC, it just gets a victim segment
225 * and it does not remove it from dirty seglist.
226 * When it is called from SSR segment selection, it finds a segment
227 * which has minimum valid blocks and removes it from dirty seglist.
228 */
229static int get_victim_by_default(struct f2fs_sb_info *sbi,
230 unsigned int *result, int gc_type, int type, char alloc_mode)
231{
232 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
233 struct victim_sel_policy p;
234 unsigned int segno;
235 int nsearched = 0;
236
237 p.alloc_mode = alloc_mode;
238 select_policy(sbi, gc_type, type, &p);
239
240 p.min_segno = NULL_SEGNO;
241 p.min_cost = get_max_cost(sbi, &p);
242
243 mutex_lock(&dirty_i->seglist_lock);
244
245 if (p.alloc_mode == LFS && gc_type == FG_GC) {
246 p.min_segno = check_bg_victims(sbi);
247 if (p.min_segno != NULL_SEGNO)
248 goto got_it;
249 }
250
251 while (1) {
252 unsigned long cost;
253
254 segno = find_next_bit(p.dirty_segmap,
255 TOTAL_SEGS(sbi), p.offset);
256 if (segno >= TOTAL_SEGS(sbi)) {
257 if (sbi->last_victim[p.gc_mode]) {
258 sbi->last_victim[p.gc_mode] = 0;
259 p.offset = 0;
260 continue;
261 }
262 break;
263 }
264 p.offset = ((segno / p.ofs_unit) * p.ofs_unit) + p.ofs_unit;
265
266 if (test_bit(segno, dirty_i->victim_segmap[FG_GC]))
267 continue;
268 if (gc_type == BG_GC &&
269 test_bit(segno, dirty_i->victim_segmap[BG_GC]))
270 continue;
271 if (IS_CURSEC(sbi, GET_SECNO(sbi, segno)))
272 continue;
273
274 cost = get_gc_cost(sbi, segno, &p);
275
276 if (p.min_cost > cost) {
277 p.min_segno = segno;
278 p.min_cost = cost;
279 }
280
281 if (cost == get_max_cost(sbi, &p))
282 continue;
283
284 if (nsearched++ >= MAX_VICTIM_SEARCH) {
285 sbi->last_victim[p.gc_mode] = segno;
286 break;
287 }
288 }
289got_it:
290 if (p.min_segno != NULL_SEGNO) {
291 *result = (p.min_segno / p.ofs_unit) * p.ofs_unit;
292 if (p.alloc_mode == LFS) {
293 int i;
294 for (i = 0; i < p.ofs_unit; i++)
295 set_bit(*result + i,
296 dirty_i->victim_segmap[gc_type]);
297 }
298 }
299 mutex_unlock(&dirty_i->seglist_lock);
300
301 return (p.min_segno == NULL_SEGNO) ? 0 : 1;
302}
303
304static const struct victim_selection default_v_ops = {
305 .get_victim = get_victim_by_default,
306};
307
308static struct inode *find_gc_inode(nid_t ino, struct list_head *ilist)
309{
310 struct list_head *this;
311 struct inode_entry *ie;
312
313 list_for_each(this, ilist) {
314 ie = list_entry(this, struct inode_entry, list);
315 if (ie->inode->i_ino == ino)
316 return ie->inode;
317 }
318 return NULL;
319}
320
321static void add_gc_inode(struct inode *inode, struct list_head *ilist)
322{
323 struct list_head *this;
324 struct inode_entry *new_ie, *ie;
325
326 list_for_each(this, ilist) {
327 ie = list_entry(this, struct inode_entry, list);
328 if (ie->inode == inode) {
329 iput(inode);
330 return;
331 }
332 }
333repeat:
334 new_ie = kmem_cache_alloc(winode_slab, GFP_NOFS);
335 if (!new_ie) {
336 cond_resched();
337 goto repeat;
338 }
339 new_ie->inode = inode;
340 list_add_tail(&new_ie->list, ilist);
341}
342
343static void put_gc_inode(struct list_head *ilist)
344{
345 struct inode_entry *ie, *next_ie;
346 list_for_each_entry_safe(ie, next_ie, ilist, list) {
347 iput(ie->inode);
348 list_del(&ie->list);
349 kmem_cache_free(winode_slab, ie);
350 }
351}
352
353static int check_valid_map(struct f2fs_sb_info *sbi,
354 unsigned int segno, int offset)
355{
356 struct sit_info *sit_i = SIT_I(sbi);
357 struct seg_entry *sentry;
358 int ret;
359
360 mutex_lock(&sit_i->sentry_lock);
361 sentry = get_seg_entry(sbi, segno);
362 ret = f2fs_test_bit(offset, sentry->cur_valid_map);
363 mutex_unlock(&sit_i->sentry_lock);
43727527 364 return ret;
7bc09003
JK
365}
366
0a8165d7 367/*
7bc09003
JK
368 * This function compares node address got in summary with that in NAT.
369 * On validity, copy that node with cold status, otherwise (invalid node)
370 * ignore that.
371 */
43727527 372static void gc_node_segment(struct f2fs_sb_info *sbi,
7bc09003
JK
373 struct f2fs_summary *sum, unsigned int segno, int gc_type)
374{
375 bool initial = true;
376 struct f2fs_summary *entry;
377 int off;
378
379next_step:
380 entry = sum;
381 for (off = 0; off < sbi->blocks_per_seg; off++, entry++) {
382 nid_t nid = le32_to_cpu(entry->nid);
383 struct page *node_page;
7bc09003 384
43727527
JK
385 /* stop BG_GC if there is not enough free sections. */
386 if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0))
387 return;
7bc09003 388
43727527 389 if (check_valid_map(sbi, segno, off) == 0)
7bc09003
JK
390 continue;
391
392 if (initial) {
393 ra_node_page(sbi, nid);
394 continue;
395 }
396 node_page = get_node_page(sbi, nid);
397 if (IS_ERR(node_page))
398 continue;
399
400 /* set page dirty and write it */
401 if (!PageWriteback(node_page))
402 set_page_dirty(node_page);
403 f2fs_put_page(node_page, 1);
404 stat_inc_node_blk_count(sbi, 1);
405 }
406 if (initial) {
407 initial = false;
408 goto next_step;
409 }
410
411 if (gc_type == FG_GC) {
412 struct writeback_control wbc = {
413 .sync_mode = WB_SYNC_ALL,
414 .nr_to_write = LONG_MAX,
415 .for_reclaim = 0,
416 };
417 sync_node_pages(sbi, 0, &wbc);
418 }
7bc09003
JK
419}
420
0a8165d7 421/*
9af45ef5
JK
422 * Calculate start block index indicating the given node offset.
423 * Be careful, caller should give this node offset only indicating direct node
424 * blocks. If any node offsets, which point the other types of node blocks such
425 * as indirect or double indirect node blocks, are given, it must be a caller's
426 * bug.
7bc09003
JK
427 */
428block_t start_bidx_of_node(unsigned int node_ofs)
429{
ce19a5d4
JK
430 unsigned int indirect_blks = 2 * NIDS_PER_BLOCK + 4;
431 unsigned int bidx;
7bc09003 432
ce19a5d4
JK
433 if (node_ofs == 0)
434 return 0;
7bc09003 435
ce19a5d4 436 if (node_ofs <= 2) {
7bc09003
JK
437 bidx = node_ofs - 1;
438 } else if (node_ofs <= indirect_blks) {
ce19a5d4 439 int dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1);
7bc09003
JK
440 bidx = node_ofs - 2 - dec;
441 } else {
ce19a5d4 442 int dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1);
7bc09003
JK
443 bidx = node_ofs - 5 - dec;
444 }
ce19a5d4 445 return bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE;
7bc09003
JK
446}
447
448static int check_dnode(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
449 struct node_info *dni, block_t blkaddr, unsigned int *nofs)
450{
451 struct page *node_page;
452 nid_t nid;
453 unsigned int ofs_in_node;
454 block_t source_blkaddr;
455
456 nid = le32_to_cpu(sum->nid);
457 ofs_in_node = le16_to_cpu(sum->ofs_in_node);
458
459 node_page = get_node_page(sbi, nid);
460 if (IS_ERR(node_page))
43727527 461 return 0;
7bc09003
JK
462
463 get_node_info(sbi, nid, dni);
464
465 if (sum->version != dni->version) {
466 f2fs_put_page(node_page, 1);
43727527 467 return 0;
7bc09003
JK
468 }
469
470 *nofs = ofs_of_node(node_page);
471 source_blkaddr = datablock_addr(node_page, ofs_in_node);
472 f2fs_put_page(node_page, 1);
473
474 if (source_blkaddr != blkaddr)
43727527
JK
475 return 0;
476 return 1;
7bc09003
JK
477}
478
479static void move_data_page(struct inode *inode, struct page *page, int gc_type)
480{
481 if (page->mapping != inode->i_mapping)
482 goto out;
483
484 if (inode != page->mapping->host)
485 goto out;
486
487 if (PageWriteback(page))
488 goto out;
489
490 if (gc_type == BG_GC) {
491 set_page_dirty(page);
492 set_cold_data(page);
493 } else {
494 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
495 mutex_lock_op(sbi, DATA_WRITE);
496 if (clear_page_dirty_for_io(page) &&
497 S_ISDIR(inode->i_mode)) {
498 dec_page_count(sbi, F2FS_DIRTY_DENTS);
499 inode_dec_dirty_dents(inode);
500 }
501 set_cold_data(page);
502 do_write_data_page(page);
503 mutex_unlock_op(sbi, DATA_WRITE);
504 clear_cold_data(page);
505 }
506out:
507 f2fs_put_page(page, 1);
508}
509
0a8165d7 510/*
7bc09003
JK
511 * This function tries to get parent node of victim data block, and identifies
512 * data block validity. If the block is valid, copy that with cold status and
513 * modify parent node.
514 * If the parent node is not valid or the data block address is different,
515 * the victim data block is ignored.
516 */
43727527 517static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
7bc09003
JK
518 struct list_head *ilist, unsigned int segno, int gc_type)
519{
520 struct super_block *sb = sbi->sb;
521 struct f2fs_summary *entry;
522 block_t start_addr;
43727527 523 int off;
7bc09003
JK
524 int phase = 0;
525
526 start_addr = START_BLOCK(sbi, segno);
527
528next_step:
529 entry = sum;
530 for (off = 0; off < sbi->blocks_per_seg; off++, entry++) {
531 struct page *data_page;
532 struct inode *inode;
533 struct node_info dni; /* dnode info for the data */
534 unsigned int ofs_in_node, nofs;
535 block_t start_bidx;
536
43727527
JK
537 /* stop BG_GC if there is not enough free sections. */
538 if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0))
539 return;
7bc09003 540
43727527 541 if (check_valid_map(sbi, segno, off) == 0)
7bc09003
JK
542 continue;
543
544 if (phase == 0) {
545 ra_node_page(sbi, le32_to_cpu(entry->nid));
546 continue;
547 }
548
549 /* Get an inode by ino with checking validity */
43727527 550 if (check_dnode(sbi, entry, &dni, start_addr + off, &nofs) == 0)
7bc09003
JK
551 continue;
552
553 if (phase == 1) {
554 ra_node_page(sbi, dni.ino);
555 continue;
556 }
557
558 start_bidx = start_bidx_of_node(nofs);
559 ofs_in_node = le16_to_cpu(entry->ofs_in_node);
560
561 if (phase == 2) {
d4686d56 562 inode = f2fs_iget(sb, dni.ino);
7bc09003
JK
563 if (IS_ERR(inode))
564 continue;
565
566 data_page = find_data_page(inode,
567 start_bidx + ofs_in_node);
568 if (IS_ERR(data_page))
569 goto next_iput;
570
571 f2fs_put_page(data_page, 0);
572 add_gc_inode(inode, ilist);
573 } else {
574 inode = find_gc_inode(dni.ino, ilist);
575 if (inode) {
576 data_page = get_lock_data_page(inode,
577 start_bidx + ofs_in_node);
578 if (IS_ERR(data_page))
579 continue;
580 move_data_page(inode, data_page, gc_type);
581 stat_inc_data_blk_count(sbi, 1);
582 }
583 }
584 continue;
585next_iput:
586 iput(inode);
587 }
588 if (++phase < 4)
589 goto next_step;
43727527 590
7bc09003
JK
591 if (gc_type == FG_GC)
592 f2fs_submit_bio(sbi, DATA, true);
7bc09003
JK
593}
594
595static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim,
596 int gc_type, int type)
597{
598 struct sit_info *sit_i = SIT_I(sbi);
599 int ret;
600 mutex_lock(&sit_i->sentry_lock);
601 ret = DIRTY_I(sbi)->v_ops->get_victim(sbi, victim, gc_type, type, LFS);
602 mutex_unlock(&sit_i->sentry_lock);
603 return ret;
604}
605
43727527 606static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno,
7bc09003
JK
607 struct list_head *ilist, int gc_type)
608{
609 struct page *sum_page;
610 struct f2fs_summary_block *sum;
7bc09003
JK
611
612 /* read segment summary of victim */
613 sum_page = get_sum_page(sbi, segno);
614 if (IS_ERR(sum_page))
43727527 615 return;
7bc09003
JK
616
617 /*
618 * CP needs to lock sum_page. In this time, we don't need
619 * to lock this page, because this summary page is not gone anywhere.
620 * Also, this page is not gonna be updated before GC is done.
621 */
622 unlock_page(sum_page);
623 sum = page_address(sum_page);
624
625 switch (GET_SUM_TYPE((&sum->footer))) {
626 case SUM_TYPE_NODE:
43727527 627 gc_node_segment(sbi, sum->entries, segno, gc_type);
7bc09003
JK
628 break;
629 case SUM_TYPE_DATA:
43727527 630 gc_data_segment(sbi, sum->entries, ilist, segno, gc_type);
7bc09003
JK
631 break;
632 }
633 stat_inc_seg_count(sbi, GET_SUM_TYPE((&sum->footer)));
634 stat_inc_call_count(sbi->stat_info);
635
636 f2fs_put_page(sum_page, 0);
7bc09003
JK
637}
638
408e9375 639int f2fs_gc(struct f2fs_sb_info *sbi)
7bc09003 640{
7bc09003 641 struct list_head ilist;
408e9375 642 unsigned int segno, i;
7bc09003 643 int gc_type = BG_GC;
43727527
JK
644 int nfree = 0;
645 int ret = -1;
7bc09003
JK
646
647 INIT_LIST_HEAD(&ilist);
648gc_more:
408e9375
JK
649 if (!(sbi->sb->s_flags & MS_ACTIVE))
650 goto stop;
7bc09003 651
43727527 652 if (gc_type == BG_GC && has_not_enough_free_secs(sbi, nfree))
408e9375 653 gc_type = FG_GC;
7bc09003 654
408e9375
JK
655 if (!__get_victim(sbi, &segno, gc_type, NO_CHECK_TYPE))
656 goto stop;
43727527 657 ret = 0;
7bc09003 658
43727527
JK
659 for (i = 0; i < sbi->segs_per_sec; i++)
660 do_garbage_collect(sbi, segno + i, &ilist, gc_type);
661
662 if (gc_type == FG_GC &&
663 get_valid_blocks(sbi, segno, sbi->segs_per_sec) == 0)
664 nfree++;
665
666 if (has_not_enough_free_secs(sbi, nfree))
667 goto gc_more;
668
669 if (gc_type == FG_GC)
670 write_checkpoint(sbi, false);
408e9375 671stop:
7bc09003
JK
672 mutex_unlock(&sbi->gc_mutex);
673
674 put_gc_inode(&ilist);
43727527 675 return ret;
7bc09003
JK
676}
677
678void build_gc_manager(struct f2fs_sb_info *sbi)
679{
680 DIRTY_I(sbi)->v_ops = &default_v_ops;
681}
682
6e6093a8 683int __init create_gc_caches(void)
7bc09003
JK
684{
685 winode_slab = f2fs_kmem_cache_create("f2fs_gc_inodes",
686 sizeof(struct inode_entry), NULL);
687 if (!winode_slab)
688 return -ENOMEM;
689 return 0;
690}
691
692void destroy_gc_caches(void)
693{
694 kmem_cache_destroy(winode_slab);
695}