lkml.org 
[lkml]   [2021]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] xfs: not allow rename if src is quota enabled and project IDs are different
Date
From: Ren Lei <renlei1@chinatelecom.cn>

xfs not allow rename if target is using project inheritance and
project IDs are different to avoid tree quota mechanism not work.

But if only src with directory quota enabled, rename to other directory
without quota enabled can succeed and skip quota mechanism. which might
result to unexpected quota behavior.

This patch fix this by disable rename if src is using project inheritance
and the project IDs are not the same.

following steps can easy reproduce this issue:
1. first init a directory quota /mnt/test
mount -o prjquota /dev/sdb /mnt
mkdir /mnt/test
echo 1:/mnt/test >> /etc/projects
echo test:1 >> /etc/projid
xfs_quota -x -c 'project -s test' /mnt
xfs_quota -x -c 'limit -p bhard=10m test' /mnt

2. fill /mnt/test with tesfile util directory full:
[root@rhost1 test]# dd if=/dev/zero of=/mnt/test/testfile
dd: writing to '/mnt/test/testfile': No space left on device

3. mv testfile out to /mnt, test is empty but cannot create files:
[root@rhost1 test]# mv testfile ../
[root@rhost1 test]# ls -a
. ..
[root@rhost1 test]# touch aaa
touch: cannot touch 'aaa': Disk quota exceeded

Signed-off-by: Ren Lei <renlei1@chinatelecom.cn>
---
fs/xfs/xfs_inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 6771f357ad2c..f8c115b014f9 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3177,7 +3177,8 @@ xfs_rename(
* 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) &&
+ if (unlikely((target_dp->i_diflags & XFS_DIFLAG_PROJINHERIT ||
+ src_dp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
target_dp->i_projid != src_ip->i_projid)) {
error = -EXDEV;
goto out_trans_cancel;
--
2.27.0
\
 
 \ /
  Last update: 2021-12-14 04:24    [W:0.054 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site