[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200110192942.25021-12-ira.weiny@intel.com>
Date: Fri, 10 Jan 2020 11:29:41 -0800
From: ira.weiny@...el.com
To: linux-kernel@...r.kernel.org
Cc: Ira Weiny <ira.weiny@...el.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
"Darrick J. Wong" <darrick.wong@...cle.com>,
Dan Williams <dan.j.williams@...el.com>,
Dave Chinner <david@...morbit.com>,
Christoph Hellwig <hch@....de>,
"Theodore Y. Ts'o" <tytso@....edu>, Jan Kara <jack@...e.cz>,
linux-ext4@...r.kernel.org, linux-xfs@...r.kernel.org,
linux-fsdevel@...r.kernel.org
Subject: [RFC PATCH V2 11/12] fs/xfs: Clean up locking in dax invalidate
From: Ira Weiny <ira.weiny@...el.com>
Define a variable to hold the lock flags to ensure that the correct
locks are returned or released on error.
Signed-off-by: Ira Weiny <ira.weiny@...el.com>
---
fs/xfs/xfs_ioctl.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 1ab0906c6c7f..9a35bf83eaa1 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1176,7 +1176,7 @@ xfs_ioctl_setattr_dax_invalidate(
int *join_flags)
{
struct inode *inode = VFS_I(ip);
- int error;
+ int error, flags;
*join_flags = 0;
@@ -1191,8 +1191,10 @@ xfs_ioctl_setattr_dax_invalidate(
if (S_ISDIR(inode->i_mode))
return 0;
+ flags = XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL;
+
/* lock, flush and invalidate mapping in preparation for flag change */
- xfs_ilock(ip, XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL);
+ xfs_ilock(ip, flags);
if ((fa->fsx_xflags & FS_XFLAG_DAX) == FS_XFLAG_DAX &&
!xfs_inode_supports_dax(ip)) {
@@ -1215,11 +1217,11 @@ xfs_ioctl_setattr_dax_invalidate(
if (error)
goto out_unlock;
- *join_flags = XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL;
+ *join_flags = flags;
return 0;
out_unlock:
- xfs_iunlock(ip, XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL);
+ xfs_iunlock(ip, flags);
return error;
}
--
2.21.0
Powered by blists - more mailing lists