]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/ceph/inode.c
ceph: quota: add counter for snaprealms with quota
[mirror_ubuntu-bionic-kernel.git] / fs / ceph / inode.c
index ae6723e80c7158c79f89f8aa43de239e2f596c36..fb198365cb1a3f0d01c3911b9576d4f5ba40d1d4 100644 (file)
@@ -535,6 +535,9 @@ void ceph_destroy_inode(struct inode *inode)
 
        __ceph_remove_caps(inode);
 
+       if (__ceph_has_any_quota(ci))
+               ceph_adjust_quota_realms_count(inode, false);
+
        /*
         * we may still have a snap_realm reference if there are stray
         * caps in i_snap_caps.
@@ -790,8 +793,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
        inode->i_rdev = le32_to_cpu(info->rdev);
        inode->i_blkbits = fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1;
 
-       ci->i_max_bytes = iinfo->max_bytes;
-       ci->i_max_files = iinfo->max_files;
+       __ceph_update_quota(ci, iinfo->max_bytes, iinfo->max_files);
 
        if ((new_version || (new_issued & CEPH_CAP_AUTH_SHARED)) &&
            (issued & CEPH_CAP_AUTH_EXCL) == 0) {
@@ -2150,6 +2152,10 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
        if (err != 0)
                return err;
 
+       if ((attr->ia_valid & ATTR_SIZE) &&
+           ceph_quota_is_max_bytes_exceeded(inode, attr->ia_size))
+               return -EDQUOT;
+
        err = __ceph_setattr(inode, attr);
 
        if (err >= 0 && (attr->ia_valid & ATTR_MODE))