xfs
[Top] [All Lists]

[PATCH 2/3] xfs: prevent against ioend livelocks in xfs_file_fsync

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/3] xfs: prevent against ioend livelocks in xfs_file_fsync
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Tue, 26 Jul 2011 11:07:11 -0400
In-reply-to: <20110726150633.GA17400@xxxxxxxxxxxxx>
References: <20110726150633.GA17400@xxxxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
We need to take some locks to prevent new ioends from coming in when we wait
for all existing ones to go away.  Up to Linux 3.0 that was done using the
i_mutex held by the VFS fsync code, but now that we are called without
it we need to take care of it ourselves.  Use the I/O lock instead of
i_mutex just like we do in other places.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Index: linux-2.6/fs/xfs/linux-2.6/xfs_file.c
===================================================================
--- linux-2.6.orig/fs/xfs/linux-2.6/xfs_file.c  2011-07-25 23:50:35.081563423 
+0200
+++ linux-2.6/fs/xfs/linux-2.6/xfs_file.c       2011-07-25 23:51:18.098229833 
+0200
@@ -149,7 +149,9 @@ xfs_file_fsync(
 
        xfs_iflags_clear(ip, XFS_ITRUNCATED);
 
+       xfs_ilock(ip, XFS_IOLOCK_SHARED);
        xfs_ioend_wait(ip);
+       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
 
        if (mp->m_flags & XFS_MOUNT_BARRIER) {
                /*

<Prev in Thread] Current Thread [Next in Thread>