linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode
@ 2025-07-29 11:00 Andrey Albershteyn
  2025-07-29 11:00 ` [PATCH 1/3] xfs: allow renames of project-less inodes Andrey Albershteyn
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Andrey Albershteyn @ 2025-07-29 11:00 UTC (permalink / raw)
  To: cem, djwong, linux-xfs; +Cc: Andrey Albershteyn

With addition of new syscalls file_getattr/file_setattr allow changing
filesystem inode attributes on special files. Fix project ID inheritance
for special files in renames.

Cc: linux-xfs@vger.kernel.org

---
Darrick, I left your reviewed-by tags, as the code didn't changed, I just
updated the commit messages. Let me know if you have any new feedback on
this.

---
Andrey Albershteyn (3):
      xfs: allow renames of project-less inodes
      xfs: allow setting xattrs on special files
      xfs: add .fileattr_set and fileattr_get callbacks for symlinks

 fs/xfs/xfs_inode.c | 64 +++++++++++++++++++++++++++++-------------------------
 fs/xfs/xfs_ioctl.c |  6 -----
 fs/xfs/xfs_iops.c  |  2 ++
 3 files changed, 36 insertions(+), 36 deletions(-)
---
base-commit: 86aa721820952b793a12fc6e5a01734186c0c238
change-id: 20250320-xfs-xattrat-b31a9f5ed284

Best regards,
-- 
Andrey Albershteyn <aalbersh@kernel.org>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] xfs: allow renames of project-less inodes
  2025-07-29 11:00 [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Andrey Albershteyn
@ 2025-07-29 11:00 ` Andrey Albershteyn
  2025-07-29 11:00 ` [PATCH 2/3] xfs: allow setting xattrs on special files Andrey Albershteyn
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Andrey Albershteyn @ 2025-07-29 11:00 UTC (permalink / raw)
  To: cem, djwong, linux-xfs; +Cc: Andrey Albershteyn

From: Andrey Albershteyn <aalbersh@redhat.com>

Special file inodes cannot have project ID set from userspace and
are skipped during initial project setup. Those inodes are left
project-less in the project directory. New inodes created after
project initialization do have an ID. Creating hard links or
renaming those project-less inodes then fails on different ID check.

In commit e23d7e82b707 ("xfs: allow cross-linking special files
without project quota"), we relaxed the project id checks to
allow hardlinking special files with differing project ids since the
projid cannot be changed. Apply the same workaround for renaming
operations.

Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_inode.c | 64 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 9c39251961a3..0ddb9ce0f5e3 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -877,6 +877,35 @@ xfs_create_tmpfile(
 	return error;
 }
 
+static inline int
+xfs_projid_differ(
+	struct xfs_inode	*tdp,
+	struct xfs_inode	*sip)
+{
+	/*
+	 * If we are using project inheritance, we only allow hard link/renames
+	 * creation in our tree when the project IDs are the same; else
+	 * the tree quota mechanism could be circumvented.
+	 */
+	if (unlikely((tdp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
+		     tdp->i_projid != sip->i_projid)) {
+		/*
+		 * Project quota setup skips special files which can
+		 * leave inodes in a PROJINHERIT directory without a
+		 * project ID set. We need to allow links to be made
+		 * to these "project-less" inodes because userspace
+		 * expects them to succeed after project ID setup,
+		 * but everything else should be rejected.
+		 */
+		if (!special_file(VFS_I(sip)->i_mode) ||
+		    sip->i_projid != 0) {
+			return -EXDEV;
+		}
+	}
+
+	return 0;
+}
+
 int
 xfs_link(
 	struct xfs_inode	*tdp,
@@ -930,27 +959,9 @@ xfs_link(
 		goto error_return;
 	}
 
-	/*
-	 * If we are using project inheritance, we only allow hard link
-	 * creation in our tree when the project IDs are the same; else
-	 * the tree quota mechanism could be circumvented.
-	 */
-	if (unlikely((tdp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
-		     tdp->i_projid != sip->i_projid)) {
-		/*
-		 * Project quota setup skips special files which can
-		 * leave inodes in a PROJINHERIT directory without a
-		 * project ID set. We need to allow links to be made
-		 * to these "project-less" inodes because userspace
-		 * expects them to succeed after project ID setup,
-		 * but everything else should be rejected.
-		 */
-		if (!special_file(VFS_I(sip)->i_mode) ||
-		    sip->i_projid != 0) {
-			error = -EXDEV;
-			goto error_return;
-		}
-	}
+	error = xfs_projid_differ(tdp, sip);
+	if (error)
+		goto error_return;
 
 	error = xfs_dir_add_child(tp, resblks, &du);
 	if (error)
@@ -2227,16 +2238,9 @@ xfs_rename(
 	if (du_wip.ip)
 		xfs_trans_ijoin(tp, du_wip.ip, 0);
 
-	/*
-	 * If we are using project inheritance, we only allow renames
-	 * into our tree when the project IDs are the same; else the
-	 * tree quota mechanism would be circumvented.
-	 */
-	if (unlikely((target_dp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
-		     target_dp->i_projid != src_ip->i_projid)) {
-		error = -EXDEV;
+	error = xfs_projid_differ(target_dp, src_ip);
+	if (error)
 		goto out_trans_cancel;
-	}
 
 	/* RENAME_EXCHANGE is unique from here on. */
 	if (flags & RENAME_EXCHANGE) {

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] xfs: allow setting xattrs on special files
  2025-07-29 11:00 [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Andrey Albershteyn
  2025-07-29 11:00 ` [PATCH 1/3] xfs: allow renames of project-less inodes Andrey Albershteyn
@ 2025-07-29 11:00 ` Andrey Albershteyn
  2025-07-29 14:32   ` Darrick J. Wong
  2025-07-29 11:00 ` [PATCH 3/3] xfs: add .fileattr_set and fileattr_get callbacks for symlinks Andrey Albershteyn
  2025-07-29 14:34 ` [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Darrick J. Wong
  3 siblings, 1 reply; 9+ messages in thread
From: Andrey Albershteyn @ 2025-07-29 11:00 UTC (permalink / raw)
  To: cem, djwong, linux-xfs; +Cc: Andrey Albershteyn

From: Andrey Albershteyn <aalbersh@redhat.com>

XFS does't have extended attributes manipulation ioctls for special
files. Changing or reading file extended attributes is rejected for them
in xfs_fileattr_*et().

In XFS, this is necessary to work for project quota directories.
When project is set up, xfs_quota opens and calls FS_IOC_SETFSXATTR on
every inode in the directory. However, special files are skipped due to
open() returning a special inode for them. So, they don't even get to
this check.

The recently added file_getattr/file_setattr will call xfs_fileattr_*et,
on special files. This patch allows reading/changing extended file
attributes on special files.

Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_ioctl.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index fe1f74a3b6a3..f3c89172cc27 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -512,9 +512,6 @@ xfs_fileattr_get(
 {
 	struct xfs_inode	*ip = XFS_I(d_inode(dentry));
 
-	if (d_is_special(dentry))
-		return -ENOTTY;
-
 	xfs_ilock(ip, XFS_ILOCK_SHARED);
 	xfs_fill_fsxattr(ip, XFS_DATA_FORK, fa);
 	xfs_iunlock(ip, XFS_ILOCK_SHARED);
@@ -736,9 +733,6 @@ xfs_fileattr_set(
 
 	trace_xfs_ioctl_setattr(ip);
 
-	if (d_is_special(dentry))
-		return -ENOTTY;
-
 	if (!fa->fsx_valid) {
 		if (fa->flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL |
 				  FS_NOATIME_FL | FS_NODUMP_FL |

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] xfs: add .fileattr_set and fileattr_get callbacks for symlinks
  2025-07-29 11:00 [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Andrey Albershteyn
  2025-07-29 11:00 ` [PATCH 1/3] xfs: allow renames of project-less inodes Andrey Albershteyn
  2025-07-29 11:00 ` [PATCH 2/3] xfs: allow setting xattrs on special files Andrey Albershteyn
@ 2025-07-29 11:00 ` Andrey Albershteyn
  2025-07-29 14:34 ` [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Darrick J. Wong
  3 siblings, 0 replies; 9+ messages in thread
From: Andrey Albershteyn @ 2025-07-29 11:00 UTC (permalink / raw)
  To: cem, djwong, linux-xfs; +Cc: Andrey Albershteyn

From: Andrey Albershteyn <aalbersh@redhat.com>

As there are now file_getattr() and file_setattr(), xfs_quota will
call them on special files. These new syscalls call ->fileattr_get/set.

Symlink inodes don't have callbacks to set extended attributes. This
patch adds them. The attribute value combinations are checked in
fileattr_set_prepare().

Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_iops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 149b5460fbfd..c1234aad11e9 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1334,6 +1334,8 @@ static const struct inode_operations xfs_symlink_inode_operations = {
 	.setattr		= xfs_vn_setattr,
 	.listxattr		= xfs_vn_listxattr,
 	.update_time		= xfs_vn_update_time,
+	.fileattr_get		= xfs_fileattr_get,
+	.fileattr_set		= xfs_fileattr_set,
 };
 
 /* Figure out if this file actually supports DAX. */

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] xfs: allow setting xattrs on special files
  2025-07-29 11:00 ` [PATCH 2/3] xfs: allow setting xattrs on special files Andrey Albershteyn
@ 2025-07-29 14:32   ` Darrick J. Wong
  2025-07-29 14:55     ` Andrey Albershteyn
  0 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2025-07-29 14:32 UTC (permalink / raw)
  To: Andrey Albershteyn; +Cc: cem, linux-xfs

On Tue, Jul 29, 2025 at 01:00:36PM +0200, Andrey Albershteyn wrote:
> From: Andrey Albershteyn <aalbersh@redhat.com>
> 
> XFS does't have extended attributes manipulation ioctls for special
> files. Changing or reading file extended attributes is rejected for them

"extended file attributes" or "fileattrs" as Amir suggested,
but never "extended attributes" because that's a separate thing.

(no need to drop the rvb over this)

--D

> in xfs_fileattr_*et().
> 
> In XFS, this is necessary to work for project quota directories.
> When project is set up, xfs_quota opens and calls FS_IOC_SETFSXATTR on
> every inode in the directory. However, special files are skipped due to
> open() returning a special inode for them. So, they don't even get to
> this check.
> 
> The recently added file_getattr/file_setattr will call xfs_fileattr_*et,
> on special files. This patch allows reading/changing extended file
> attributes on special files.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  fs/xfs/xfs_ioctl.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index fe1f74a3b6a3..f3c89172cc27 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -512,9 +512,6 @@ xfs_fileattr_get(
>  {
>  	struct xfs_inode	*ip = XFS_I(d_inode(dentry));
>  
> -	if (d_is_special(dentry))
> -		return -ENOTTY;
> -
>  	xfs_ilock(ip, XFS_ILOCK_SHARED);
>  	xfs_fill_fsxattr(ip, XFS_DATA_FORK, fa);
>  	xfs_iunlock(ip, XFS_ILOCK_SHARED);
> @@ -736,9 +733,6 @@ xfs_fileattr_set(
>  
>  	trace_xfs_ioctl_setattr(ip);
>  
> -	if (d_is_special(dentry))
> -		return -ENOTTY;
> -
>  	if (!fa->fsx_valid) {
>  		if (fa->flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL |
>  				  FS_NOATIME_FL | FS_NODUMP_FL |
> 
> -- 
> 2.49.0
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode
  2025-07-29 11:00 [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Andrey Albershteyn
                   ` (2 preceding siblings ...)
  2025-07-29 11:00 ` [PATCH 3/3] xfs: add .fileattr_set and fileattr_get callbacks for symlinks Andrey Albershteyn
@ 2025-07-29 14:34 ` Darrick J. Wong
  2025-07-29 15:50   ` Andrey Albershteyn
  3 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2025-07-29 14:34 UTC (permalink / raw)
  To: Andrey Albershteyn; +Cc: cem, linux-xfs

On Tue, Jul 29, 2025 at 01:00:34PM +0200, Andrey Albershteyn wrote:
> With addition of new syscalls file_getattr/file_setattr allow changing
> filesystem inode attributes on special files. Fix project ID inheritance
> for special files in renames.
> 
> Cc: linux-xfs@vger.kernel.org
> 
> ---
> Darrick, I left your reviewed-by tags, as the code didn't changed, I just
> updated the commit messages. Let me know if you have any new feedback on
> this.

It all looks ok except for s/(file| )extended attribute/fileattr/

Seeing as the VFS part just went in for 6.17 this should probably get
merged soonish, right?

--D

> ---
> Andrey Albershteyn (3):
>       xfs: allow renames of project-less inodes
>       xfs: allow setting xattrs on special files
>       xfs: add .fileattr_set and fileattr_get callbacks for symlinks
> 
>  fs/xfs/xfs_inode.c | 64 +++++++++++++++++++++++++++++-------------------------
>  fs/xfs/xfs_ioctl.c |  6 -----
>  fs/xfs/xfs_iops.c  |  2 ++
>  3 files changed, 36 insertions(+), 36 deletions(-)
> ---
> base-commit: 86aa721820952b793a12fc6e5a01734186c0c238
> change-id: 20250320-xfs-xattrat-b31a9f5ed284
> 
> Best regards,
> -- 
> Andrey Albershteyn <aalbersh@kernel.org>
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] xfs: allow setting xattrs on special files
  2025-07-29 14:32   ` Darrick J. Wong
@ 2025-07-29 14:55     ` Andrey Albershteyn
  0 siblings, 0 replies; 9+ messages in thread
From: Andrey Albershteyn @ 2025-07-29 14:55 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: cem, linux-xfs

On 2025-07-29 07:32:54, Darrick J. Wong wrote:
> On Tue, Jul 29, 2025 at 01:00:36PM +0200, Andrey Albershteyn wrote:
> > From: Andrey Albershteyn <aalbersh@redhat.com>
> > 
> > XFS does't have extended attributes manipulation ioctls for special
> > files. Changing or reading file extended attributes is rejected for them
> 
> "extended file attributes" or "fileattrs" as Amir suggested,
> but never "extended attributes" because that's a separate thing.

sure

> 
> (no need to drop the rvb over this)
> 

Thanks!

-- 
- Andrey


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode
  2025-07-29 14:34 ` [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Darrick J. Wong
@ 2025-07-29 15:50   ` Andrey Albershteyn
  2025-07-29 15:52     ` Darrick J. Wong
  0 siblings, 1 reply; 9+ messages in thread
From: Andrey Albershteyn @ 2025-07-29 15:50 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: cem, linux-xfs

On 2025-07-29 07:34:11, Darrick J. Wong wrote:
> On Tue, Jul 29, 2025 at 01:00:34PM +0200, Andrey Albershteyn wrote:
> > With addition of new syscalls file_getattr/file_setattr allow changing
> > filesystem inode attributes on special files. Fix project ID inheritance
> > for special files in renames.
> > 
> > Cc: linux-xfs@vger.kernel.org
> > 
> > ---
> > Darrick, I left your reviewed-by tags, as the code didn't changed, I just
> > updated the commit messages. Let me know if you have any new feedback on
> > this.
> 
> It all looks ok except for s/(file| )extended attribute/fileattr/
> 
> Seeing as the VFS part just went in for 6.17 this should probably get
> merged soonish, right?

Without this special files won't be able to use these syscalls, but
otherwise, for regular files nothing changes. So, I think it not
necessary for this to get into this merge window.

> 
> --D
> 
> > ---
> > Andrey Albershteyn (3):
> >       xfs: allow renames of project-less inodes
> >       xfs: allow setting xattrs on special files
> >       xfs: add .fileattr_set and fileattr_get callbacks for symlinks
> > 
> >  fs/xfs/xfs_inode.c | 64 +++++++++++++++++++++++++++++-------------------------
> >  fs/xfs/xfs_ioctl.c |  6 -----
> >  fs/xfs/xfs_iops.c  |  2 ++
> >  3 files changed, 36 insertions(+), 36 deletions(-)
> > ---
> > base-commit: 86aa721820952b793a12fc6e5a01734186c0c238
> > change-id: 20250320-xfs-xattrat-b31a9f5ed284
> > 
> > Best regards,
> > -- 
> > Andrey Albershteyn <aalbersh@kernel.org>
> > 
> > 
> 

-- 
- Andrey


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode
  2025-07-29 15:50   ` Andrey Albershteyn
@ 2025-07-29 15:52     ` Darrick J. Wong
  0 siblings, 0 replies; 9+ messages in thread
From: Darrick J. Wong @ 2025-07-29 15:52 UTC (permalink / raw)
  To: Andrey Albershteyn; +Cc: cem, linux-xfs

On Tue, Jul 29, 2025 at 05:50:08PM +0200, Andrey Albershteyn wrote:
> On 2025-07-29 07:34:11, Darrick J. Wong wrote:
> > On Tue, Jul 29, 2025 at 01:00:34PM +0200, Andrey Albershteyn wrote:
> > > With addition of new syscalls file_getattr/file_setattr allow changing
> > > filesystem inode attributes on special files. Fix project ID inheritance
> > > for special files in renames.
> > > 
> > > Cc: linux-xfs@vger.kernel.org
> > > 
> > > ---
> > > Darrick, I left your reviewed-by tags, as the code didn't changed, I just
> > > updated the commit messages. Let me know if you have any new feedback on
> > > this.
> > 
> > It all looks ok except for s/(file| )extended attribute/fileattr/
> > 
> > Seeing as the VFS part just went in for 6.17 this should probably get
> > merged soonish, right?
> 
> Without this special files won't be able to use these syscalls, but
> otherwise, for regular files nothing changes. So, I think it not
> necessary for this to get into this merge window.

<nod> Ok.

--D

> > 
> > --D
> > 
> > > ---
> > > Andrey Albershteyn (3):
> > >       xfs: allow renames of project-less inodes
> > >       xfs: allow setting xattrs on special files
> > >       xfs: add .fileattr_set and fileattr_get callbacks for symlinks
> > > 
> > >  fs/xfs/xfs_inode.c | 64 +++++++++++++++++++++++++++++-------------------------
> > >  fs/xfs/xfs_ioctl.c |  6 -----
> > >  fs/xfs/xfs_iops.c  |  2 ++
> > >  3 files changed, 36 insertions(+), 36 deletions(-)
> > > ---
> > > base-commit: 86aa721820952b793a12fc6e5a01734186c0c238
> > > change-id: 20250320-xfs-xattrat-b31a9f5ed284
> > > 
> > > Best regards,
> > > -- 
> > > Andrey Albershteyn <aalbersh@kernel.org>
> > > 
> > > 
> > 
> 
> -- 
> - Andrey
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-29 15:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29 11:00 [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Andrey Albershteyn
2025-07-29 11:00 ` [PATCH 1/3] xfs: allow renames of project-less inodes Andrey Albershteyn
2025-07-29 11:00 ` [PATCH 2/3] xfs: allow setting xattrs on special files Andrey Albershteyn
2025-07-29 14:32   ` Darrick J. Wong
2025-07-29 14:55     ` Andrey Albershteyn
2025-07-29 11:00 ` [PATCH 3/3] xfs: add .fileattr_set and fileattr_get callbacks for symlinks Andrey Albershteyn
2025-07-29 14:34 ` [PATCH 0/3] Use new syscalls to set filesystem inode attributes on any inode Darrick J. Wong
2025-07-29 15:50   ` Andrey Albershteyn
2025-07-29 15:52     ` 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;
as well as URLs for NNTP newsgroup(s).