}
if ((mask & CEPH_SETATTR_SIZE) &&
(unsigned long)attr->st_size > in->size &&
- is_quota_bytes_exceeded(in, (unsigned long)attr->st_size - in->size)) {
+ is_quota_bytes_exceeded(in, (unsigned long)attr->st_size - in->size,
+ perms)) {
return -EDQUOT;
}
// check quota
uint64_t endoff = offset + size;
- UserPerm perms(f->actor_uid, f->actor_gid); //
- if (endoff > in->size && is_quota_bytes_exceeded(in, endoff - in->size))
+ if (endoff > in->size && is_quota_bytes_exceeded(in, endoff - in->size,
+ f->actor_perms)) {
return -EDQUOT;
+ }
// use/adjust fd pos?
if (offset < 0) {
in->size = totalwritten + offset;
mark_caps_dirty(in, CEPH_CAP_FILE_WR);
- if (is_quota_bytes_approaching(in)) {
+ if (is_quota_bytes_approaching(in, f->actor_perms)) {
check_caps(in, true);
} else {
if ((in->size << 1) >= in->max_size &&
// quota but we can see a parent of it that does have a quota, we'll
// respect that one instead.
assert(root != nullptr);
- Inode *quota_root = root->quota.is_enable() ? root : get_quota_root(root);
+ Inode *quota_root = root->quota.is_enable() ? root : get_quota_root(root, perms);
// get_quota_root should always give us something if client quotas are
// enabled
int ret;
bufferlist bl;
- UserPerm perms(fh->actor_uid, fh->actor_gid);
if (sleep && switch_interrupt_cb) {
// enable interrupt
switch_interrupt_cb(callback_handle, req->get());
- ret = make_request(req, perms, NULL, NULL, -1, &bl);
+ ret = make_request(req, fh->actor_perms, NULL, NULL, -1, &bl);
// disable interrupt
switch_interrupt_cb(callback_handle, NULL);
put_request(req);
} else {
- ret = make_request(req, perms, NULL, NULL, -1, &bl);
+ ret = make_request(req, fh->actor_perms, NULL, NULL, -1, &bl);
}
if (ret == 0) {
if (dir->snapid != CEPH_NOSNAP) {
return -EROFS;
}
- if (is_quota_files_exceeded(dir)) {
+ if (is_quota_files_exceeded(dir, perms)) {
return -EDQUOT;
}
if (dir->snapid != CEPH_NOSNAP) {
return -EROFS;
}
- if (is_quota_files_exceeded(dir)) {
+ if (is_quota_files_exceeded(dir, perms)) {
return -EDQUOT;
}
if (dir->snapid != CEPH_NOSNAP && dir->snapid != CEPH_SNAPDIR) {
return -EROFS;
}
- if (is_quota_files_exceeded(dir)) {
+ if (is_quota_files_exceeded(dir, perm)) {
return -EDQUOT;
}
MetaRequest *req = new MetaRequest(dir->snapid == CEPH_SNAPDIR ?
if (dir->snapid != CEPH_NOSNAP) {
return -EROFS;
}
- if (is_quota_files_exceeded(dir)) {
+ if (is_quota_files_exceeded(dir, perms)) {
return -EDQUOT;
}
fromdir != todir &&
(fromdir->quota.is_enable() ||
todir->quota.is_enable() ||
- get_quota_root(fromdir) != get_quota_root(todir))) {
+ get_quota_root(fromdir, perm) != get_quota_root(todir, perm))) {
return -EXDEV;
}
if (in->snapid != CEPH_NOSNAP || dir->snapid != CEPH_NOSNAP) {
return -EROFS;
}
- if (is_quota_files_exceeded(dir)) {
+ if (is_quota_files_exceeded(dir, perm)) {
return -EDQUOT;
}
uint64_t size = offset + length;
if (!(mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE)) &&
size > in->size &&
- is_quota_bytes_exceeded(in, size - in->size)) {
+ is_quota_bytes_exceeded(in, size - in->size, fh->actor_perms)) {
return -EDQUOT;
}
in->mtime = ceph_clock_now(cct);
mark_caps_dirty(in, CEPH_CAP_FILE_WR);
- if (is_quota_bytes_approaching(in)) {
+ if (is_quota_bytes_approaching(in, fh->actor_perms)) {
check_caps(in, true);
} else {
if ((in->size << 1) >= in->max_size &&
return true;
}
-Inode *Client::get_quota_root(Inode *in)
+Inode *Client::get_quota_root(Inode *in, const UserPerm& perms)
{
if (!cct->_conf->client_quota)
return NULL;
req->set_inode(cur);
InodeRef parent_ref;
- UserPerm perms(get_uid(), get_gid());
int ret = make_request(req, perms, &parent_ref);
if (ret < 0) {
ldout(cct, 1) << __func__ << " " << in->vino()
* Traverse quota ancestors of the Inode, return true
* if any of them passes the passed function
*/
-bool Client::check_quota_condition(
- Inode *in, std::function<bool (const Inode &in)> test)
+bool Client::check_quota_condition(Inode *in, const UserPerm& perms,
+ std::function<bool (const Inode &in)> test)
{
if (!cct->_conf->client_quota)
return false;
return false;
} else {
// Continue up the tree
- in = get_quota_root(in);
+ in = get_quota_root(in, perms);
}
}
return false;
}
-bool Client::is_quota_files_exceeded(Inode *in)
+bool Client::is_quota_files_exceeded(Inode *in, const UserPerm& perms)
{
- return check_quota_condition(in,
+ return check_quota_condition(in, perms,
[](const Inode &in) {
return in.quota.max_files && in.rstat.rsize() >= in.quota.max_files;
});
}
-bool Client::is_quota_bytes_exceeded(Inode *in, int64_t new_bytes)
+bool Client::is_quota_bytes_exceeded(Inode *in, int64_t new_bytes,
+ const UserPerm& perms)
{
- return check_quota_condition(in,
+ return check_quota_condition(in, perms,
[&new_bytes](const Inode &in) {
return in.quota.max_bytes && (in.rstat.rbytes + new_bytes)
> in.quota.max_bytes;
});
}
-bool Client::is_quota_bytes_approaching(Inode *in)
+bool Client::is_quota_bytes_approaching(Inode *in, const UserPerm& perms)
{
- return check_quota_condition(in,
+ return check_quota_condition(in, perms,
[](const Inode &in) {
if (in.quota.max_bytes) {
if (in.rstat.rbytes >= in.quota.max_bytes) {