Skip to contentSkip to conversation

f2fs: check if inode's state is dirty or not before skip fsync

PATCH In review Changman Lee 2 participants 8 messages Dec 1, 2014 – Dec 5, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: check if inode's state is dirty or not before skip fsync

It makes sense to check inode's state than check if inode page is dirty or not.

---
 fs/f2fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/file.c +2 -5
index 7c2ec3e..0c5ae87 100644
@@ -173,14 +173,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
 			!exist_written_data(sbi, ino, APPEND_INO)) {
-		struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
 
 		/* But we need to avoid that there are some inode updates */
-		if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino)) {
-			f2fs_put_page(i, 0);
+		if (is_inode_flag_set(fi, FI_DIRTY_INODE) ||
+					need_inode_block_update(sbi, ino))
 			goto go_write;
-		}
-		f2fs_put_page(i, 0);
 
 		if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
 				exist_written_data(sbi, ino, UPDATE_INO))
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 2 lines · Changman Lee

It makes sense to check inode's state than check if inode page is dirty or not.

Nice catch.
However, we should leave the original condition, since write_inode can be called in prior to this fsync call.
And, this is not a proper fix, since it still can skip to write its inode page.

How about this one?

fs/f2fs/file.c +6 -0
index 146e58a..6690599 100644
@@ -168,6 +168,12 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		return ret;
 	}
 
+	/* if the inode is dirty, let's recover all the time */
+	if (is_inode_flag_set(fi, FI_DIRTY_INODE)) {
+		update_inode_page(inode);
+		goto go_write;
+	}
+
 	/*
 	 * if there is no written data, don't waste time to write recovery info.
 	 */
Signature · 1 line
2.1.1
Quoted 41 lines
---
 fs/f2fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/file.c +2 -5
index 7c2ec3e..0c5ae87 100644
@@ -173,14 +173,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
 			!exist_written_data(sbi, ino, APPEND_INO)) {
-		struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
 
 		/* But we need to avoid that there are some inode updates */
-		if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino)) {
-			f2fs_put_page(i, 0);
+		if (is_inode_flag_set(fi, FI_DIRTY_INODE) ||
+					need_inode_block_update(sbi, ino))
 			goto go_write;
-		}
-		f2fs_put_page(i, 0);
 
 		if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
 				exist_written_data(sbi, ino, UPDATE_INO))
Signature · 13 lines
1.9.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#2 lore raw

Hi,

f2fs_dirty_inode just set fi->flag as FI_DIRTY_INODE not to call update_inode_page. Instead, we do it when f2fs_write_indoe is called. Do you have any reason to do like this?
How about move update_inode_page from write_inode to dirty_inode? And we can update inode page when mark_inode_dirty or mark_inode_dirty_sync is called. Then, we control write I/O in write_inode according to wbc->sync_mode.
Could you consider this once?

Thanks,

Quoted 72 lines · Jaegeuk Kim
Quoted 2 lines · Changman Lee

It makes sense to check inode's state than check if inode page is dirty or not.

Nice catch.
However, we should leave the original condition, since write_inode can be called in prior to this fsync call.
And, this is not a proper fix, since it still can skip to write its inode page.

How about this one?

fs/f2fs/file.c +6 -0
index 146e58a..6690599 100644
@@ -168,6 +168,12 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		return ret;
 	}
 
+	/* if the inode is dirty, let's recover all the time */
+	if (is_inode_flag_set(fi, FI_DIRTY_INODE)) {
+		update_inode_page(inode);
+		goto go_write;
+	}
+
 	/*
 	 * if there is no written data, don't waste time to write recovery info.
 	 */
Signature · 1 line
2.1.1
Quoted 41 lines
---
 fs/f2fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/file.c +2 -5
index 7c2ec3e..0c5ae87 100644
@@ -173,14 +173,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
 			!exist_written_data(sbi, ino, APPEND_INO)) {
-		struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
 
 		/* But we need to avoid that there are some inode updates */
-		if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino)) {
-			f2fs_put_page(i, 0);
+		if (is_inode_flag_set(fi, FI_DIRTY_INODE) ||
+					need_inode_block_update(sbi, ino))
 			goto go_write;
-		}
-		f2fs_put_page(i, 0);
 
 		if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
 				exist_written_data(sbi, ino, UPDATE_INO))
Signature · 13 lines
1.9.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#3 lore raw
Quoted 5 lines · Changman Lee

Hi,

f2fs_dirty_inode just set fi->flag as FI_DIRTY_INODE not to call update_inode_page. Instead, we do it when f2fs_write_indoe is called. Do you have any reason to do like this?

Actually, I'd like to use inode caches instead of dirty node pages as much as possible to mitigate memory pressure as well as reduce node page writes. But, the reality is that f2fs triggers update_inode_page frequently, since some inode information like i_blocks and i_links should be recovered consistently from sudden power-cuts.

Quoted 4 lines

How about move update_inode_page from write_inode to dirty_inode? And we can update inode page when mark_inode_dirty or mark_inode_dirty_sync is called. Then, we control write I/O in write_inode according to wbc->sync_mode.

What do you mean controlling write I/O in write_inode? The write_inode does not trigger any I/Os.
We're controlling node page writes by f2fs_write_node_pages.

Anyway, if we call update_inode_page in mark_inode_dirty, f2fs would suffer from a lot of dirty node pages.

Thanks,

Quoted 77 lines

Could you consider this once?

Thanks,

Quoted 72 lines · Jaegeuk Kim
Quoted 2 lines · Changman Lee

It makes sense to check inode's state than check if inode page is dirty or not.

Nice catch.
However, we should leave the original condition, since write_inode can be called in prior to this fsync call.
And, this is not a proper fix, since it still can skip to write its inode page.

How about this one?

fs/f2fs/file.c +6 -0
index 146e58a..6690599 100644
@@ -168,6 +168,12 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		return ret;
 	}
 
+	/* if the inode is dirty, let's recover all the time */
+	if (is_inode_flag_set(fi, FI_DIRTY_INODE)) {
+		update_inode_page(inode);
+		goto go_write;
+	}
+
 	/*
 	 * if there is no written data, don't waste time to write recovery info.
 	 */
Signature · 1 line
2.1.1
Quoted 41 lines
---
 fs/f2fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/file.c +2 -5
index 7c2ec3e..0c5ae87 100644
@@ -173,14 +173,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
 			!exist_written_data(sbi, ino, APPEND_INO)) {
-		struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
 
 		/* But we need to avoid that there are some inode updates */
-		if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino)) {
-			f2fs_put_page(i, 0);
+		if (is_inode_flag_set(fi, FI_DIRTY_INODE) ||
+					need_inode_block_update(sbi, ino))
 			goto go_write;
-		}
-		f2fs_put_page(i, 0);
 
 		if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
 				exist_written_data(sbi, ino, UPDATE_INO))
Signature · 13 lines
1.9.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#4 lore raw

Hi Jaegeuk,

Thanks for explanation.

Quoted 7 lines · Jaegeuk Kim
Quoted 5 lines · Changman Lee

Hi,

f2fs_dirty_inode just set fi->flag as FI_DIRTY_INODE not to call update_inode_page. Instead, we do it when f2fs_write_indoe is called. Do you have any reason to do like this?

Quoted 5 lines

Actually, I'd like to use inode caches instead of dirty node pages as much as possible to mitigate memory pressure as well as reduce node page writes. But, the reality is that f2fs triggers update_inode_page frequently, since some inode information like i_blocks and i_links should be recovered consistently from sudden power-cuts.

I got it. No objection.

Quoted 9 lines
Quoted 5 lines

How about move update_inode_page from write_inode to dirty_inode? And we can update inode page when mark_inode_dirty or mark_inode_dirty_sync is called. Then, we control write I/O in write_inode according to wbc->sync_mode.

What do you mean controlling write I/O in write_inode? The write_inode does not trigger any I/Os.
We're controlling node page writes by f2fs_write_node_pages.

Sorry, it's not enough for my explanation.
At __writeback_single_inode, it calls write_inode if inode is dirty. And at ext4_write_inode and btrfs_write_inode, they issue write according to wbc->sync_mode. However, current f2fs doesn't issue any write i/o. Could you review it?

Quoted 3 lines

Anyway, if we call update_inode_page in mark_inode_dirty, f2fs would suffer from a lot of dirty node pages.

Got it. But I think we should write dirty node after update_inode_page in write_inode if wbc->sync_mode == WB_SYNC_ALL.

Finally, I have one more question.
At f2fs_sync_file, in the case of need_cp is true and file_wrong_pino f2fs calls write_inode. But the inode isn't written back. Is it okay? Could you elaborate on it?

Thanks,

Quoted 80 lines

Thanks,

Quoted 77 lines

Could you consider this once?

Thanks,

Quoted 72 lines · Jaegeuk Kim
Quoted 2 lines · Changman Lee

It makes sense to check inode's state than check if inode page is dirty or not.

Nice catch.
However, we should leave the original condition, since write_inode can be called in prior to this fsync call.
And, this is not a proper fix, since it still can skip to write its inode page.

How about this one?

fs/f2fs/file.c +6 -0
index 146e58a..6690599 100644
@@ -168,6 +168,12 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		return ret;
 	}
 
+	/* if the inode is dirty, let's recover all the time */
+	if (is_inode_flag_set(fi, FI_DIRTY_INODE)) {
+		update_inode_page(inode);
+		goto go_write;
+	}
+
 	/*
 	 * if there is no written data, don't waste time to write recovery info.
 	 */
Signature · 1 line
2.1.1
Quoted 41 lines
---
 fs/f2fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/file.c +2 -5
index 7c2ec3e..0c5ae87 100644
@@ -173,14 +173,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
 			!exist_written_data(sbi, ino, APPEND_INO)) {
-		struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
 
 		/* But we need to avoid that there are some inode updates */
-		if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino)) {
-			f2fs_put_page(i, 0);
+		if (is_inode_flag_set(fi, FI_DIRTY_INODE) ||
+					need_inode_block_update(sbi, ino))
 			goto go_write;
-		}
-		f2fs_put_page(i, 0);
 
 		if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
 				exist_written_data(sbi, ino, UPDATE_INO))
Signature · 13 lines
1.9.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#5 lore raw
Quoted 30 lines · Changman Lee

Hi Jaegeuk,

Thanks for explanation.

Quoted 7 lines · Jaegeuk Kim
Quoted 5 lines · Changman Lee

Hi,

f2fs_dirty_inode just set fi->flag as FI_DIRTY_INODE not to call update_inode_page. Instead, we do it when f2fs_write_indoe is called. Do you have any reason to do like this?

Quoted 5 lines

Actually, I'd like to use inode caches instead of dirty node pages as much as possible to mitigate memory pressure as well as reduce node page writes. But, the reality is that f2fs triggers update_inode_page frequently, since some inode information like i_blocks and i_links should be recovered consistently from sudden power-cuts.

I got it. No objection.

Quoted 9 lines
Quoted 5 lines

How about move update_inode_page from write_inode to dirty_inode? And we can update inode page when mark_inode_dirty or mark_inode_dirty_sync is called. Then, we control write I/O in write_inode according to wbc->sync_mode.

What do you mean controlling write I/O in write_inode? The write_inode does not trigger any I/Os.
We're controlling node page writes by f2fs_write_node_pages.

Quoted 5 lines

Sorry, it's not enough for my explanation.
At __writeback_single_inode, it calls write_inode if inode is dirty. And at ext4_write_inode and btrfs_write_inode, they issue write according to wbc->sync_mode. However, current f2fs doesn't issue any write i/o. Could you review it?

Hi,

Well, I'm not quite sure that f2fs should do this. In terms of recovery, we don't need to do this.

Quoted 7 lines
Quoted 4 lines

Anyway, if we call update_inode_page in mark_inode_dirty, f2fs would suffer from a lot of dirty node pages.

Got it. But I think we should write dirty node after update_inode_page in write_inode if wbc->sync_mode == WB_SYNC_ALL.

Why do we have to do this?
Again, there is no problem wrt recovery, but that causes unnecessary IOs.

Quoted 6 lines

Finally, I have one more question.
At f2fs_sync_file, in the case of need_cp is true and file_wrong_pino f2fs calls write_inode. But the inode isn't written back. Is it okay? Could you elaborate on it?

No problem. That pino will be used only for fsynced inodes after checkpoint.

Thanks,

Quoted 83 lines

Thanks,

Quoted 80 lines

Thanks,

Quoted 77 lines

Could you consider this once?

Thanks,

Quoted 72 lines · Jaegeuk Kim
Quoted 2 lines · Changman Lee

It makes sense to check inode's state than check if inode page is dirty or not.

Nice catch.
However, we should leave the original condition, since write_inode can be called in prior to this fsync call.
And, this is not a proper fix, since it still can skip to write its inode page.

How about this one?

fs/f2fs/file.c +6 -0
index 146e58a..6690599 100644
@@ -168,6 +168,12 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		return ret;
 	}
 
+	/* if the inode is dirty, let's recover all the time */
+	if (is_inode_flag_set(fi, FI_DIRTY_INODE)) {
+		update_inode_page(inode);
+		goto go_write;
+	}
+
 	/*
 	 * if there is no written data, don't waste time to write recovery info.
 	 */
Signature · 1 line
2.1.1
Quoted 41 lines
---
 fs/f2fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/file.c +2 -5
index 7c2ec3e..0c5ae87 100644
@@ -173,14 +173,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
 			!exist_written_data(sbi, ino, APPEND_INO)) {
-		struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
 
 		/* But we need to avoid that there are some inode updates */
-		if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino)) {
-			f2fs_put_page(i, 0);
+		if (is_inode_flag_set(fi, FI_DIRTY_INODE) ||
+					need_inode_block_update(sbi, ino))
 			goto go_write;
-		}
-		f2fs_put_page(i, 0);
 
 		if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
 				exist_written_data(sbi, ino, UPDATE_INO))
Signature · 13 lines
1.9.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#6 lore raw
Quoted 55 lines · Jaegeuk Kim
Quoted 30 lines · Changman Lee

Hi Jaegeuk,

Thanks for explanation.

Quoted 7 lines · Jaegeuk Kim
Quoted 5 lines · Changman Lee

Hi,

f2fs_dirty_inode just set fi->flag as FI_DIRTY_INODE not to call update_inode_page. Instead, we do it when f2fs_write_indoe is called. Do you have any reason to do like this?

Quoted 5 lines

Actually, I'd like to use inode caches instead of dirty node pages as much as possible to mitigate memory pressure as well as reduce node page writes. But, the reality is that f2fs triggers update_inode_page frequently, since some inode information like i_blocks and i_links should be recovered consistently from sudden power-cuts.

I got it. No objection.

Quoted 9 lines
Quoted 5 lines

How about move update_inode_page from write_inode to dirty_inode? And we can update inode page when mark_inode_dirty or mark_inode_dirty_sync is called. Then, we control write I/O in write_inode according to wbc->sync_mode.

What do you mean controlling write I/O in write_inode? The write_inode does not trigger any I/Os.
We're controlling node page writes by f2fs_write_node_pages.

Quoted 5 lines

Sorry, it's not enough for my explanation.
At __writeback_single_inode, it calls write_inode if inode is dirty. And at ext4_write_inode and btrfs_write_inode, they issue write according to wbc->sync_mode. However, current f2fs doesn't issue any write i/o. Could you review it?

