// quota but we can see a parent of it that does have a quota, we'll
// respect that one instead.
ceph_assert(root != nullptr);
- InodeRef quota_root = root->quota.is_enable() ? root : get_quota_root(root.get(), perms);
+ InodeRef quota_root = root->quota.is_enable(QUOTA_MAX_BYTES) ? root : get_quota_root(root.get(), perms, QUOTA_MAX_BYTES);
// get_quota_root should always give us something if client quotas are
// enabled
}
if (cct->_conf.get_val<bool>("client_quota") && fromdir != todir) {
Inode *fromdir_root =
- fromdir->quota.is_enable() ? fromdir : get_quota_root(fromdir, perm);
+ fromdir->quota.is_enable(QUOTA_MAX_FILES) ? fromdir : get_quota_root(fromdir, perm, QUOTA_MAX_FILES);
Inode *todir_root =
- todir->quota.is_enable() ? todir : get_quota_root(todir, perm);
+ todir->quota.is_enable(QUOTA_MAX_FILES) ? todir : get_quota_root(todir, perm, QUOTA_MAX_FILES);
if (fromdir_root != todir_root) {
return -CEPHFS_EXDEV;
}
return false;
}
-Inode *Client::get_quota_root(Inode *in, const UserPerm& perms)
+Inode *Client::get_quota_root(Inode *in, const UserPerm& perms, quota_max_t type)
{
Inode *quota_in = root_ancestor;
SnapRealm *realm = in->snaprealm;
if (p == inode_map.end())
break;
- if (p->second->quota.is_enable()) {
+ if (p->second->quota.is_enable(type)) {
quota_in = p->second;
break;
}
int authenticate();
- Inode* get_quota_root(Inode *in, const UserPerm& perms);
+ Inode* get_quota_root(Inode *in, const UserPerm& perms, quota_max_t type=QUOTA_ANY);
bool check_quota_condition(Inode *in, const UserPerm& perms,
std::function<bool (const Inode &)> test);
bool is_quota_files_exceeded(Inode *in, const UserPerm& perms);
(l.ino == r.ino && l.snapid < r.snapid);
}
+typedef enum {
+ QUOTA_MAX_FILES,
+ QUOTA_MAX_BYTES,
+ QUOTA_ANY
+} quota_max_t;
+
struct quota_info_t
{
void encode(ceph::buffer::list& bl) const {
bool is_valid() const {
return max_bytes >=0 && max_files >=0;
}
- bool is_enable() const {
- return max_bytes || max_files;
+ bool is_enable(quota_max_t type=QUOTA_ANY) const {
+ switch (type) {
+ case QUOTA_MAX_FILES:
+ return !!max_files;
+ case QUOTA_MAX_BYTES:
+ return !!max_bytes;
+ case QUOTA_ANY:
+ default:
+ return !!max_bytes || !!max_files;
+ }
}
void decode_json(JSONObj *obj);