Hi all, A few weeks ago, Filipe Manana reported[1] that the new generic/673 test fails on btrfs because btrfs is more aggressive about dropping the setgid bit when reflinking into a file. After some more digging, we discovered that btrfs calls the VFS helpers to handle updating VFS inode attributes, whereas XFS has open-coded logic dating from ~1997 that have not been kept up to date. A few days later, Andrey Zhadchenko reported[2] that XFS can mistakenly clear S_ISUID and S_ISGID on idmapped mounts. After further discussion, it was pointed out that the VFS already handles all these fiddly file mode changes, and that it was the XFS implementation that is out of date. Both of these reports resolve to the same cause, which is that XFS needs to call setattr_copy to update i_mode instead of doing it directly. This series replaces all of our bespoke code with VFS calls to fix the problem and reduce the size of the codebase by ~70 lines. [1] https://lore.kernel.org/linux-xfs/CAL3q7H47iNQ=Wmk83WcGB-KBJVOEtR9+qGczzCeXJ9Y2KCV25Q@xxxxxxxxxxxxxx/ [2] https://lore.kernel.org/linux-xfs/20220221182218.748084-1-andrey.zhadchenko@xxxxxxxxxxxxx/ If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below. This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome. --D kernel git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=setattr-copy-5.18 --- fs/xfs/xfs_iops.c | 116 +++++++++++------------------------------------------ fs/xfs/xfs_pnfs.c | 3 + 2 files changed, 25 insertions(+), 94 deletions(-)