Skip to content

Commit 0eb6bbe

Browse files
ukernelidryomov
authored andcommitted
ceph: fix root quota realm check
Signed-off-by: "Yan, Zheng" <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 2596366 commit 0eb6bbe

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/ceph/quota.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
8585
struct ceph_snap_realm *realm, *next;
8686
struct ceph_vino vino;
8787
struct inode *in;
88+
bool has_quota;
8889

8990
if (ceph_snap(inode) != CEPH_NOSNAP)
9091
return NULL;
@@ -104,12 +105,13 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
104105
break;
105106
}
106107
ci = ceph_inode(in);
107-
if (ceph_has_quota(ci) || (ci->i_vino.ino == CEPH_INO_ROOT)) {
108-
iput(in);
109-
return realm;
110-
}
108+
has_quota = ceph_has_quota(ci);
111109
iput(in);
110+
112111
next = realm->parent;
112+
if (has_quota || !next)
113+
return realm;
114+
113115
ceph_get_snap_realm(mdsc, next);
114116
ceph_put_snap_realm(mdsc, realm);
115117
realm = next;
@@ -162,7 +164,6 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
162164
struct ceph_vino vino;
163165
struct inode *in;
164166
u64 max, rvalue;
165-
bool is_root;
166167
bool exceeded = false;
167168

168169
if (ceph_snap(inode) != CEPH_NOSNAP)
@@ -192,7 +193,6 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
192193
max = ci->i_max_bytes;
193194
rvalue = ci->i_rbytes;
194195
}
195-
is_root = (ci->i_vino.ino == CEPH_INO_ROOT);
196196
spin_unlock(&ci->i_ceph_lock);
197197
switch (op) {
198198
case QUOTA_CHECK_MAX_FILES_OP:
@@ -222,9 +222,9 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
222222
}
223223
iput(in);
224224

225-
if (is_root || exceeded)
226-
break;
227225
next = realm->parent;
226+
if (exceeded || !next)
227+
break;
228228
ceph_get_snap_realm(mdsc, next);
229229
ceph_put_snap_realm(mdsc, realm);
230230
realm = next;

0 commit comments

Comments
 (0)