Currently, we allow making hard link bewteen different quota realms and it may cause inaccurate quota accouting. This patch adds quota realm check when doing hard link. Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx> --- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 82928cea0209..87fa996dbad4 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -993,6 +993,10 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir, if (ceph_snap(dir) != CEPH_NOSNAP) return -EROFS; + /* don't allow cross-quota link */ + if (!ceph_quota_is_same_realm(d_inode(old_dentry), dir)) + return -EXDEV; + dout("link in dir %p old_dentry %p dentry %p\n", dir, old_dentry, dentry); req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LINK, USE_AUTH_MDS); -- 2.17.1