* [PATCH v2 1/3] xfs: allow renames of project-less inodes
2025-08-04 12:08 [PATCH v2 0/3] Use new syscalls to set filesystem file attributes on any inode Andrey Albershteyn
@ 2025-08-04 12:08 ` Andrey Albershteyn
2025-08-04 12:08 ` [PATCH v2 2/3] xfs: add .fileattr_set and fileattr_get callbacks for symlinks Andrey Albershteyn
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Albershteyn @ 2025-08-04 12:08 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.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] xfs: add .fileattr_set and fileattr_get callbacks for symlinks
2025-08-04 12:08 [PATCH v2 0/3] Use new syscalls to set filesystem file attributes on any inode Andrey Albershteyn
2025-08-04 12:08 ` [PATCH v2 1/3] xfs: allow renames of project-less inodes Andrey Albershteyn
@ 2025-08-04 12:08 ` Andrey Albershteyn
2025-08-04 12:08 ` [PATCH v2 3/3] xfs: allow setting file attributes on special files Andrey Albershteyn
2025-08-28 13:18 ` [PATCH v2 0/3] Use new syscalls to set filesystem file attributes on any inode Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Albershteyn @ 2025-08-04 12:08 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 file attributes. This
patch adds them. The attribute values 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.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] xfs: allow setting file attributes on special files
2025-08-04 12:08 [PATCH v2 0/3] Use new syscalls to set filesystem file attributes on any inode Andrey Albershteyn
2025-08-04 12:08 ` [PATCH v2 1/3] xfs: allow renames of project-less inodes Andrey Albershteyn
2025-08-04 12:08 ` [PATCH v2 2/3] xfs: add .fileattr_set and fileattr_get callbacks for symlinks Andrey Albershteyn
@ 2025-08-04 12:08 ` Andrey Albershteyn
2025-08-28 13:18 ` [PATCH v2 0/3] Use new syscalls to set filesystem file attributes on any inode Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Andrey Albershteyn @ 2025-08-04 12:08 UTC (permalink / raw)
To: cem, djwong, linux-xfs; +Cc: Andrey Albershteyn
From: Andrey Albershteyn <aalbersh@redhat.com>
XFS does't have file attributes manipulation ioctls for special
files. Changing or reading file 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 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.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/3] Use new syscalls to set filesystem file attributes on any inode
2025-08-04 12:08 [PATCH v2 0/3] Use new syscalls to set filesystem file attributes on any inode Andrey Albershteyn
` (2 preceding siblings ...)
2025-08-04 12:08 ` [PATCH v2 3/3] xfs: allow setting file attributes on special files Andrey Albershteyn
@ 2025-08-28 13:18 ` Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Carlos Maiolino @ 2025-08-28 13:18 UTC (permalink / raw)
To: djwong, linux-xfs, Andrey Albershteyn
On Mon, 04 Aug 2025 14:08:13 +0200, Andrey Albershteyn wrote:
> With addition of new syscalls file_getattr/file_setattr allow changing
> filesystem file attributes on special files. Fix project ID inheritance
> for special files in renames.
>
>
Applied to for-next, thanks!
[1/3] xfs: allow renames of project-less inodes
commit: 8d2f9f5c64f16e0717854fb66d795ebe8c30103b
[2/3] xfs: add .fileattr_set and fileattr_get callbacks for symlinks
commit: 8a221004fe5288b66503699a329a6b623be13f91
[3/3] xfs: allow setting file attributes on special files
commit: 0239bd9fa445a21def88f7e76fe6e0414b2a4da0
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread