diff mbox series

[V5,08/12] fs/xfs: Hold off aops users while changing DAX state

Message ID 20200227052442.22524-9-ira.weiny@intel.com (mailing list archive)
State New, archived
Headers show
Series Enable per-file/per-directory DAX operations V5 | expand

Commit Message

Ira Weiny Feb. 27, 2020, 5:24 a.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

XFS requires the use of the aops of an inode to be quiesced prior to
changing the aops vector to/from the DAX vector.

Take the aops write lock while changing DAX state.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
Changes from v4:
	Open code the aops write lock
	Obsolete: Clean up lock name in comments
	Obsolete: Change #define: XFS_DAX_EXCL => XFS_AOPSLOCK_EXCL

Changes from v3:
	Change locking function names to reflect changes in previous
	patches.

Changes from V2:
	Change name of patch (WAS: fs/xfs: Add lock/unlock state to xfs)
	Remove the xfs specific lock and move to the vfs layer.
		We still use XFS_LOCK_DAX_EXCL to be able to pass this
		flag through to the transaction code.  But we no longer
		have a lock specific to xfs.  This removes a lot of code
		from the XFS layer, preps us for using this in ext4, and
		is actually more straight forward now that all the
		locking requirements are better known.

	Fix locking order comment
	Rework for new 'state' names
	(Other comments on the previous patch are not applicable with
	new patch as much of the code was removed in favor of the vfs
	level lock)
---
 fs/xfs/xfs_ioctl.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 498fae2ef9f6..6c4d4ea3b6b6 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1444,7 +1444,11 @@  xfs_ioctl_setattr(
 	 * or cancel time, so need to be passed through to
 	 * xfs_ioctl_setattr_get_trans() so it can apply them to the join call
 	 * appropriately.
+	 *
+	 * Further we hold off aops users until we have completed any potential
+	 * changing of aops due to attribute changes.
 	 */
+	inode_aops_down_write(VFS_I(ip));
 	code = xfs_ioctl_setattr_dax_invalidate(ip, fa, &join_flags);
 	if (code)
 		goto error_free_dquots;
@@ -1527,6 +1531,7 @@  xfs_ioctl_setattr(
 	xfs_qm_dqrele(udqp);
 	xfs_qm_dqrele(pdqp);
 
+	inode_aops_up_write(VFS_I(ip));
 	return code;
 
 error_trans_cancel:
@@ -1534,6 +1539,7 @@  xfs_ioctl_setattr(
 error_free_dquots:
 	xfs_qm_dqrele(udqp);
 	xfs_qm_dqrele(pdqp);
+	inode_aops_up_write(VFS_I(ip));
 	return code;
 }
 
@@ -1603,7 +1609,11 @@  xfs_ioc_setxflags(
 	 * or cancel time, so need to be passed through to
 	 * xfs_ioctl_setattr_get_trans() so it can apply them to the join call
 	 * appropriately.
+	 *
+	 * Further we hold off aops users until we have completed any potential
+	 * changing of aops due to attribute changes.
 	 */
+	inode_aops_down_write(VFS_I(ip));
 	error = xfs_ioctl_setattr_dax_invalidate(ip, &fa, &join_flags);
 	if (error)
 		goto out_drop_write;
@@ -1630,6 +1640,7 @@  xfs_ioc_setxflags(
 	error = xfs_trans_commit(tp);
 out_drop_write:
 	mnt_drop_write_file(filp);
+	inode_aops_up_write(VFS_I(ip));
 	return error;
 }