[bionic:linux][PATCH 1/2] ceph: don't check quota for snap inode

Marcelo Henrique Cerri marcelo.cerri at canonical.com
Wed May 13 16:21:48 UTC 2020


From: Yan, Zheng <zyan at redhat.com>

BugLink: https://bugs.launchpad.net/bugs/1875884

snap inode's i_snap_realm is not pointing to ceph_snap_realm.

Signed-off-by: "Yan, Zheng" <zyan at redhat.com>
Signed-off-by: Ilya Dryomov <idryomov at gmail.com>
(cherry picked from commit 2596366907f872de7be0557720bb55bccf7489d9)
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri at canonical.com>
---
 fs/ceph/dir.c   |  3 ++-
 fs/ceph/quota.c | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 04abc65e1c20..194f8ed6c276 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -932,7 +932,8 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 		goto out;
 	}
 
-	if (ceph_quota_is_max_files_exceeded(dir)) {
+	if (op == CEPH_MDS_OP_MKDIR &&
+	    ceph_quota_is_max_files_exceeded(dir)) {
 		err = -EDQUOT;
 		goto out;
 	}
diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c
index c5b1fd26daaa..e1eb95545feb 100644
--- a/fs/ceph/quota.c
+++ b/fs/ceph/quota.c
@@ -98,8 +98,15 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
 	struct inode *in;
 	bool has_quota;
 
+	if (ceph_snap(inode) != CEPH_NOSNAP)
+		return NULL;
+
 	realm = ceph_inode(inode)->i_snap_realm;
-	ceph_get_snap_realm(mdsc, realm);
+	if (realm)
+		ceph_get_snap_realm(mdsc, realm);
+	else
+		pr_err_ratelimited("get_quota_realm: ino (%llx.%llx) "
+				   "null i_snap_realm\n", ceph_vinop(inode));
 	while (realm) {
 		vino.ino = realm->ino;
 		vino.snap = CEPH_NOSNAP;
@@ -171,9 +178,16 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
 	u64 max, rvalue;
 	bool exceeded = false;
 
+	if (ceph_snap(inode) != CEPH_NOSNAP)
+		return false;
+
 	down_read(&mdsc->snap_rwsem);
 	realm = ceph_inode(inode)->i_snap_realm;
-	ceph_get_snap_realm(mdsc, realm);
+	if (realm)
+		ceph_get_snap_realm(mdsc, realm);
+	else
+		pr_err_ratelimited("check_quota_exceeded: ino (%llx.%llx) "
+				   "null i_snap_realm\n", ceph_vinop(inode));
 	while (realm) {
 		vino.ino = realm->ino;
 		vino.snap = CEPH_NOSNAP;
-- 
2.25.1




More information about the kernel-team mailing list