Skip to contentSkip to conversation

ceph: add a new vxattr to return auth mds for an inode

PATCH Superseded Jeff Layton 2 participants 7 messages Jul 27, 2021 – Jul 28, 2021 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: add a new vxattr to return auth mds for an inode

Add a new vxattr that shows what MDS is authoritative for an inode (if we happen to have auth caps). If we don't have an auth cap for the inode then just return -1.

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

---
 fs/ceph/xattr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
fs/ceph/xattr.c +16 -0
index 1242db8d3444..70664a19b8dc 100644
@@ -340,6 +340,15 @@ static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val,
 			      ceph_cap_string(issued), issued);
 }
 
+static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci,
+				       char *val, size_t size)
+{
+	/* return -1 if we don't have auth caps (and thus can't tell) */
+	if (!ci->i_auth_cap)
+		return ceph_fmt_xattr(val, size, "-1");
+	return ceph_fmt_xattr(val, size, "%d", ci->i_auth_cap->session->s_mds);
+}
+
 #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
 	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -473,6 +482,13 @@ static struct ceph_vxattr ceph_common_vxattrs[] = {
 		.exists_cb = NULL,
 		.flags = VXATTR_FLAG_READONLY,
 	},
+	{
+		.name = "ceph.auth_mds",
+		.name_size = sizeof("ceph.auth_mds"),
+		.getxattr_cb = ceph_vxattrcb_auth_mds,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
 	{ .name = NULL, 0 }	/* Required table terminator */
 };
 
Signature · 1 line
2.31.1
#1 lore raw
Quoted 15 lines · Jeff Layton

Add a new vxattr that shows what MDS is authoritative for an inode (if we happen to have auth caps). If we don't have an auth cap for the inode then just return -1.

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

---
 fs/ceph/xattr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
fs/ceph/xattr.c +0 -0
index 1242db8d3444..70664a19b8dc 100644

fs/ceph/xattr.c static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val, · line 348

Quoted 9 lines
fs/ceph/xattr.c +6 -0
@@ -340,6 +340,15 @@ static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val,
 			      ceph_cap_string(issued), issued);
 }
 
+static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci,
+				       char *val, size_t size)
+{
+	/* return -1 if we don't have auth caps (and thus can't tell) */
+	if (!ci->i_auth_cap)
+		return ceph_fmt_xattr(val, size, "-1");

I don't really have an opinion on this as I don't have a usecase for this xattr (other than debug, of course). But I just checked a similar function ceph_vxattrcb_layout_pool_namespace() and, if there's no value for ns for an inode, it just returns 0.

Anyway, just my 5c, as I'm OK with returning a '-1' string too.

Cheers,
--
Luís

Quoted 23 lines
fs/ceph/xattr.c +10 -0
+	return ceph_fmt_xattr(val, size, "%d", ci->i_auth_cap->session->s_mds);
+}
+
 #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
 	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -473,6 +482,13 @@ static struct ceph_vxattr ceph_common_vxattrs[] = {
 		.exists_cb = NULL,
 		.flags = VXATTR_FLAG_READONLY,
 	},
+	{
+		.name = "ceph.auth_mds",
+		.name_size = sizeof("ceph.auth_mds"),
+		.getxattr_cb = ceph_vxattrcb_auth_mds,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
 	{ .name = NULL, 0 }	/* Required table terminator */
 };
 
Signature · 1 line
2.31.1
#2 lore raw
Quoted 31 lines · Luis Henriques
Quoted 15 lines · Jeff Layton

Add a new vxattr that shows what MDS is authoritative for an inode (if we happen to have auth caps). If we don't have an auth cap for the inode then just return -1.

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

---
 fs/ceph/xattr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
fs/ceph/xattr.c +0 -0
index 1242db8d3444..70664a19b8dc 100644

fs/ceph/xattr.c static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val, · line 348

Quoted 9 lines
fs/ceph/xattr.c +6 -0
@@ -340,6 +340,15 @@ static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val,
 			      ceph_cap_string(issued), issued);
 }
 
+static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci,
+				       char *val, size_t size)
+{
+	/* return -1 if we don't have auth caps (and thus can't tell) */
+	if (!ci->i_auth_cap)
+		return ceph_fmt_xattr(val, size, "-1");

I don't really have an opinion on this as I don't have a usecase for this xattr (other than debug, of course). But I just checked a similar function ceph_vxattrcb_layout_pool_namespace() and, if there's no value for ns for an inode, it just returns 0.

Quoted 2 lines

Anyway, just my 5c, as I'm OK with returning a '-1' string too.

TBH, I don't have much of a use-case for this either, but it was requested by Sage long ago. That said, I figure it might be useful in some cases, particularly when troubleshooting pinning issues.

Pool numbering is a bit different, as I think pool 0 is not valid, whereas we index mds's starting with 0. I'm fine with a different convention here, but I considered it as a safe way to say "I don't know" in this situation.

Quoted 23 lines
Quoted 23 lines
fs/ceph/xattr.c +10 -0
+	return ceph_fmt_xattr(val, size, "%d", ci->i_auth_cap->session->s_mds);
+}
+
 #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
 	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -473,6 +482,13 @@ static struct ceph_vxattr ceph_common_vxattrs[] = {
 		.exists_cb = NULL,
 		.flags = VXATTR_FLAG_READONLY,
 	},
+	{
+		.name = "ceph.auth_mds",
+		.name_size = sizeof("ceph.auth_mds"),
+		.getxattr_cb = ceph_vxattrcb_auth_mds,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
 	{ .name = NULL, 0 }	/* Required table terminator */
 };
 
Signature · 1 line
2.31.1
Signature · 1 line
Jeff Layton <[email protected]>
#3 lore raw
Quoted 36 lines · Jeff Layton
Quoted 31 lines · Luis Henriques
Quoted 15 lines · Jeff Layton

Add a new vxattr that shows what MDS is authoritative for an inode (if we happen to have auth caps). If we don't have an auth cap for the inode then just return -1.

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

---
 fs/ceph/xattr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
fs/ceph/xattr.c +0 -0
index 1242db8d3444..70664a19b8dc 100644

fs/ceph/xattr.c static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val, · line 348

Quoted 9 lines
fs/ceph/xattr.c +6 -0
@@ -340,6 +340,15 @@ static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val,
 			      ceph_cap_string(issued), issued);
 }
 
+static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci,
+				       char *val, size_t size)
+{
+	/* return -1 if we don't have auth caps (and thus can't tell) */
+	if (!ci->i_auth_cap)
+		return ceph_fmt_xattr(val, size, "-1");

I don't really have an opinion on this as I don't have a usecase for this xattr (other than debug, of course). But I just checked a similar function ceph_vxattrcb_layout_pool_namespace() and, if there's no value for ns for an inode, it just returns 0.

Quoted 2 lines

Anyway, just my 5c, as I'm OK with returning a '-1' string too.

Quoted 8 lines

TBH, I don't have much of a use-case for this either, but it was requested by Sage long ago. That said, I figure it might be useful in some cases, particularly when troubleshooting pinning issues.

Pool numbering is a bit different, as I think pool 0 is not valid, whereas we index mds's starting with 0. I'm fine with a different convention here, but I considered it as a safe way to say "I don't know" in this situation.

Right, but what I meant by returning 0 was to really do:

	if (!ci->i_auth_cap)
		return 0;

and not to return the string "0". Anyway, as I said, I don't have an opinion on this and returning the "-1" string for the MDS index sounds good too.

Cheers,
--
Luís

Quoted 27 lines
Quoted 23 lines
Quoted 23 lines
fs/ceph/xattr.c +10 -0
+	return ceph_fmt_xattr(val, size, "%d", ci->i_auth_cap->session->s_mds);
+}
+
 #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
 	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -473,6 +482,13 @@ static struct ceph_vxattr ceph_common_vxattrs[] = {
 		.exists_cb = NULL,
 		.flags = VXATTR_FLAG_READONLY,
 	},
+	{
+		.name = "ceph.auth_mds",
+		.name_size = sizeof("ceph.auth_mds"),
+		.getxattr_cb = ceph_vxattrcb_auth_mds,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
 	{ .name = NULL, 0 }	/* Required table terminator */
 };
 
Signature · 1 line
2.31.1
Signature · 1 line
Jeff Layton <[email protected]>
#4 lore raw
Quoted 51 lines · Luis Henriques
Quoted 36 lines · Jeff Layton
Quoted 31 lines · Luis Henriques
Quoted 15 lines · Jeff Layton

Add a new vxattr that shows what MDS is authoritative for an inode (if we happen to have auth caps). If we don't have an auth cap for the inode then just return -1.

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

---
 fs/ceph/xattr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
fs/ceph/xattr.c +0 -0
index 1242db8d3444..70664a19b8dc 100644

fs/ceph/xattr.c static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val, · line 348

Quoted 9 lines
fs/ceph/xattr.c +6 -0
@@ -340,6 +340,15 @@ static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val,
 			      ceph_cap_string(issued), issued);
 }
 
+static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci,
+				       char *val, size_t size)
+{
+	/* return -1 if we don't have auth caps (and thus can't tell) */
+	if (!ci->i_auth_cap)
+		return ceph_fmt_xattr(val, size, "-1");

I don't really have an opinion on this as I don't have a usecase for this xattr (other than debug, of course). But I just checked a similar function ceph_vxattrcb_layout_pool_namespace() and, if there's no value for ns for an inode, it just returns 0.

Quoted 2 lines

Anyway, just my 5c, as I'm OK with returning a '-1' string too.

Quoted 8 lines

TBH, I don't have much of a use-case for this either, but it was requested by Sage long ago. That said, I figure it might be useful in some cases, particularly when troubleshooting pinning issues.

Pool numbering is a bit different, as I think pool 0 is not valid, whereas we index mds's starting with 0. I'm fine with a different convention here, but I considered it as a safe way to say "I don't know" in this situation.

Right, but what I meant by returning 0 was to really do:

	if (!ci->i_auth_cap)
		return 0;
Quoted 8 lines

and not to return the string "0". Anyway, as I said, I don't have an opinion on this and returning the "-1" string for the MDS index sounds good too.

Cheers,
--
Luís

Oh yeah, ok. We could do that I guess. I don't care much either way, but that might be cleaner. Let me think on it a bit.

I also think we'll need to hold the ci->i_ceph_lock around the i_auth_cap access. I'll need to send a v2 patch for that anyway.

Quoted 27 lines
Quoted 27 lines
Quoted 23 lines
Quoted 23 lines
fs/ceph/xattr.c +10 -0
+	return ceph_fmt_xattr(val, size, "%d", ci->i_auth_cap->session->s_mds);
+}
+
 #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
 	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -473,6 +482,13 @@ static struct ceph_vxattr ceph_common_vxattrs[] = {
 		.exists_cb = NULL,
 		.flags = VXATTR_FLAG_READONLY,
 	},
+	{
+		.name = "ceph.auth_mds",
+		.name_size = sizeof("ceph.auth_mds"),
+		.getxattr_cb = ceph_vxattrcb_auth_mds,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
 	{ .name = NULL, 0 }	/* Required table terminator */
 };
 
Signature · 1 line
2.31.1
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Jeff Layton <[email protected]>
#5 lore raw

PATCH v2 1/1 ceph: add a new vxattr to return auth mds for an inode

In reply to Jeff Layton

Add a new vxattr that shows what MDS is authoritative for an inode (if we happen to have auth caps). If we don't have an auth cap for the inode then just return -1.

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

---
 fs/ceph/xattr.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

v2: ensure we hold the i_ceph_lock when working with the i_auth_cap.

fs/ceph/xattr.c +19 -0
index 1242db8d3444..159a1ffa4f4b 100644
@@ -340,6 +340,18 @@ static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val,
 			      ceph_cap_string(issued), issued);
 }
 
+static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci,
+				       char *val, size_t size)
+{
+	int ret;
+
+	spin_lock(&ci->i_ceph_lock);
+	ret = ceph_fmt_xattr(val, size, "%d",
+			     ci->i_auth_cap ? ci->i_auth_cap->session->s_mds : -1);
+	spin_unlock(&ci->i_ceph_lock);
+	return ret;
+}
+
 #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
 	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -473,6 +485,13 @@ static struct ceph_vxattr ceph_common_vxattrs[] = {
 		.exists_cb = NULL,
 		.flags = VXATTR_FLAG_READONLY,
 	},
+	{
+		.name = "ceph.auth_mds",
+		.name_size = sizeof("ceph.auth_mds"),
+		.getxattr_cb = ceph_vxattrcb_auth_mds,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
 	{ .name = NULL, 0 }	/* Required table terminator */
 };
 
Signature · 1 line
2.31.1
#6 lore raw
Quoted 11 lines · Jeff Layton

Add a new vxattr that shows what MDS is authoritative for an inode (if we happen to have auth caps). If we don't have an auth cap for the inode then just return -1.

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

---
 fs/ceph/xattr.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

v2: ensure we hold the i_ceph_lock when working with the i_auth_cap.

Yeah, this lock is definitely needed here. LGTM.

Cheers,
--
Luís

Quoted 40 lines
fs/ceph/xattr.c +19 -0
index 1242db8d3444..159a1ffa4f4b 100644
@@ -340,6 +340,18 @@ static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val,
 			      ceph_cap_string(issued), issued);
 }
 
+static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci,
+				       char *val, size_t size)
+{
+	int ret;
+
+	spin_lock(&ci->i_ceph_lock);
+	ret = ceph_fmt_xattr(val, size, "%d",
+			     ci->i_auth_cap ? ci->i_auth_cap->session->s_mds : -1);
+	spin_unlock(&ci->i_ceph_lock);
+	return ret;
+}
+
 #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
 	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -473,6 +485,13 @@ static struct ceph_vxattr ceph_common_vxattrs[] = {
 		.exists_cb = NULL,
 		.flags = VXATTR_FLAG_READONLY,
 	},
+	{
+		.name = "ceph.auth_mds",
+		.name_size = sizeof("ceph.auth_mds"),
+		.getxattr_cb = ceph_vxattrcb_auth_mds,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
 	{ .name = NULL, 0 }	/* Required table terminator */
 };
 
Signature · 1 line
2.31.1