f2fs: simplify page iteration loops
PATCH 59/131 f2fs: simplify page iteration loops
From: Jan Kara <[email protected]>
Subject: f2fs: simplify page iteration loops
In several places we want to iterate over all tagged pages in a mapping. However the code was apparently copied from places that iterate only over a limited range and thus it checks for index <= end, optimizes the case where we are coming close to range end which is all pointless when end == ULONG_MAX. So just remove this dead code.
[[email protected]: fix warnings]
Signed-off-by Jan Kara <[email protected]>
Reviewed-by Daniel Jordan <[email protected]>
Reviewed-by Chao Yu <[email protected]>
Cc Jaegeuk Kim <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
fs/f2fs/checkpoint.c | 13 +++------ fs/f2fs/node.c | 59 +++++++++++++---------------------------- 2 files changed, 25 insertions(+), 47 deletions(-)
fs/f2fs/checkpoint.c renamed from fs/f2fs/checkpoint.c~f2fs-simplify-page-iteration-loops +5 -8
@@ -305,9 +305,10 @@ long sync_meta_pages(struct f2fs_sb_info long nr_to_write, enum iostat_type io_type) { struct address_space *mapping = META_MAPPING(sbi); -pgoff_t index =0 , end =ULONG_MAX , prev =ULONG_MAX ; +pgoff_t index =0 , prev =ULONG_MAX ;struct pagevec pvec;long nwritten =0 ; +int nr_pages;struct writeback_control wbc = { .for_reclaim =0 , };
@@ -317,13 +318,9 @@ long sync_meta_pages(struct f2fs_sb_infoblk_start_plug (&plug); -while (index <= end) { -int i, nr_pages; - nr_pages =pagevec_lookup_tag (&pvec, mapping, &index, -PAGECACHE_TAG_DIRTY , -min (end - index, (pgoff_t )PAGEVEC_SIZE -1 ) +1 ); -if (unlikely (nr_pages ==0 )) -break ; +while ((nr_pages =pagevec_lookup_tag (&pvec, mapping, &index, +PAGECACHE_TAG_DIRTY ,PAGEVEC_SIZE ))) { +int i;for (i =0 ; i < nr_pages; i++) {struct page *page = pvec.pages[i];
fs/f2fs/node.c renamed from fs/f2fs/node.c~f2fs-simplify-page-iteration-loops +20 -38
117 lines not on this page · raw message