From 7fd9e544fbb10c6ae4b4953f6063560c8eeae6e8 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 15 Nov 2013 13:55:58 +0900 Subject: f2fs: add a slab cache entry for small discards This patch adds a slab cache entry for small discards. Each entry consists of: struct discard_entry { struct list_head list; /* list head */ block_t blkaddr; /* block address to be discarded */ int len; /* # of consecutive blocks of the discard */ }; Signed-off-by: Jaegeuk Kim --- fs/f2fs/segment.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'fs/f2fs/segment.c') diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 67f1e5bbdac9..823526ec5243 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -22,6 +22,8 @@ #define __reverse_ffz(x) __reverse_ffs(~(x)) +static struct kmem_cache *discard_entry_slab; + /* * __reverse_ffs is copied from include/asm-generic/bitops/__ffs.h since * MSB and LSB are reversed in a byte by f2fs_set_bit. @@ -1798,6 +1800,10 @@ int build_segment_manager(struct f2fs_sb_info *sbi) sm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr); sm_info->rec_prefree_segments = DEF_RECLAIM_PREFREE_SEGMENTS; + INIT_LIST_HEAD(&sm_info->discard_list); + sm_info->nr_discards = 0; + sm_info->max_discards = 0; + err = build_sit_info(sbi); if (err) return err; @@ -1913,3 +1919,17 @@ void destroy_segment_manager(struct f2fs_sb_info *sbi) sbi->sm_info = NULL; kfree(sm_info); } + +int __init create_segment_manager_caches(void) +{ + discard_entry_slab = f2fs_kmem_cache_create("discard_entry", + sizeof(struct discard_entry), NULL); + if (!discard_entry_slab) + return -ENOMEM; + return 0; +} + +void destroy_segment_manager_caches(void) +{ + kmem_cache_destroy(discard_entry_slab); +} -- cgit v1.2.3