Skip to contentSkip to conversation

f2fs: simplify page iteration loops

PATCH New [email protected] 1 participant 1 message Nov 16, 2017 F2FS file system

lore
Share & tools
lore
#0 lore raw

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.

---

 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
diff -puN fs/f2fs/checkpoint.c~f2fs-simplify-page-iteration-loops fs/f2fs/checkpoint.c
@@ -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_info
 
 	blk_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