From: Andreas Dilger Date: Sat, 11 Nov 2017 07:30:51 +0000 (-0700) Subject: LU-6349 idl: add PTLRPC definitions to enum X-Git-Tag: 2.10.58~27 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=0c9bb26fc4d9157aaa10df2ba0a1796f2e5fc21e LU-6349 idl: add PTLRPC definitions to enum Add PTLRPC definitions to enums for cleanliness, and use them: enum lustre_msg_version for LUSTRE_*_VERSION enum lustre_msg_magic for LUSTRE_MSG_MAGIC_* enum lustre_msghdr for MSGHDR_* Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: Ie17619bfc2433339ab32e257d596adf64c2c4ff0 Reviewed-on: https://review.whamcloud.com/30958 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Emoly Liu Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index b927d04..25e75f8 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -359,7 +359,7 @@ struct tgt_handler { /* Flags in enum tgt_handler_flags */ __u32 th_flags; /* Request version for this opcode */ - int th_version; + enum lustre_msg_version th_version; /* Handler function */ int (*th_act)(struct tgt_session_info *tsi); /* Handler function for high priority requests */ diff --git a/lustre/include/lustre_import.h b/lustre/include/lustre_import.h index d48dee1..5ff1f84 100644 --- a/lustre/include/lustre_import.h +++ b/lustre/include/lustre_import.h @@ -311,13 +311,13 @@ struct obd_import { __u64 imp_connect_flags2_orig; int imp_connect_error; - __u32 imp_msg_magic; - /* adjusted based on server capability */ - __u32 imp_msghdr_flags; + enum lustre_msg_magic imp_msg_magic; + /* adjusted based on server capability */ + enum lustre_msghdr imp_msghdr_flags; - /* adaptive timeout data */ - struct imp_at imp_at; - time64_t imp_last_reply_time; /* for health check */ + /* adaptive timeout data */ + struct imp_at imp_at; + time64_t imp_last_reply_time; /* for health check */ }; /* import.c */ diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 3a33211..f9daeae 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -2364,7 +2364,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg); void lustre_msg_add_op_flags(struct lustre_msg *msg, __u32 flags); struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg); __u32 lustre_msg_get_type(struct lustre_msg *msg); -__u32 lustre_msg_get_version(struct lustre_msg *msg); +enum lustre_msg_version lustre_msg_get_version(struct lustre_msg *msg); void lustre_msg_add_version(struct lustre_msg *msg, __u32 version); __u32 lustre_msg_get_opc(struct lustre_msg *msg); __u64 lustre_msg_get_last_xid(struct lustre_msg *msg); diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index 73c8b83..aae5821 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -570,15 +570,20 @@ struct lustre_handle_array { }; /* lustre_msg struct magic. DON'T use swabbed values of MAGIC as magic! */ -#define LUSTRE_MSG_MAGIC_V2 0x0BD00BD3 -#define LUSTRE_MSG_MAGIC_V2_SWABBED 0xD30BD00B -#define LUSTRE_MSG_MAGIC LUSTRE_MSG_MAGIC_V2 +enum lustre_msg_magic { + LUSTRE_MSG_MAGIC_V2 = 0x0BD00BD3, + LUSTRE_MSG_MAGIC_V2_SWABBED = 0xD30BD00B, + LUSTRE_MSG_MAGIC = LUSTRE_MSG_MAGIC_V2 +}; /* flags for lm_flags */ -#define MSGHDR_AT_SUPPORT 0x1 /* adaptive timeouts, lm_cksum valid +enum lustre_msghdr { + MSGHDR_AT_SUPPORT = 0x1, /* adaptive timeouts, lm_cksum valid * in early reply messages */ -#define MSGHDR_CKSUM_INCOMPAT18 0x2 /* compat for 1.8, needs to be set well + MSGHDR_CKSUM_INCOMPAT18 = 0x2, /* compat for 1.8, needs to be set well * beyond 2.8.0 for compatibility */ +}; + #define lustre_msg lustre_msg_v2 /* we depend on this structure to be 8-byte aligned */ /* this type is only endian-adjusted in lustre_unpack_msg() */ @@ -588,7 +593,7 @@ struct lustre_msg_v2 { __u32 lm_magic; /* RPC version magic = LUSTRE_MSG_MAGIC_V2 */ __u32 lm_repsize; /* size of preallocated reply buffer */ __u32 lm_cksum; /* CRC32 of ptlrpc_body early reply messages */ - __u32 lm_flags; /* MSGHDR_* flags */ + __u32 lm_flags; /* enum lustre_msghdr MSGHDR_* flags */ __u32 lm_padding_2; /* unused */ __u32 lm_padding_3; /* unused */ __u32 lm_buflens[0]; /* length of additional buffers in bytes, @@ -605,14 +610,16 @@ struct lustre_msg_v2 { #define PTL_RPC_MSG_REPLY 4713 /* normal RPC reply message */ /* ptlrpc_body pb_version ((target_version << 16) | rpc_version) */ -#define PTLRPC_MSG_VERSION 0x00000003 -#define LUSTRE_VERSION_MASK 0xffff0000 -#define LUSTRE_OBD_VERSION 0x00010000 -#define LUSTRE_MDS_VERSION 0x00020000 -#define LUSTRE_OST_VERSION 0x00030000 -#define LUSTRE_DLM_VERSION 0x00040000 -#define LUSTRE_LOG_VERSION 0x00050000 -#define LUSTRE_MGS_VERSION 0x00060000 +enum lustre_msg_version { + PTLRPC_MSG_VERSION = 0x00000003, + LUSTRE_VERSION_MASK = 0xffff0000, + LUSTRE_OBD_VERSION = 0x00010000, + LUSTRE_MDS_VERSION = 0x00020000, + LUSTRE_OST_VERSION = 0x00030000, + LUSTRE_DLM_VERSION = 0x00040000, + LUSTRE_LOG_VERSION = 0x00050000, + LUSTRE_MGS_VERSION = 0x00060000, +}; /* pb_flags that apply to all request messages */ /* #define MSG_LAST_REPLAY 0x0001 obsolete 2.0 => {REQ,LOCK}_REPLAY_DONE */ diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index fac4b7d..ce07f42 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -90,13 +90,15 @@ int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout, } static inline int lustre_msg_check_version_v2(struct lustre_msg_v2 *msg, - __u32 version) + enum lustre_msg_version version) { - __u32 ver = lustre_msg_get_version(msg); - return (ver & LUSTRE_VERSION_MASK) != version; + enum lustre_msg_version ver = lustre_msg_get_version(msg); + + return (ver & LUSTRE_VERSION_MASK) != version; } -int lustre_msg_check_version(struct lustre_msg *msg, __u32 version) +int lustre_msg_check_version(struct lustre_msg *msg, + enum lustre_msg_version version) { #define LUSTRE_MSG_MAGIC_V1 0x0BD00BD0 switch (msg->lm_magic) { @@ -800,7 +802,7 @@ static inline struct ptlrpc_body *lustre_msg_ptlrpc_body(struct lustre_msg *msg) sizeof(struct ptlrpc_body_v2)); } -__u32 lustre_msghdr_get_flags(struct lustre_msg *msg) +enum lustre_msghdr lustre_msghdr_get_flags(struct lustre_msg *msg) { switch (msg->lm_magic) { case LUSTRE_MSG_MAGIC_V2: @@ -954,7 +956,7 @@ __u32 lustre_msg_get_type(struct lustre_msg *msg) } EXPORT_SYMBOL(lustre_msg_get_type); -__u32 lustre_msg_get_version(struct lustre_msg *msg) +enum lustre_msg_version lustre_msg_get_version(struct lustre_msg *msg) { switch (msg->lm_magic) { case LUSTRE_MSG_MAGIC_V2: {