From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josef Bacik Subject: [PATCH] xfs: fix xfs_file_fsync() call in O_SYNC case Date: Tue, 19 Jul 2011 12:19:17 -0400 Message-ID: <1311092357-17994-1-git-send-email-josef@redhat.com> To: hch@infradead.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, david@fromorbit.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33454 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751462Ab1GSQTi (ORCPT ); Tue, 19 Jul 2011 12:19:38 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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, Signed-off-by: Josef Bacik --- fs/xfs/linux-2.6/xfs_file.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-) diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c index 9183f75..1db8bd8 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/linux-2.6/xfs_file.c @@ -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: -- 1.7.5.2