Skip to contentSkip to conversation

xfs: fix xfs_file_fsync() call in O_SYNC case

PATCH New Josef Bacik 1 participant 1 message Jul 19, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix xfs_file_fsync() call in O_SYNC case

When I pushed down the i_mutex into ->fsync() I created a deadlock with xfs when writing O_SYNC. Fix this by dropping the filemap_write_and_wait_range() since it's done in ->fsync() now and call xfs_file_fsync() where we've dropped the i_mutex. This was suggested by Christoph and has passed xfstests. Thanks,

---
 fs/xfs/linux-2.6/xfs_file.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)
fs/xfs/linux-2.6/xfs_file.c +2 -9
index 9183f75..1db8bd8 100644
@@ -887,18 +887,11 @@ xfs_file_aio_write(
 	/* Handle various SYNC-type writes */
 	if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) {
 		loff_t end = pos + ret - 1;
-		int error, error2;
 
 		xfs_rw_iunlock(ip, iolock);
-		error = filemap_write_and_wait_range(mapping, pos, end);
+		ret = -xfs_file_fsync(file, pos, end,
+				      (file->f_flags & __O_SYNC) ? 0 : 1);
 		xfs_rw_ilock(ip, iolock);
-
-		error2 = -xfs_file_fsync(file, pos, end,
-					 (file->f_flags & __O_SYNC) ? 0 : 1);
-		if (error)
-			ret = error;
-		else if (error2)
-			ret = error2;
 	}
 
 out_unlock:
Signature · 1 line
1.7.5.2