public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* synchronous mounts
@ 2001-11-15  8:03 Andrew Morton
  2001-11-15 21:45 ` Stephen C. Tweedie
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Morton @ 2001-11-15  8:03 UTC (permalink / raw)
  To: lkml; +Cc: Neil Brown

Linux is not syncing write() data for files on synchronously mounted
filesystems, and it isn't syncing write() data for ext2/3 files which
are operating under `chattr +S'.

Is this deliberate, or a bug?

This patch makes write()s data-synchronous.  There's a fix-for-the-fix
here for ext3.  Other filesystems which are second-guessing the generic
layer's behaviour may also end up doing a double sync with this patch.

Really, generic_osync_inode() needs to be front-ended by
an inode_operations method.


--- linux-2.4.15-pre4/mm/filemap.c	Mon Nov 12 11:16:12 2001
+++ linux-akpm/mm/filemap.c	Wed Nov 14 22:50:25 2001
@@ -2916,8 +2916,10 @@ unlock:
 
 	/* For now, when the user asks for O_SYNC, we'll actually
 	 * provide O_DSYNC. */
-	if ((status >= 0) && (file->f_flags & O_SYNC))
-		status = generic_osync_inode(inode, OSYNC_METADATA|OSYNC_DATA);
+	if (status >= 0) {
+		if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
+			status = generic_osync_inode(inode, OSYNC_METADATA|OSYNC_DATA);
+	}
 	
 	err = written ? written : status;
 out:
--- linux-2.4.15-pre4/fs/ext3/file.c	Mon Nov 12 11:16:12 2001
+++ linux-akpm/fs/ext3/file.c	Wed Nov 14 23:52:08 2001
@@ -61,22 +61,19 @@ static int ext3_open_file (struct inode 
 static ssize_t
 ext3_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
 {
-	int ret;
 	struct inode *inode = file->f_dentry->d_inode;
 
-	ret = generic_file_write(file, buf, count, ppos);
-	if ((ret >= 0) && IS_SYNC(inode)) {
-		if (file->f_flags & O_SYNC) {
-			/*
-			 * generic_osync_inode() has already done the sync
-			 */
-		} else {
-			int ret2 = ext3_force_commit(inode->i_sb);
-			if (ret2)
-				ret = ret2;
-		}
-	}
-	return ret;
+	/*
+	 * Nasty: if the file is subject to synchronous writes then we need
+	 * to force generic_osync_inode() to call ext3_write_inode().
+	 * We do that by marking the inode dirty.  This adds much more
+	 * computational expense than we need, but we're going to sync
+	 * anyway.
+	 */
+	if (IS_SYNC(inode) || (file->f_flags & O_SYNC))
+		mark_inode_dirty(inode);
+
+	return generic_file_write(file, buf, count, ppos);
 }
 
 struct file_operations ext3_file_operations = {

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

end of thread, other threads:[~2001-11-17  7:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-15  8:03 synchronous mounts Andrew Morton
2001-11-15 21:45 ` Stephen C. Tweedie
2001-11-15 22:02   ` Andrew Morton
2001-11-15 23:05     ` Stephen C. Tweedie
2001-11-16  0:19   ` Jeff Garzik
2001-11-16  8:33     ` Andrew Morton
2001-11-16 10:47       ` Matthias Andree
2001-11-16 12:28     ` Stephen C. Tweedie
2001-11-16 13:28       ` Jeff Garzik
2001-11-16 13:37       ` Jeff Garzik
2001-11-16 22:40       ` Matthias Andree
2001-11-16  3:07   ` Neil Brown
2001-11-17  7:13     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox