patch-2.1.57 linux/drivers/block/ataflop.c

Next file: linux/drivers/block/floppy.c
Previous file: linux/drivers/block/acsi_slm.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.56/linux/drivers/block/ataflop.c linux/drivers/block/ataflop.c
@@ -1978,10 +1978,14 @@
 
   drive = inode->i_rdev & 3;
 
-  if (!filp || (filp->f_mode & (2 | OPEN_WRITE_BIT)))
-    /* if the file is mounted OR (writable now AND writable at open
-       time) Linus: Does this cover all cases? */
-    block_fsync (filp, filp->f_dentry);
+	/*
+	 * If filp is NULL, we're being called from blkdev_release
+	 * or after a failed mount attempt.  In the former case the
+	 * device has already been sync'ed, and in the latter no
+	 * sync is required.  Otherwise, sync if filp is writable.
+	 */
+	if (filp && (filp->f_mode & (2 | OPEN_WRITE_BIT)))
+		block_fsync (filp, filp->f_dentry);
 
   if (fd_ref[drive] < 0)
     fd_ref[drive] = 0;

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