linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix handling errors got by f2fs_write_inode
@ 2012-12-14  7:27 Jaegeuk Kim
  2012-12-19  8:47 ` [PATCH v2] " Jaegeuk Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Jaegeuk Kim @ 2012-12-14  7:27 UTC (permalink / raw)
  To: me, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

Ruslan reported that f2fs hangs with an infinite loop in f2fs_sync_file():

	while (sync_node_pages(sbi, inode->i_ino, &wbc) == 0)
		f2fs_write_inode(inode, NULL);

If f2fs_write_inode() returns an error due to whatever situations, there would
be no dirty node pages so that sync_node_pages() returns zero.
(i.e., zero means nothing was written.)

This patch fixes f2fs behavior to deal with that issue.

Reported-by: Ruslan N. Marchenko <me@ruff.mobi>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
---
 fs/f2fs/file.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f9e085d..6527134 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -159,16 +159,19 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		need_cp = true;
 	if (need_to_sync_dir(sbi, inode))
 		need_cp = true;
-
-	f2fs_write_inode(inode, NULL);
+write_inode:
+	ret = f2fs_write_inode(inode, NULL);
+	if (ret)
+		goto out;
 
 	if (need_cp) {
 		/* all the dirty node pages should be flushed for POR */
 		ret = f2fs_sync_fs(inode->i_sb, 1);
 		clear_inode_flag(F2FS_I(inode), FI_NEED_CP);
 	} else {
-		while (sync_node_pages(sbi, inode->i_ino, &wbc) == 0)
-			f2fs_write_inode(inode, NULL);
+		/* if there is no written node page, write its inode page */
+		if (sync_node_pages(sbi, inode->i_ino, &wbc) == 0)
+			goto write_inode;
 		filemap_fdatawait_range(sbi->node_inode->i_mapping,
 							0, LONG_MAX);
 	}
-- 
1.8.0.1.250.gb7973fb


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-19  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-14  7:27 [PATCH] f2fs: fix handling errors got by f2fs_write_inode Jaegeuk Kim
2012-12-19  8:47 ` [PATCH v2] " Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).