patch-2.1.66 linux/fs/buffer.c

Next file: linux/fs/ext2/fsync.c
Previous file: linux/drivers/scsi/ppa.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.65/linux/fs/buffer.c linux/fs/buffer.c
@@ -196,7 +196,7 @@
 			 */
 			if (wait && buffer_req(bh) && !buffer_locked(bh) &&
 			    !buffer_dirty(bh) && !buffer_uptodate(bh)) {
-				err = 1;
+				err = -EIO;
 				continue;
 			}
 
@@ -288,7 +288,22 @@
  
 int file_fsync(struct file *filp, struct dentry *dentry)
 {
-	return fsync_dev(dentry->d_inode->i_dev);
+	struct inode * inode = dentry->d_inode;
+	struct super_block * sb;
+	kdev_t dev;
+
+	/* sync the inode to buffers */
+	write_inode_now(inode);
+
+	/* sync the superblock to buffers */
+	sb = inode->i_sb;
+	wait_on_super(sb);
+	if (sb->s_op && sb->s_op->write_super)
+		sb->s_op->write_super(sb);
+
+	/* .. finally sync the buffers to disk */
+	dev = inode->i_dev;
+	return sync_buffers(dev, 1);
 }
 
 asmlinkage int sys_fsync(unsigned int fd)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov