[lustre-devel] [PATCH 03/18] lustre: uapi: per-user changelog names and mask

James Simmons jsimmons at infradead.org
Mon Jul 19 05:31:58 PDT 2021


From: Mikhail Pershin <mpershin at whamcloud.com>

Allow specifying a name for newly-registered changelog users,
rather than the default "clNNN" that is otherwise used. This
allows services to register a "well-known" changelog user,
rather than having to store the changelog username in HA storage
outside of the filesystem.

Each changelog user still has a unique ID appended to it, to allow
the changelog_clear and changelog_deregister commands to be run
using only the ID if necessary/desired. User name can be used to
deregister. User name is also unique per server.

If no name is given, then default "cl" format is used.

With this new functionality, it is possible to specify the name like:
  testfs-MDT0000: Registered changelog userid 'cl13-watcher'

Per-user mask is also added to allow specific operation logging on
per-user basis. Mask can be set only during registration. Resulting
mask from per-server mask and all user masks is used for current
changelog operations.

Lustre-commit: a15eb4f13224e14 ("LU-13055 mdd: per-user changelog names and mask")
Signed-off-by: Mikhail Pershin <mpershin at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/43380
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: John L. Hammond <jhammond at whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson at ddn.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/obdclass/llog_swab.c          | 17 ++++++++++++-----
 fs/lustre/ptlrpc/wiretest.c             | 23 ++++++++++++-----------
 include/uapi/linux/lustre/lustre_idl.h  | 18 ++++++++++++++++++
 include/uapi/linux/lustre/lustre_user.h |  2 +-
 4 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/fs/lustre/obdclass/llog_swab.c b/fs/lustre/obdclass/llog_swab.c
index 0b83dc3..7bfc304 100644
--- a/fs/lustre/obdclass/llog_swab.c
+++ b/fs/lustre/obdclass/llog_swab.c
@@ -185,19 +185,26 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec)
 		 * to compute its location at runtime
 		 */
 		tail = (struct llog_rec_tail *)((char *)&cr->cr +
-						changelog_rec_size(&cr->cr) +
-						cr->cr.cr_namelen);
+						rec->lrh_len - sizeof(*tail));
 		break;
 	}
 
 	case CHANGELOG_USER_REC:
+	case CHANGELOG_USER_REC2:
 	{
-		struct llog_changelog_user_rec *cur =
-			(struct llog_changelog_user_rec *)rec;
+		struct llog_changelog_user_rec2 *cur =
+			(struct llog_changelog_user_rec2 *)rec;
 
 		__swab32s(&cur->cur_id);
 		__swab64s(&cur->cur_endrec);
-		tail = &cur->cur_tail;
+		if (cur->cur_hdr.lrh_type == CHANGELOG_USER_REC2) {
+			__swab32s(&cur->cur_mask);
+			BUILD_BUG_ON(offsetof(typeof(*cur), cur_padding1) == 0);
+			BUILD_BUG_ON(offsetof(typeof(*cur), cur_padding2) == 0);
+			BUILD_BUG_ON(offsetof(typeof(*cur), cur_padding3) == 0);
+		}
+		tail = (struct llog_rec_tail *)((char *)rec +
+						rec->lrh_len - sizeof(*tail));
 		break;
 	}
 
diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c
index 9e0eaa7..c7eb218 100644
--- a/fs/lustre/ptlrpc/wiretest.c
+++ b/fs/lustre/ptlrpc/wiretest.c
@@ -3567,17 +3567,18 @@ void lustre_assert_wire_constants(void)
 		 (long long)(int)offsetof(struct llog_logid, lgl_ogen));
 	LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogen) == 4, "found %lld\n",
 		 (long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogen));
-	BUILD_BUG_ON(OST_SZ_REC != 274730752);
-	BUILD_BUG_ON(MDS_UNLINK_REC != 274801668);
-	BUILD_BUG_ON(MDS_UNLINK64_REC != 275325956);
-	BUILD_BUG_ON(MDS_SETATTR64_REC != 275325953);
-	BUILD_BUG_ON(OBD_CFG_REC != 274857984);
-	BUILD_BUG_ON(LLOG_GEN_REC != 274989056);
-	BUILD_BUG_ON(CHANGELOG_REC != 275120128);
-	BUILD_BUG_ON(CHANGELOG_USER_REC != 275185664);
-	BUILD_BUG_ON(HSM_AGENT_REC != 275251200);
-	BUILD_BUG_ON(LLOG_HDR_MAGIC != 275010873);
-	BUILD_BUG_ON(LLOG_LOGID_MAGIC != 275010875);
+	BUILD_BUG_ON(OST_SZ_REC != 0x10600f00);
+	BUILD_BUG_ON(MDS_UNLINK_REC != 0x10612404);
+	BUILD_BUG_ON(MDS_UNLINK64_REC != 0x10692404);
+	BUILD_BUG_ON(MDS_SETATTR64_REC != 0x10692401);
+	BUILD_BUG_ON(OBD_CFG_REC != 0x10620000);
+	BUILD_BUG_ON(LLOG_GEN_REC != 0x10640000);
+	BUILD_BUG_ON(CHANGELOG_REC != 0x10660000);
+	BUILD_BUG_ON(CHANGELOG_USER_REC != 0x10670000);
+	BUILD_BUG_ON(CHANGELOG_USER_REC2 != 0x10670002);
+	BUILD_BUG_ON(HSM_AGENT_REC != 0x10680000);
+	BUILD_BUG_ON(LLOG_HDR_MAGIC != 0x10645539);
+	BUILD_BUG_ON(LLOG_LOGID_MAGIC != 0x1064553b);
 
 	/* Checks for struct llog_catid */
 	LASSERTF((int)sizeof(struct llog_catid) == 32, "found %lld\n",
diff --git a/include/uapi/linux/lustre/lustre_idl.h b/include/uapi/linux/lustre/lustre_idl.h
index 68bb807..8f49adb 100644
--- a/include/uapi/linux/lustre/lustre_idl.h
+++ b/include/uapi/linux/lustre/lustre_idl.h
@@ -2480,6 +2480,7 @@ enum llog_op_type {
 	/* LLOG_JOIN_REC	= LLOG_OP_MAGIC | 0x50000, obsolete  1.8.0 */
 	CHANGELOG_REC		= LLOG_OP_MAGIC | 0x60000,
 	CHANGELOG_USER_REC	= LLOG_OP_MAGIC | 0x70000,
+	CHANGELOG_USER_REC2	= LLOG_OP_MAGIC | 0x70002,
 	HSM_AGENT_REC		= LLOG_OP_MAGIC | 0x80000,
 	LLOG_HDR_MAGIC		= LLOG_OP_MAGIC | 0x45539,
 	LLOG_LOGID_MAGIC	= LLOG_OP_MAGIC | 0x4553b,
@@ -2575,6 +2576,8 @@ struct llog_changelog_rec {
 	struct llog_rec_tail	cr_do_not_use;	/**< for_sizezof_only */
 } __attribute__((packed));
 
+#define CHANGELOG_USER_NAMELEN 16 /* base name including NUL terminator */
+
 struct llog_changelog_user_rec {
 	struct llog_rec_hdr	cur_hdr;
 	__u32			cur_id;
@@ -2583,6 +2586,21 @@ struct llog_changelog_user_rec {
 	struct llog_rec_tail	cur_tail;
 } __attribute__((packed));
 
+/* this is twice the size of CHANGELOG_USER_REC */
+struct llog_changelog_user_rec2 {
+	struct llog_rec_hdr	cur_hdr;
+	__u32			cur_id;
+	/* only for use in relative time comparisons to detect idle users */
+	__u32			cur_time;
+	__u64			cur_endrec;
+	__u32                   cur_mask;
+	__u32			cur_padding1;
+	char			cur_name[CHANGELOG_USER_NAMELEN];
+	__u64			cur_padding2;
+	__u64			cur_padding3;
+	struct llog_rec_tail	cur_tail;
+} __attribute__((packed));
+
 enum agent_req_status {
 	ARS_WAITING,
 	ARS_STARTED,
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index 49b013c..0cd3500 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -1248,7 +1248,7 @@ enum changelog_rec_type {
 	CL_RESYNC	= 22, /* FLR: file was resync-ed */
 	CL_GETXATTR	= 23,
 	CL_DN_OPEN	= 24, /* denied open */
-	CL_LAST
+	CL_LAST,
 };
 
 static inline const char *changelog_type2str(int type)
-- 
1.8.3.1



More information about the lustre-devel mailing list