diff mbox

[19/35] f2fs: Simplify page iteration loops

Message ID 20170601093245.29238-20-jack@suse.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kara June 1, 2017, 9:32 a.m. UTC
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.

CC: Jaegeuk Kim <jaegeuk@kernel.org>
CC: linux-f2fs-devel@lists.sourceforge.net
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/f2fs/checkpoint.c | 13 ++++-------
 fs/f2fs/node.c       | 65 +++++++++++++++++++---------------------------------
 2 files changed, 28 insertions(+), 50 deletions(-)

Comments

kernel test robot June 1, 2017, 1 p.m. UTC | #1
Hi Jan,

[auto build test WARNING on linus/master]
[also build test WARNING on v4.12-rc3]
[cannot apply to next-20170601]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jan-Kara/pagevec-API-cleanups/20170601-200653
config: x86_64-randconfig-x019-201722 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   fs//f2fs/checkpoint.c: In function 'sync_meta_pages':
>> fs//f2fs/checkpoint.c:313:5: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
        PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE)) {
        ^~~~~~~~~~~~~~~~~~~
--
   fs//f2fs/node.c: In function 'last_fsync_dnode':
>> fs//f2fs/node.c:1271:5: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
        PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE)) {
        ^~~~~~~~~~~~~~~~~~~
   fs//f2fs/node.c: In function 'fsync_node_pages':
   fs//f2fs/node.c:1421:5: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
        PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE)) {
        ^~~~~~~~~~~~~~~~~~~
   fs//f2fs/node.c: In function 'sync_node_pages':
   fs//f2fs/node.c:1533:5: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
        PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE)) {
        ^~~~~~~~~~~~~~~~~~~
   fs//f2fs/node.c: In function 'wait_on_node_pages_writeback':
   fs//f2fs/node.c:1630:5: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
        PAGECACHE_TAG_WRITEBACK, PAGEVEC_SIZE)) {
        ^~~~~~~~~~~~~~~~~~~~~~~

vim +313 fs//f2fs/checkpoint.c

   297	{
   298		struct address_space *mapping = META_MAPPING(sbi);
   299		pgoff_t index = 0, prev = ULONG_MAX;
   300		struct pagevec pvec;
   301		long nwritten = 0;
   302		int nr_pages;
   303		struct writeback_control wbc = {
   304			.for_reclaim = 0,
   305		};
   306		struct blk_plug plug;
   307	
   308		pagevec_init(&pvec, 0);
   309	
   310		blk_start_plug(&plug);
   311	
   312		while (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
 > 313					PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE)) {
   314			int i;
   315	
   316			for (i = 0; i < nr_pages; i++) {
   317				struct page *page = pvec.pages[i];
   318	
   319				if (prev == ULONG_MAX)
   320					prev = page->index - 1;
   321				if (nr_to_write != LONG_MAX && page->index != prev + 1) {

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index ea9c317b5916..6da86eac758a 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -296,9 +296,10 @@  long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
 						long nr_to_write)
 {
 	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,
 	};
@@ -308,13 +309,9 @@  long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
 
 	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];
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 4547c5c5cd98..dd53bcd9fc46 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1259,21 +1259,17 @@  void move_node_page(struct page *node_page, int gc_type)
 
 static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 {
-	pgoff_t index, end;
+	pgoff_t index;
 	struct pagevec pvec;
 	struct page *last_page = NULL;
+	int nr_pages;
 
 	pagevec_init(&pvec, 0);
 	index = 0;
-	end = ULONG_MAX;
-
-	while (index <= end) {
-		int i, nr_pages;
-		nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY,
-				min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
-		if (nr_pages == 0)
-			break;
+
+	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE)) {
+		int i;
 
 		for (i = 0; i < nr_pages; i++) {
 			struct page *page = pvec.pages[i];
@@ -1403,13 +1399,14 @@  static int f2fs_write_node_page(struct page *page,
 int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 			struct writeback_control *wbc, bool atomic)
 {
-	pgoff_t index, end;
+	pgoff_t index;
 	pgoff_t last_idx = ULONG_MAX;
 	struct pagevec pvec;
 	int ret = 0;
 	struct page *last_page = NULL;
 	bool marked = false;
 	nid_t ino = inode->i_ino;
+	int nr_pages;
 
 	if (atomic) {
 		last_page = last_fsync_dnode(sbi, ino);
@@ -1419,15 +1416,10 @@  int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 retry:
 	pagevec_init(&pvec, 0);
 	index = 0;
-	end = ULONG_MAX;
-
-	while (index <= end) {
-		int i, nr_pages;
-		nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY,
-				min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
-		if (nr_pages == 0)
-			break;
+
+	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE)) {
+		int i;
 
 		for (i = 0; i < nr_pages; i++) {
 			struct page *page = pvec.pages[i];
@@ -1525,25 +1517,21 @@  int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 
 int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
 {
-	pgoff_t index, end;
+	pgoff_t index;
 	struct pagevec pvec;
 	int step = 0;
 	int nwritten = 0;
 	int ret = 0;
+	int nr_pages;
 
 	pagevec_init(&pvec, 0);
 
 next_step:
 	index = 0;
-	end = ULONG_MAX;
-
-	while (index <= end) {
-		int i, nr_pages;
-		nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY,
-				min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
-		if (nr_pages == 0)
-			break;
+
+	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE)) {
+		int i;
 
 		for (i = 0; i < nr_pages; i++) {
 			struct page *page = pvec.pages[i];
@@ -1631,27 +1619,20 @@  int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
 
 int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
 {
-	pgoff_t index = 0, end = ULONG_MAX;
+	pgoff_t index = 0;
 	struct pagevec pvec;
 	int ret2, ret = 0;
+	int nr_pages;
 
 	pagevec_init(&pvec, 0);
 
-	while (index <= end) {
-		int i, nr_pages;
-		nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_WRITEBACK,
-				min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
-		if (nr_pages == 0)
-			break;
+	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_WRITEBACK, PAGEVEC_SIZE)) {
+		int i;
 
 		for (i = 0; i < nr_pages; i++) {
 			struct page *page = pvec.pages[i];
 
-			/* until radix tree lookup accepts end_index */
-			if (unlikely(page->index > end))
-				continue;
-
 			if (ino && ino_of_node(page) == ino) {
 				f2fs_wait_on_page_writeback(page, NODE, true);
 				if (TestClearPageError(page))