Skip to content

Commit e23d7e8

Browse files
alberandChandan Babu R
authored andcommitted
xfs: allow cross-linking special files without project quota
There's an issue that if special files is created before quota project is enabled, then it's not possible to link this file. This works fine for normal files. This happens because xfs_quota skips special files (no ioctls to set necessary flags). The check for having the same project ID for source and destination then fails as source file doesn't have any ID. mkfs.xfs -f /dev/sda mount -o prjquota /dev/sda /mnt/test mkdir /mnt/test/foo mkfifo /mnt/test/foo/fifo1 xfs_quota -xc "project -sp /mnt/test/foo 9" /mnt/test > Setting up project 9 (path /mnt/test/foo)... > xfs_quota: skipping special file /mnt/test/foo/fifo1 > Processed 1 (/etc/projects and cmdline) paths for project 9 with recursion depth infinite (-1). ln /mnt/test/foo/fifo1 /mnt/test/foo/fifo1_link > ln: failed to create hard link '/mnt/test/testdir/fifo1_link' => '/mnt/test/testdir/fifo1': Invalid cross-device link mkfifo /mnt/test/foo/fifo2 ln /mnt/test/foo/fifo2 /mnt/test/foo/fifo2_link Fix this by allowing linking of special files to the project quota if special files doesn't have any ID set (ID = 0). Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent 39cd87c commit e23d7e8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

fs/xfs/xfs_inode.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,8 +1301,19 @@ xfs_link(
13011301
*/
13021302
if (unlikely((tdp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
13031303
tdp->i_projid != sip->i_projid)) {
1304-
error = -EXDEV;
1305-
goto error_return;
1304+
/*
1305+
* Project quota setup skips special files which can
1306+
* leave inodes in a PROJINHERIT directory without a
1307+
* project ID set. We need to allow links to be made
1308+
* to these "project-less" inodes because userspace
1309+
* expects them to succeed after project ID setup,
1310+
* but everything else should be rejected.
1311+
*/
1312+
if (!special_file(VFS_I(sip)->i_mode) ||
1313+
sip->i_projid != 0) {
1314+
error = -EXDEV;
1315+
goto error_return;
1316+
}
13061317
}
13071318

13081319
if (!resblks) {

0 commit comments

Comments
 (0)