Hi,

Well, I'm not quite sure that f2fs should do this. In terms of recovery, we don't need to do this.

Quoted 7 lines
Quoted 4 lines

Anyway, if we call update_inode_page in mark_inode_dirty, f2fs would suffer from a lot of dirty node pages.

Got it. But I think we should write dirty node after update_inode_page in write_inode if wbc->sync_mode == WB_SYNC_ALL.

Why do we have to do this?
Again, there is no problem wrt recovery, but that causes unnecessary IOs.

Quoted 2 lines
Quoted 6 lines
Quoted 4 lines

Finally, I have one more question.
At f2fs_sync_file, in the case of need_cp is true and file_wrong_pino f2fs calls write_inode. But the inode isn't written back. Is it okay? Could you elaborate on it?

No problem. That pino will be used only for fsynced inodes after checkpoint.

I got it. My concern was started from this. If there is no problem, I think current f2fs_write_inode is also no problem. Thanks Jaegeuk.

Then, let's merge your suggestion below.

Lastly, I have curiosity related to write node; APPEND or UPDATE. Before fsync is called, isn't there any possiblity to be changed to APPEND from UPDATE. If so, we might lost recovery info.
I think we'd better check if there is a situation.

Regards,
Changman

Quoted 86 lines

Thanks,

Quoted 83 lines

Thanks,

Quoted 80 lines

Thanks,

Quoted 77 lines

Could you consider this once?

Thanks,

Quoted 72 lines · Jaegeuk Kim
Quoted 2 lines · Changman Lee

It makes sense to check inode's state than check if inode page is dirty or not.

Nice catch.
However, we should leave the original condition, since write_inode can be called in prior to this fsync call.
And, this is not a proper fix, since it still can skip to write its inode page.

How about this one?

fs/f2fs/file.c +6 -0
index 146e58a..6690599 100644
@@ -168,6 +168,12 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		return ret;
 	}
 
+	/* if the inode is dirty, let's recover all the time */
+	if (is_inode_flag_set(fi, FI_DIRTY_INODE)) {
+		update_inode_page(inode);
+		goto go_write;
+	}
+
 	/*
 	 * if there is no written data, don't waste time to write recovery info.
 	 */
Signature · 1 line
2.1.1
Quoted 41 lines
---
 fs/f2fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/file.c +2 -5
index 7c2ec3e..0c5ae87 100644
@@ -173,14 +173,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
 			!exist_written_data(sbi, ino, APPEND_INO)) {
-		struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
 
 		/* But we need to avoid that there are some inode updates */
-		if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino)) {
-			f2fs_put_page(i, 0);
+		if (is_inode_flag_set(fi, FI_DIRTY_INODE) ||
+					need_inode_block_update(sbi, ino))
 			goto go_write;
-		}
-		f2fs_put_page(i, 0);
 
 		if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
 				exist_written_data(sbi, ino, UPDATE_INO))
Signature · 13 lines
1.9.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#7 lore raw
Quoted 61 lines · Changman Lee
Quoted 60 lines · Jaegeuk Kim
Quoted 30 lines · Changman Lee

Hi Jaegeuk,

Thanks for explanation.

Quoted 7 lines · Jaegeuk Kim
Quoted 5 lines · Changman Lee

Hi,

f2fs_dirty_inode just set fi->flag as FI_DIRTY_INODE not to call update_inode_page. Instead, we do it when f2fs_write_indoe is called. Do you have any reason to do like this?

Quoted 5 lines

Actually, I'd like to use inode caches instead of dirty node pages as much as possible to mitigate memory pressure as well as reduce node page writes. But, the reality is that f2fs triggers update_inode_page frequently, since some inode information like i_blocks and i_links should be recovered consistently from sudden power-cuts.

I got it. No objection.

Quoted 9 lines
Quoted 5 lines

