diff options
author | Chao Yu <yuchao0@huawei.com> | 2017-04-14 11:24:55 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-04-19 14:00:40 -0400 |
commit | 004b68621897f06aa2817e7438469d23f4a3a284 (patch) | |
tree | 662ba33d4d48cf7704f4adf43c6e805f12b22951 /fs/f2fs/f2fs.h | |
parent | d40d30c5aa5227546030d3d7b0a6a38c6c85933a (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.h | 48 |
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 | ||
197 | struct 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 | |||
197 | struct discard_cmd { | 203 | struct 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 | ||
534 | static 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 | |||
540 | static 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 | |||
546 | static 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 | |||
520 | static inline bool __is_extent_mergeable(struct extent_info *back, | 552 | static 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 | */ |
2608 | struct rb_entry *__lookup_rb_tree(struct rb_root *root, | ||
2609 | struct rb_entry *cached_re, unsigned int ofs); | ||
2610 | struct 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); | ||
2613 | struct 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); | ||
2576 | unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink); | 2618 | unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink); |
2577 | bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext); | 2619 | bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext); |
2578 | void f2fs_drop_extent_tree(struct inode *inode); | 2620 | void f2fs_drop_extent_tree(struct inode *inode); |