summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/f2fs.h
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2017-04-14 11:24:55 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2017-04-19 14:00:40 -0400
commit004b68621897f06aa2817e7438469d23f4a3a284 (patch)
tree662ba33d4d48cf7704f4adf43c6e805f12b22951 /fs/f2fs/f2fs.h
parentd40d30c5aa5227546030d3d7b0a6a38c6c85933a (diff)
f2fs: use rb-tree to track pending discard commands
Introduce rb-tree based discard cache infrastructure to speed up lookup and merge operation of discard entry. Signed-off-by: Chao Yu <yuchao0@huawei.com> [Jaegeuk Kim: initialize dc to avoid build warning] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/f2fs.h')
-rw-r--r--fs/f2fs/f2fs.h48
1 files changed, 45 insertions, 3 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 562db8989a4e..ee7d6105a7a5 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -194,13 +194,26 @@ enum {
194 D_DONE, 194 D_DONE,
195}; 195};
196 196
197struct discard_info {
198 block_t lstart; /* logical start address */
199 block_t len; /* length */
200 block_t start; /* actual start address in dev */
201};
202
197struct discard_cmd { 203struct discard_cmd {
204 struct rb_node rb_node; /* rb node located in rb-tree */
205 union {
206 struct {
207 block_t lstart; /* logical start address */
208 block_t len; /* length */
209 block_t start; /* actual start address in dev */
210 };
211 struct discard_info di; /* discard info */
212
213 };
198 struct list_head list; /* command list */ 214 struct list_head list; /* command list */
199 struct completion wait; /* compleation */ 215 struct completion wait; /* compleation */
200 struct block_device *bdev; /* bdev */ 216 struct block_device *bdev; /* bdev */
201 block_t lstart; /* logical start address */
202 block_t start; /* actual start address in dev */
203 block_t len; /* length */
204 int state; /* state */ 217 int state; /* state */
205 int error; /* bio error */ 218 int error; /* bio error */
206}; 219};
@@ -217,6 +230,7 @@ struct discard_cmd_control {
217 atomic_t issued_discard; /* # of issued discard */ 230 atomic_t issued_discard; /* # of issued discard */
218 atomic_t issing_discard; /* # of issing discard */ 231 atomic_t issing_discard; /* # of issing discard */
219 atomic_t discard_cmd_cnt; /* # of cached cmd count */ 232 atomic_t discard_cmd_cnt; /* # of cached cmd count */
233 struct rb_root root; /* root of discard rb-tree */
220}; 234};
221 235
222/* for the list of fsync inodes, used only during recovery */ 236/* for the list of fsync inodes, used only during recovery */
@@ -517,6 +531,24 @@ static inline void set_extent_info(struct extent_info *ei, unsigned int fofs,
517 ei->len = len; 531 ei->len = len;
518} 532}
519 533
534static inline bool __is_discard_mergeable(struct discard_info *back,
535 struct discard_info *front)
536{
537 return back->lstart + back->len == front->lstart;
538}
539
540static inline bool __is_discard_back_mergeable(struct discard_info *cur,
541 struct discard_info *back)
542{
543 return __is_discard_mergeable(back, cur);
544}
545
546static inline bool __is_discard_front_mergeable(struct discard_info *cur,
547 struct discard_info *front)
548{
549 return __is_discard_mergeable(cur, front);
550}
551
520static inline bool __is_extent_mergeable(struct extent_info *back, 552static inline bool __is_extent_mergeable(struct extent_info *back,
521 struct extent_info *front) 553 struct extent_info *front)
522{ 554{
@@ -2573,6 +2605,16 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi);
2573/* 2605/*
2574 * extent_cache.c 2606 * extent_cache.c
2575 */ 2607 */
2608struct rb_entry *__lookup_rb_tree(struct rb_root *root,
2609 struct rb_entry *cached_re, unsigned int ofs);
2610struct rb_node **__lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
2611 struct rb_root *root, struct rb_node **parent,
2612 unsigned int ofs);
2613struct rb_entry *__lookup_rb_tree_ret(struct rb_root *root,
2614 struct rb_entry *cached_re, unsigned int ofs,
2615 struct rb_entry **prev_entry, struct rb_entry **next_entry,
2616 struct rb_node ***insert_p, struct rb_node **insert_parent,
2617 bool force);
2576unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink); 2618unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink);
2577bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext); 2619bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext);
2578void f2fs_drop_extent_tree(struct inode *inode); 2620void f2fs_drop_extent_tree(struct inode *inode);