Skip to contentSkip to conversation

ceph: don't check for quotas on MDS stray dirs

PATCH Superseded Jeff Layton 3 participants 3 messages Nov 9, 2021 – Nov 15, 2021 Ceph client

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: don't check for quotas on MDS stray dirs

玮文 胡 reported seeing the WARN_RATELIMITED pop when writing to an inode that had been transplanted into the stray dir. The client was trying to look up the quotarealm info from the parent and that tripped the warning.

Change the ceph_vino_is_reserved helper to not throw a warning and add a new ceph_vino_warn_reserved() helper that does. Change all of the existing callsites to call the "warn" variant, and have ceph_has_realms_with_quotas check return false when the vino is reserved.

URL: https://tracker.ceph.com/issues/53180

---
 fs/ceph/export.c |  4 ++--
 fs/ceph/inode.c  |  2 +-
 fs/ceph/quota.c  |  3 +++
 fs/ceph/super.h  | 17 ++++++++++-------
 4 files changed, 16 insertions(+), 10 deletions(-)
fs/ceph/export.c +2 -2
index e0fa66ac8b9f..a75cf07d668f 100644
@@ -130,7 +130,7 @@ static struct inode *__lookup_inode(struct super_block *sb, u64 ino)
 	vino.ino = ino;
 	vino.snap = CEPH_NOSNAP;
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
 		return ERR_PTR(-ESTALE);
 
 	inode = ceph_find_inode(sb, vino);
@@ -224,7 +224,7 @@ static struct dentry *__snapfh_to_dentry(struct super_block *sb,
 		vino.snap = sfh->snapid;
 	}
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
 		return ERR_PTR(-ESTALE);
 
 	inode = ceph_find_inode(sb, vino);
fs/ceph/inode.c +1 -1
index e8eb8612ddd6..a685fab56772 100644
@@ -56,7 +56,7 @@ struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino)
 {
 	struct inode *inode;
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
 		return ERR_PTR(-EREMOTEIO);
 
 	inode = iget5_locked(sb, (unsigned long)vino.ino, ceph_ino_compare,
fs/ceph/quota.c +3 -0
index 620c691af40e..d1158c40bb0c 100644
@@ -30,6 +30,9 @@ static inline bool ceph_has_realms_with_quotas(struct inode *inode)
 	/* if root is the real CephFS root, we don't have quota realms */
 	if (root && ceph_ino(root) == CEPH_INO_ROOT)
 		return false;
+	/* MDS stray dirs have no quota realms */
+	if (ceph_vino_is_reserved(ceph_inode(inode)->i_vino))
+		return false;
 	/* otherwise, we can't know for sure */
 	return true;
 }
fs/ceph/super.h +10 -7
index ed51e04739c4..c232ed8e8a37 100644
@@ -547,18 +547,21 @@ static inline int ceph_ino_compare(struct inode *inode, void *data)
 
 static inline bool ceph_vino_is_reserved(const struct ceph_vino vino)
 {
-	if (vino.ino < CEPH_INO_SYSTEM_BASE &&
-	    vino.ino >= CEPH_MDS_INO_MDSDIR_OFFSET) {
-		WARN_RATELIMIT(1, "Attempt to access reserved inode number 0x%llx", vino.ino);
-		return true;
-	}
-	return false;
+	return vino.ino < CEPH_INO_SYSTEM_BASE &&
+	       vino.ino >= CEPH_MDS_INO_MDSDIR_OFFSET;
+}
+
+static inline bool ceph_vino_warn_reserved(const struct ceph_vino vino)
+{
+	return WARN_RATELIMIT(ceph_vino_is_reserved(vino),
+				"Attempt to access reserved inode number 0x%llx",
+				vino.ino);
 }
 
 static inline struct inode *ceph_find_inode(struct super_block *sb,
 					    struct ceph_vino vino)
 {
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
 		return NULL;
 
 	/*
Signature · 1 line
2.33.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 105 lines · Jeff Layton

玮文 胡 reported seeing the WARN_RATELIMITED pop when writing to an inode that had been transplanted into the stray dir. The client was trying to look up the quotarealm info from the parent and that tripped the warning.

Change the ceph_vino_is_reserved helper to not throw a warning and add a new ceph_vino_warn_reserved() helper that does. Change all of the existing callsites to call the "warn" variant, and have ceph_has_realms_with_quotas check return false when the vino is reserved.

URL: https://tracker.ceph.com/issues/53180

---
 fs/ceph/export.c |  4 ++--
 fs/ceph/inode.c  |  2 +-
 fs/ceph/quota.c  |  3 +++
 fs/ceph/super.h  | 17 ++++++++++-------
 4 files changed, 16 insertions(+), 10 deletions(-)
fs/ceph/export.c +2 -2
index e0fa66ac8b9f..a75cf07d668f 100644
@@ -130,7 +130,7 @@ static struct inode *__lookup_inode(struct super_block *sb, u64 ino)
 	vino.ino = ino;
 	vino.snap = CEPH_NOSNAP;
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
 		return ERR_PTR(-ESTALE);
 
 	inode = ceph_find_inode(sb, vino);
@@ -224,7 +224,7 @@ static struct dentry *__snapfh_to_dentry(struct super_block *sb,
 		vino.snap = sfh->snapid;
 	}
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
 		return ERR_PTR(-ESTALE);
 
 	inode = ceph_find_inode(sb, vino);
fs/ceph/inode.c +1 -1
index e8eb8612ddd6..a685fab56772 100644
@@ -56,7 +56,7 @@ struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino)
 {
 	struct inode *inode;
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
 		return ERR_PTR(-EREMOTEIO);
 
 	inode = iget5_locked(sb, (unsigned long)vino.ino, ceph_ino_compare,
fs/ceph/quota.c +3 -0
index 620c691af40e..d1158c40bb0c 100644
@@ -30,6 +30,9 @@ static inline bool ceph_has_realms_with_quotas(struct inode *inode)
 	/* if root is the real CephFS root, we don't have quota realms */
 	if (root && ceph_ino(root) == CEPH_INO_ROOT)
 		return false;
+	/* MDS stray dirs have no quota realms */
+	if (ceph_vino_is_reserved(ceph_inode(inode)->i_vino))
+		return false;
 	/* otherwise, we can't know for sure */
 	return true;
 }
fs/ceph/super.h +10 -7
index ed51e04739c4..c232ed8e8a37 100644
@@ -547,18 +547,21 @@ static inline int ceph_ino_compare(struct inode *inode, void *data)
 
 static inline bool ceph_vino_is_reserved(const struct ceph_vino vino)
 {
-	if (vino.ino < CEPH_INO_SYSTEM_BASE &&
-	    vino.ino >= CEPH_MDS_INO_MDSDIR_OFFSET) {
-		WARN_RATELIMIT(1, "Attempt to access reserved inode number 0x%llx", vino.ino);
-		return true;
-	}
-	return false;
+	return vino.ino < CEPH_INO_SYSTEM_BASE &&
+	       vino.ino >= CEPH_MDS_INO_MDSDIR_OFFSET;
+}
+
+static inline bool ceph_vino_warn_reserved(const struct ceph_vino vino)
+{
+	return WARN_RATELIMIT(ceph_vino_is_reserved(vino),
+				"Attempt to access reserved inode number 0x%llx",
+				vino.ino);
 }
 
 static inline struct inode *ceph_find_inode(struct super_block *sb,
 					    struct ceph_vino vino)
 {
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
 		return NULL;
 
 	/*
Signature · 1 line
2.33.1

This looks reasonable. I would probably keep the old function name and simply name the new one ceph_vino_is_reserved_no_warn(). But that's just because I'm lazy :-)

Cheers,
--
Luís

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jeff Layton
Quoted 92 lines · Jeff Layton

玮文 胡 reported seeing the WARN_RATELIMITED pop when writing to an inode that had been transplanted into the stray dir. The client was trying to look up the quotarealm info from the parent and that tripped the warning.

Change the ceph_vino_is_reserved helper to not throw a warning and add a new ceph_vino_warn_reserved() helper that does. Change all of the existing callsites to call the "warn" variant, and have ceph_has_realms_with_quotas check return false when the vino is reserved.

URL: https://tracker.ceph.com/issues/53180

---
  fs/ceph/export.c |  4 ++--
  fs/ceph/inode.c  |  2 +-
  fs/ceph/quota.c  |  3 +++
  fs/ceph/super.h  | 17 ++++++++++-------
  4 files changed, 16 insertions(+), 10 deletions(-)
fs/ceph/export.c +2 -2
index e0fa66ac8b9f..a75cf07d668f 100644
@@ -130,7 +130,7 @@ static struct inode *__lookup_inode(struct super_block *sb, u64 ino)
  	vino.ino = ino;
  	vino.snap = CEPH_NOSNAP;
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
  		return ERR_PTR(-ESTALE);
 
  	inode = ceph_find_inode(sb, vino);
@@ -224,7 +224,7 @@ static struct dentry *__snapfh_to_dentry(struct super_block *sb,
  		vino.snap = sfh->snapid;
  	}
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
  		return ERR_PTR(-ESTALE);
 
  	inode = ceph_find_inode(sb, vino);
fs/ceph/inode.c +1 -1
index e8eb8612ddd6..a685fab56772 100644
@@ -56,7 +56,7 @@ struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino)
  {
  	struct inode *inode;
 
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
  		return ERR_PTR(-EREMOTEIO);
 
  	inode = iget5_locked(sb, (unsigned long)vino.ino, ceph_ino_compare,
fs/ceph/quota.c +3 -0
index 620c691af40e..d1158c40bb0c 100644
@@ -30,6 +30,9 @@ static inline bool ceph_has_realms_with_quotas(struct inode *inode)
  	/* if root is the real CephFS root, we don't have quota realms */
  	if (root && ceph_ino(root) == CEPH_INO_ROOT)
  		return false;
+	/* MDS stray dirs have no quota realms */
+	if (ceph_vino_is_reserved(ceph_inode(inode)->i_vino))
+		return false;
  	/* otherwise, we can't know for sure */
  	return true;
  }
fs/ceph/super.h +9 -6
index ed51e04739c4..c232ed8e8a37 100644
@@ -547,18 +547,21 @@ static inline int ceph_ino_compare(struct inode *inode, void *data)
 
  static inline bool ceph_vino_is_reserved(const struct ceph_vino vino)
  {
-	if (vino.ino < CEPH_INO_SYSTEM_BASE &&
-	    vino.ino >= CEPH_MDS_INO_MDSDIR_OFFSET) {
-		WARN_RATELIMIT(1, "Attempt to access reserved inode number 0x%llx", vino.ino);
-		return true;
-	}
-	return false;
+	return vino.ino < CEPH_INO_SYSTEM_BASE &&
+	       vino.ino >= CEPH_MDS_INO_MDSDIR_OFFSET;
+}
+
+static inline bool ceph_vino_warn_reserved(const struct ceph_vino vino)
+{
+	return WARN_RATELIMIT(ceph_vino_is_reserved(vino),
+				"Attempt to access reserved inode number 0x%llx",
+				vino.ino);

fs/ceph/super.h static inline int ceph_ino_compare(struct inode *inode, void *data) · line 567

Quoted 10 lines
fs/ceph/super.h +1 -1
  }
 
  static inline struct inode *ceph_find_inode(struct super_block *sb,
  					    struct ceph_vino vino)
  {
-	if (ceph_vino_is_reserved(vino))
+	if (ceph_vino_warn_reserved(vino))
  		return NULL;
 
  	/*

LGTM.