From: Yan, Zheng Date: Fri, 12 Jan 2018 08:55:31 +0000 (+0800) Subject: ceph: fix root quota realm check X-Git-Tag: Ubuntu-4.15.0-55.60~7 X-Git-Url: https://git.proxmox.com/?p=mirror_ubuntu-bionic-kernel.git;a=commitdiff_plain;h=780ac19f406d8706540f43f44240f7e28be1484a ceph: fix root quota realm check BugLink: https://bugs.launchpad.net/bugs/1834235 Signed-off-by: "Yan, Zheng" Signed-off-by: Ilya Dryomov (cherry picked from commit 0eb6bbe4d9cf02f639d661edf7c02defc3453a69) Signed-off-by: Connor Kuehl Acked-by: Kleber Sacilotto de Souza Acked-by: Stefan Bader Signed-off-by: Kleber Sacilotto de Souza --- diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c index 5d7dada91a57..fd27e7113731 100644 --- a/fs/ceph/quota.c +++ b/fs/ceph/quota.c @@ -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;