How about move update_inode_page from write_inode to dirty_inode? And we can update inode page when mark_inode_dirty or mark_inode_dirty_sync is called. Then, we control write I/O in write_inode according to wbc->sync_mode.

What do you mean controlling write I/O in write_inode? The write_inode does not trigger any I/Os.
We're controlling node page writes by f2fs_write_node_pages.

Quoted 5 lines

Sorry, it's not enough for my explanation.
At __writeback_single_inode, it calls write_inode if inode is dirty. And at ext4_write_inode and btrfs_write_inode, they issue write according to wbc->sync_mode. However, current f2fs doesn't issue any write i/o. Could you review it?

Hi,

Well, I'm not quite sure that f2fs should do this. In terms of recovery, we don't need to do this.

Quoted 7 lines
Quoted 4 lines

Anyway, if we call update_inode_page in mark_inode_dirty, f2fs would suffer from a lot of dirty node pages.

Got it. But I think we should write dirty node after update_inode_page in write_inode if wbc->sync_mode == WB_SYNC_ALL.

Why do we have to do this?
Again, there is no problem wrt recovery, but that causes unnecessary IOs.

Quoted 6 lines

Finally, I have one more question.
At f2fs_sync_file, in the case of need_cp is true and file_wrong_pino f2fs calls write_inode. But the inode isn't written back. Is it okay? Could you elaborate on it?

Quoted 7 lines
Quoted 1 line

No problem. That pino will be used only for fsynced inodes after checkpoint.

I got it. My concern was started from this. If there is no problem, I think current f2fs_write_inode is also no problem. Thanks Jaegeuk.

Then, let's merge your suggestion below.

Please, write and resubmit patch v2.
One additional comment is that conditions in the patch should have considered datasync like this.

	/* if the inode is dirty, let's recover all the time */
	if (!datasync && is_inode_flag_set(fi, FI_DIRTY_INODE)) {
		update_inode_page(inode);
		goto go_write;
	}

}

Quoted 5 lines

Lastly, I have curiosity related to write node; APPEND or UPDATE. Before fsync is called, isn't there any possiblity to be changed to APPEND from UPDATE. If so, we might lost recovery info.

No, APPEND and UPDATE are orthogonal.

Thanks,

Quoted 91 lines

I think we'd better check if there is a situation.

Regards,
Changman

Quoted 86 lines

Thanks,

Quoted 83 lines

Thanks,

Quoted 80 lines

Thanks,

Quoted 77 lines

Could you consider this once?

Thanks,

Quoted 72 lines · Jaegeuk Kim
Quoted 2 lines · Changman Lee

It makes sense to check inode's state than check if inode page is dirty or not.

Nice catch.
However, we should leave the original condition, since write_inode can be called in prior to this fsync call.
And, this is not a proper fix, since it still can skip to write its inode page.

How about this one?

fs/f2fs/file.c +6 -0
index 146e58a..6690599 100644
@@ -168,6 +168,12 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		return ret;
 	}
 
+	/* if the inode is dirty, let's recover all the time */
+	if (is_inode_flag_set(fi, FI_DIRTY_INODE)) {
+		update_inode_page(inode);
+		goto go_write;
+	}
+
 	/*
 	 * if there is no written data, don't waste time to write recovery info.
 	 */
Signature · 1 line
2.1.1
Quoted 41 lines
---
 fs/f2fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/file.c +2 -5
index 7c2ec3e..0c5ae87 100644
@@ -173,14 +173,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
 			!exist_written_data(sbi, ino, APPEND_INO)) {
-		struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
 
 		/* But we need to avoid that there are some inode updates */
-		if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino)) {
-			f2fs_put_page(i, 0);
+		if (is_inode_flag_set(fi, FI_DIRTY_INODE) ||
+					need_inode_block_update(sbi, ino))
 			goto go_write;
-		}
-		f2fs_put_page(i, 0);
 
 		if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
 				exist_written_data(sbi, ino, UPDATE_INO))
Signature · 13 lines
1.9.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel