aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/segment.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-11-14 23:55:58 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-12-22 20:18:00 -0500
commit7fd9e544fbb10c6ae4b4953f6063560c8eeae6e8 (patch)
tree886a26e62f058fe48656335374657c402dfb3da0 /fs/f2fs/segment.c
parente81c93cf8c7bd413898798cf8c67f18b1fef3360 (diff)
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 <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r--fs/f2fs/segment.c20
1 files changed, 20 insertions, 0 deletions
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 @@
22 22
23#define __reverse_ffz(x) __reverse_ffs(~(x)) 23#define __reverse_ffz(x) __reverse_ffs(~(x))
24 24
25static struct kmem_cache *discard_entry_slab;
26
25/* 27/*
26 * __reverse_ffs is copied from include/asm-generic/bitops/__ffs.h since 28 * __reverse_ffs is copied from include/asm-generic/bitops/__ffs.h since
27 * MSB and LSB are reversed in a byte by f2fs_set_bit. 29 * 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)
1798 sm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr); 1800 sm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr);
1799 sm_info->rec_prefree_segments = DEF_RECLAIM_PREFREE_SEGMENTS; 1801 sm_info->rec_prefree_segments = DEF_RECLAIM_PREFREE_SEGMENTS;
1800 1802
1803 INIT_LIST_HEAD(&sm_info->discard_list);
1804 sm_info->nr_discards = 0;
1805 sm_info->max_discards = 0;
1806
1801 err = build_sit_info(sbi); 1807 err = build_sit_info(sbi);
1802 if (err) 1808 if (err)
1803 return err; 1809 return err;
@@ -1913,3 +1919,17 @@ void destroy_segment_manager(struct f2fs_sb_info *sbi)
1913 sbi->sm_info = NULL; 1919 sbi->sm_info = NULL;
1914 kfree(sm_info); 1920 kfree(sm_info);
1915} 1921}
1922
1923int __init create_segment_manager_caches(void)
1924{
1925 discard_entry_slab = f2fs_kmem_cache_create("discard_entry",
1926 sizeof(struct discard_entry), NULL);
1927 if (!discard_entry_slab)
1928 return -ENOMEM;
1929 return 0;
1930}
1931
1932void destroy_segment_manager_caches(void)
1933{
1934 kmem_cache_destroy(discard_entry_slab);
1935}