mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-07 07:05:20 +00:00
ceph: check if mds create snaprealm when setting quota
If mds does not, return -EOPNOTSUPP. Link: http://tracker.ceph.com/issues/23491 Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
6d08b06e67
commit
f191982689
1 changed files with 25 additions and 3 deletions
|
@ -228,7 +228,15 @@ static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val,
|
||||||
|
|
||||||
static bool ceph_vxattrcb_quota_exists(struct ceph_inode_info *ci)
|
static bool ceph_vxattrcb_quota_exists(struct ceph_inode_info *ci)
|
||||||
{
|
{
|
||||||
return (ci->i_max_files || ci->i_max_bytes);
|
bool ret = false;
|
||||||
|
spin_lock(&ci->i_ceph_lock);
|
||||||
|
if ((ci->i_max_files || ci->i_max_bytes) &&
|
||||||
|
ci->i_vino.snap == CEPH_NOSNAP &&
|
||||||
|
ci->i_snap_realm &&
|
||||||
|
ci->i_snap_realm->ino == ci->i_vino.ino)
|
||||||
|
ret = true;
|
||||||
|
spin_unlock(&ci->i_ceph_lock);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t ceph_vxattrcb_quota(struct ceph_inode_info *ci, char *val,
|
static size_t ceph_vxattrcb_quota(struct ceph_inode_info *ci, char *val,
|
||||||
|
@ -1008,14 +1016,19 @@ int __ceph_setxattr(struct inode *inode, const char *name,
|
||||||
char *newval = NULL;
|
char *newval = NULL;
|
||||||
struct ceph_inode_xattr *xattr = NULL;
|
struct ceph_inode_xattr *xattr = NULL;
|
||||||
int required_blob_size;
|
int required_blob_size;
|
||||||
|
bool check_realm = false;
|
||||||
bool lock_snap_rwsem = false;
|
bool lock_snap_rwsem = false;
|
||||||
|
|
||||||
if (ceph_snap(inode) != CEPH_NOSNAP)
|
if (ceph_snap(inode) != CEPH_NOSNAP)
|
||||||
return -EROFS;
|
return -EROFS;
|
||||||
|
|
||||||
vxattr = ceph_match_vxattr(inode, name);
|
vxattr = ceph_match_vxattr(inode, name);
|
||||||
if (vxattr && vxattr->readonly)
|
if (vxattr) {
|
||||||
return -EOPNOTSUPP;
|
if (vxattr->readonly)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
if (value && !strncmp(vxattr->name, "ceph.quota", 10))
|
||||||
|
check_realm = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* pass any unhandled ceph.* xattrs through to the MDS */
|
/* pass any unhandled ceph.* xattrs through to the MDS */
|
||||||
if (!strncmp(name, XATTR_CEPH_PREFIX, XATTR_CEPH_PREFIX_LEN))
|
if (!strncmp(name, XATTR_CEPH_PREFIX, XATTR_CEPH_PREFIX_LEN))
|
||||||
|
@ -1109,6 +1122,15 @@ do_sync_unlocked:
|
||||||
err = -EBUSY;
|
err = -EBUSY;
|
||||||
} else {
|
} else {
|
||||||
err = ceph_sync_setxattr(inode, name, value, size, flags);
|
err = ceph_sync_setxattr(inode, name, value, size, flags);
|
||||||
|
if (err >= 0 && check_realm) {
|
||||||
|
/* check if snaprealm was created for quota inode */
|
||||||
|
spin_lock(&ci->i_ceph_lock);
|
||||||
|
if ((ci->i_max_files || ci->i_max_bytes) &&
|
||||||
|
!(ci->i_snap_realm &&
|
||||||
|
ci->i_snap_realm->ino == ci->i_vino.ino))
|
||||||
|
err = -EOPNOTSUPP;
|
||||||
|
spin_unlock(&ci->i_ceph_lock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
ceph_free_cap_flush(prealloc_cf);
|
ceph_free_cap_flush(prealloc_cf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue