[PATCH] ext4: Ensure writecache to disk in no journal mode

Previous thread: [Bug 12624] umount hangs after fsstress with data=journal by bugzilla-daemon on Friday, March 26, 2010 - 3:00 am. (1 message)

Next thread: Re: [PATCH 3/3] ext4: symlink must be handled via filesystem specific operation by tytso on Sunday, April 4, 2010 - 1:05 pm. (10 messages)
From: Surbhi Palande
Date: Friday, March 26, 2010 - 9:21 am

Ensure that in the no journal mode the write cache is flushed to the disk by
calling a blkdev_issue_flush() which issues a WRITE_BARRIER if necessary.

Signed-off-by: Surbhi Palande <surbhi.palande@canonical.com>
---
 fs/ext4/fsync.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index d6049e4..1d73a50 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -67,8 +67,12 @@ int ext4_sync_file(struct file *file, struct dentry *dentry, int datasync)
 	if (ret < 0)
 		return ret;
 
-	if (!journal)
-		return simple_fsync(file, dentry, datasync);
+	if (!journal) {
+		ret = simple_fsync(file, dentry, datasync);
+		if (test_opt(inode->i_sb, BARRIER))
+			blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
+		return ret;
+	}
 
 	/*
 	 * data=writeback,ordered:
-- 
1.6.3.3

--

From: Dmitry Monakhov
Date: Friday, March 26, 2010 - 9:37 am

As soon as i understand, nojournal mode is assumed to be used for
fail-free block devices(raid + UPS). So we don't have to worry about
--

From: Ric Wheeler
Date: Friday, March 26, 2010 - 10:16 am

I don't think that is a safe assumption. If users want that behavior, 
they can mount with fs without barriers...


--

From: Eric Sandeen
Date: Friday, March 26, 2010 - 10:40 am

No, I don't think so - even with "fail-free" storage, a system crash
still results in an inconsistent filesystem; with nojournalling you've

yes, I agree with Ric - even if you don't have journalling, the proper
sequence of sync calls should still result in data permanently on disk
by default.  (though I think using mount -o nobarrier for this purpose,
in absence of journalling, overloads the option a little...)

-Eric
--

Previous thread: [Bug 12624] umount hangs after fsstress with data=journal by bugzilla-daemon on Friday, March 26, 2010 - 3:00 am. (1 message)

Next thread: Re: [PATCH 3/3] ext4: symlink must be handled via filesystem specific operation by tytso on Sunday, April 4, 2010 - 1:05 pm. (10 messages)