* [PATCH] xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set
@ 2024-08-05 18:46 Darrick J. Wong
2024-08-06 13:07 ` Christoph Hellwig
2024-08-10 14:48 ` Souptick Joarder
0 siblings, 2 replies; 4+ messages in thread
From: Darrick J. Wong @ 2024-08-05 18:46 UTC (permalink / raw)
To: Chandan Babu R; +Cc: xfs
From: Darrick J. Wong <djwong@kernel.org>
If a file has the S_DAX flag (aka fsdax access mode) set, we cannot
allow users to change the realtime flag unless the datadev and rtdev
both support fsdax access modes. Even if there are no extents allocated
to the file, the setattr thread could be racing with another thread
that has already started down the write code paths.
Fixes: ba23cba9b3bdc ("fs: allow per-device dax status checking for filesystems")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/xfs_ioctl.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 4e933db75b12..6b13666d4e96 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -483,6 +483,17 @@ xfs_ioctl_setattr_xflags(
/* Can't change realtime flag if any extents are allocated. */
if (ip->i_df.if_nextents || ip->i_delayed_blks)
return -EINVAL;
+
+ /*
+ * If S_DAX is enabled on this file, we can only switch the
+ * device if both support fsdax. We can't update S_DAX because
+ * there might be other threads walking down the access paths.
+ */
+ if (IS_DAX(VFS_I(ip)) &&
+ (mp->m_ddev_targp->bt_daxdev == NULL ||
+ (mp->m_rtdev_targp &&
+ mp->m_rtdev_targp->bt_daxdev == NULL)))
+ return -EINVAL;
}
if (rtflag) {
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set
2024-08-05 18:46 [PATCH] xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set Darrick J. Wong
@ 2024-08-06 13:07 ` Christoph Hellwig
2024-08-10 14:48 ` Souptick Joarder
1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-08-06 13:07 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Chandan Babu R, xfs
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set
2024-08-05 18:46 [PATCH] xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set Darrick J. Wong
2024-08-06 13:07 ` Christoph Hellwig
@ 2024-08-10 14:48 ` Souptick Joarder
2024-08-10 16:41 ` Darrick J. Wong
1 sibling, 1 reply; 4+ messages in thread
From: Souptick Joarder @ 2024-08-10 14:48 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Chandan Babu R, xfs
On Tue, Aug 6, 2024 at 12:16 AM Darrick J. Wong <djwong@kernel.org> wrote:
>
> From: Darrick J. Wong <djwong@kernel.org>
>
> If a file has the S_DAX flag (aka fsdax access mode) set, we cannot
> allow users to change the realtime flag unless the datadev and rtdev
> both support fsdax access modes. Even if there are no extents allocated
> to the file, the setattr thread could be racing with another thread
> that has already started down the write code paths.
>
> Fixes: ba23cba9b3bdc ("fs: allow per-device dax status checking for filesystems")
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
> fs/xfs/xfs_ioctl.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 4e933db75b12..6b13666d4e96 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -483,6 +483,17 @@ xfs_ioctl_setattr_xflags(
> /* Can't change realtime flag if any extents are allocated. */
> if (ip->i_df.if_nextents || ip->i_delayed_blks)
> return -EINVAL;
> +
> + /*
> + * If S_DAX is enabled on this file, we can only switch the
> + * device if both support fsdax. We can't update S_DAX because
> + * there might be other threads walking down the access paths.
> + */
> + if (IS_DAX(VFS_I(ip)) &&
> + (mp->m_ddev_targp->bt_daxdev == NULL ||
> + (mp->m_rtdev_targp &&
> + mp->m_rtdev_targp->bt_daxdev == NULL)))
> + return -EINVAL;
Any chance of mp->m_ddev_targp == NULL ?
> }
>
> if (rtflag) {
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set
2024-08-10 14:48 ` Souptick Joarder
@ 2024-08-10 16:41 ` Darrick J. Wong
0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2024-08-10 16:41 UTC (permalink / raw)
To: Souptick Joarder; +Cc: Chandan Babu R, xfs
On Sat, Aug 10, 2024 at 08:18:16PM +0530, Souptick Joarder wrote:
> On Tue, Aug 6, 2024 at 12:16 AM Darrick J. Wong <djwong@kernel.org> wrote:
> >
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > If a file has the S_DAX flag (aka fsdax access mode) set, we cannot
> > allow users to change the realtime flag unless the datadev and rtdev
> > both support fsdax access modes. Even if there are no extents allocated
> > to the file, the setattr thread could be racing with another thread
> > that has already started down the write code paths.
> >
> > Fixes: ba23cba9b3bdc ("fs: allow per-device dax status checking for filesystems")
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> > fs/xfs/xfs_ioctl.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> > index 4e933db75b12..6b13666d4e96 100644
> > --- a/fs/xfs/xfs_ioctl.c
> > +++ b/fs/xfs/xfs_ioctl.c
> > @@ -483,6 +483,17 @@ xfs_ioctl_setattr_xflags(
> > /* Can't change realtime flag if any extents are allocated. */
> > if (ip->i_df.if_nextents || ip->i_delayed_blks)
> > return -EINVAL;
> > +
> > + /*
> > + * If S_DAX is enabled on this file, we can only switch the
> > + * device if both support fsdax. We can't update S_DAX because
> > + * there might be other threads walking down the access paths.
> > + */
> > + if (IS_DAX(VFS_I(ip)) &&
> > + (mp->m_ddev_targp->bt_daxdev == NULL ||
> > + (mp->m_rtdev_targp &&
> > + mp->m_rtdev_targp->bt_daxdev == NULL)))
> > + return -EINVAL;
> Any chance of mp->m_ddev_targp == NULL ?
No, m_ddev_targp is the device you give to mount. e.g. if you do
# mount /dev/sda /mnt
then m_ddev_targp is the block_device /dev/sda.
--D
> > }
> >
> > if (rtflag) {
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-10 16:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-05 18:46 [PATCH] xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set Darrick J. Wong
2024-08-06 13:07 ` Christoph Hellwig
2024-08-10 14:48 ` Souptick Joarder
2024-08-10 16:41 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox