ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ceph: add a new vxattr to return auth mds for an inode
@ 2021-07-27 11:35 Jeff Layton
  2021-07-27 14:46 ` Luis Henriques
  2021-07-27 18:42 ` [PATCH v2] " Jeff Layton
  0 siblings, 2 replies; 7+ messages in thread
From: Jeff Layton @ 2021-07-27 11:35 UTC (permalink / raw)
  To: ceph-devel; +Cc: idryomov

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
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/xattr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 1242db8d3444..70664a19b8dc 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -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 */
 };
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-28 10:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 11:35 [PATCH] ceph: add a new vxattr to return auth mds for an inode Jeff Layton
2021-07-27 14:46 ` Luis Henriques
2021-07-27 15:17   ` Jeff Layton
2021-07-27 15:45     ` Luis Henriques
2021-07-27 15:53       ` Jeff Layton
2021-07-27 18:42 ` [PATCH v2] " Jeff Layton
2021-07-28 10:28   ` Luis Henriques

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).