Skip to contentSkip to conversation

f2fs: cover number of dirty node pages under node_write lock

PATCH In review Jaegeuk Kim 2 participants 5 messages Sep 15, 2015 – Sep 17, 2015

Subsystems (2)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/2 f2fs: cover number of dirty node pages under node_write lock

This number is referenced by checkpoint under node_write lock.

---
 fs/f2fs/node.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
fs/f2fs/node.c +8 -7
index 27d1a74..4d9bedf 100644
@@ -1323,23 +1323,24 @@ static int f2fs_write_node_page(struct page *page,
 	nid = nid_of_node(page);
 	f2fs_bug_on(sbi, page->index != nid);
 
+	if (wbc->for_reclaim) {
+		if (!down_read_trylock(&sbi->node_write))
+			goto redirty_out;
+	} else {
+		down_read(&sbi->node_write);
+	}
+
 	get_node_info(sbi, nid, &ni);
 
 	/* This page is already truncated */
 	if (unlikely(ni.blk_addr == NULL_ADDR)) {
 		ClearPageUptodate(page);
 		dec_page_count(sbi, F2FS_DIRTY_NODES);
+		up_read(&sbi->node_write);
 		unlock_page(page);
 		return 0;
 	}
 
-	if (wbc->for_reclaim) {
-		if (!down_read_trylock(&sbi->node_write))
-			goto redirty_out;
-	} else {
-		down_read(&sbi->node_write);
-	}
-
 	set_page_writeback(page);
 	fio.blk_addr = ni.blk_addr;
 	write_node_page(nid, &fio);
Signature · 4 lines
2.1.1


------------------------------------------------------------------------------
author maintainer
#1 lore raw

PATCH 2/2 f2fs: no need to lock for update_inode_page all the time

As comment says, we don't need to call f2fs_lock_op in write_inode to prevent from producing dirty node pages all the time.
That happens only when there is not enough free sections and we can avoid that by calling balance_fs in prior to that.

---
 fs/f2fs/inode.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
fs/f2fs/inode.c +3 -7
index 35aae65..0fc4d02 100644
@@ -296,16 +296,12 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
 		return 0;
 
 	/*
-	 * We need to lock here to prevent from producing dirty node pages
+	 * We need to balance fs here to prevent from producing dirty node pages
 	 * during the urgent cleaning time when runing out of free sections.
 	 */
-	f2fs_lock_op(sbi);
-	update_inode_page(inode);
-	f2fs_unlock_op(sbi);
-
-	if (wbc)
-		f2fs_balance_fs(sbi);
+	f2fs_balance_fs(sbi);
 
+	update_inode_page(inode);
 	return 0;
 }
 
Signature · 1 line
2.1.1
#2 lore raw

RE: [f2fs-dev] [PATCH 2/2] f2fs: no need to lock for update_inode_page all the time

Hi Jaegeuk,

Quoted 26 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, September 16, 2015 12:56 AM
To: [email protected]; [email protected]; [email protected]
Cc: Jaegeuk Kim
Subject: [f2fs-dev] [PATCH 2/2] f2fs: no need to lock for update_inode_page all the time

As comment says, we don't need to call f2fs_lock_op in write_inode to prevent from producing dirty node pages all the time.
That happens only when there is not enough free sections and we can avoid that by calling balance_fs in prior to that.

---
 fs/f2fs/inode.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
fs/f2fs/inode.c +0 -0
index 35aae65..0fc4d02 100644
@@ -296,16 +296,12 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
 		return 0;
 
 	/*

fs/f2fs/inode.c int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) · line 307

Quoted 10 lines
fs/f2fs/inode.c +1 -7
-	 * We need to lock here to prevent from producing dirty node pages
+	 * We need to balance fs here to prevent from producing dirty node pages
 	 * during the urgent cleaning time when runing out of free sections.
 	 */
-	f2fs_lock_op(sbi);
-	update_inode_page(inode);
-	f2fs_unlock_op(sbi);
-
-	if (wbc)
-		f2fs_balance_fs(sbi);

f2fs_balance_fs was moved here intentionally by Jin Xu in commit 92c4342fb72a ("f2fs: avoid writing inode redundantly when creating a file") to avoid redundantly inode page submitting, I was confused since I didn't know all history here. So, should we change the position of f2fs_balance_fs?

Thanks,

Quoted 15 lines
fs/f2fs/inode.c +2 -1
+	f2fs_balance_fs(sbi);
 
+	update_inode_page(inode);
 	return 0;
 }
 
--

2.1.1

------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#3 lore raw

Re: [f2fs-dev] [PATCH 2/2] f2fs: no need to lock for update_inode_page all the time

Quoted 27 lines · Chao Yu

Hi Jaegeuk,

Quoted 25 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, September 16, 2015 12:56 AM
To: [email protected]; [email protected]; [email protected]
Cc: Jaegeuk Kim
Subject: [f2fs-dev] [PATCH 2/2] f2fs: no need to lock for update_inode_page all the time

As comment says, we don't need to call f2fs_lock_op in write_inode to prevent from producing dirty node pages all the time.
That happens only when there is not enough free sections and we can avoid that by calling balance_fs in prior to that.

---
 fs/f2fs/inode.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
fs/f2fs/inode.c +0 -0
index 35aae65..0fc4d02 100644
@@ -296,16 +296,12 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
 		return 0;
 
Quoted 16 lines

fs/f2fs/inode.c int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) · line 307

Quoted 11 lines
fs/f2fs/inode.c +1 -7
 	/*
-	 * We need to lock here to prevent from producing dirty node pages
+	 * We need to balance fs here to prevent from producing dirty node pages
 	 * during the urgent cleaning time when runing out of free sections.
 	 */
-	f2fs_lock_op(sbi);
-	update_inode_page(inode);
-	f2fs_unlock_op(sbi);
-
-	if (wbc)
-		f2fs_balance_fs(sbi);

f2fs_balance_fs was moved here intentionally by Jin Xu in commit 92c4342fb72a ("f2fs: avoid writing inode redundantly when creating a file") to avoid redundantly inode page submitting, I was confused since I didn't know all history here. So, should we change the position of f2fs_balance_fs?

Oh, I remained that order. Fixed and merged.

Thanks,

Quoted 18 lines

Thanks,

Quoted 15 lines
fs/f2fs/inode.c +2 -1
+	f2fs_balance_fs(sbi);
 
+	update_inode_page(inode);
 	return 0;
 }
 
--

2.1.1

------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reviewed-by on v1 1/2
#4 lore raw
In reply to Jaegeuk Kim
Quoted 11 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, September 16, 2015 12:56 AM
To: [email protected]; [email protected]; [email protected]
Cc: Jaegeuk Kim
Subject: [f2fs-dev] [PATCH 1/2] f2fs: cover number of dirty node pages under node_write lock

This number is referenced by checkpoint under node_write lock.