]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ceph: fix root quota realm check
authorYan, Zheng <zyan@redhat.com>
Fri, 12 Jan 2018 08:55:31 +0000 (16:55 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 2 Jul 2019 16:30:46 +0000 (18:30 +0200)
BugLink: https://bugs.launchpad.net/bugs/1834235
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 0eb6bbe4d9cf02f639d661edf7c02defc3453a69)
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
fs/ceph/quota.c

index 5d7dada91a572cc7aab8f24e62a3a7d63b2562e8..fd27e7113731c81f39bcab956e5b5001802386a0 100644 (file)
@@ -85,6 +85,7 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
        struct ceph_snap_realm *realm, *next;
        struct ceph_vino vino;
        struct inode *in;
+       bool has_quota;
 
        realm = ceph_inode(inode)->i_snap_realm;
        ceph_get_snap_realm(mdsc, realm);
@@ -97,12 +98,13 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
                        break;
                }
                ci = ceph_inode(in);
-               if (ceph_has_quota(ci) || (ci->i_vino.ino == CEPH_INO_ROOT)) {
-                       iput(in);
-                       return realm;
-               }
+               has_quota = ceph_has_quota(ci);
                iput(in);
+
                next = realm->parent;
+               if (has_quota || !next)
+                      return realm;
+
                ceph_get_snap_realm(mdsc, next);
                ceph_put_snap_realm(mdsc, realm);
                realm = next;
@@ -152,7 +154,6 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
        struct ceph_vino vino;
        struct inode *in;
        u64 max, rvalue;
-       bool is_root;
        bool exceeded = false;
 
        down_read(&mdsc->snap_rwsem);
@@ -172,7 +173,6 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
                        max = ci->i_max_files;
                        rvalue = ci->i_rfiles + ci->i_rsubdirs;
                }
-               is_root = (ci->i_vino.ino == CEPH_INO_ROOT);
                spin_unlock(&ci->i_ceph_lock);
                switch (op) {
                case QUOTA_CHECK_MAX_FILES_OP:
@@ -185,9 +185,9 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
                }
                iput(in);
 
-               if (is_root || exceeded)
-                       break;
                next = realm->parent;
+               if (exceeded || !next)
+                       break;
                ceph_get_snap_realm(mdsc, next);
                ceph_put_snap_realm(mdsc, realm);
                realm = next;