From 1d1c177f6bf3cd0201a1b5da726e529950fe8bf4 Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Fri, 24 Feb 2012 16:42:23 +0100 Subject: [PATCH] LU-1318 ldlm: allow different LVB structures to be used The DLM code always assumes that the request buffer storing the LVB is of type ost_lvb. This patch allows new LVB types to be defined and used. Although there is still one single LVB structure defined (i.e. ost_lvb), the new quota architecture will define its own LVB soon. Signed-off-by: Johann Lombardi Change-Id: I497d774eb4b66029ff2755739bbe75190f6aeee8 Reviewed-on: http://review.whamcloud.com/2649 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_idl.h | 11 +++++++++-- lustre/ptlrpc/layout.c | 2 +- lustre/ptlrpc/pack_generic.c | 17 +++++++++++------ lustre/ptlrpc/ptlrpc_module.c | 2 +- lustre/utils/req-layout.c | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 79d9303..fa09ec4 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -1529,8 +1529,6 @@ struct ost_lvb { __u64 lvb_blocks; }; -extern void lustre_swab_ost_lvb(struct ost_lvb *); - /* * MDS REQ RECORDS */ @@ -2336,6 +2334,15 @@ typedef union { extern void lustre_swab_ldlm_policy_data (ldlm_wire_policy_data_t *d); +/* Similarly to ldlm_wire_policy_data_t, there is one common swabber for all + * LVB types. As a result, any new LVB structure must match the fields of the + * ost_lvb structure. */ +union ldlm_wire_lvb { + struct ost_lvb l_ost; +}; + +extern void lustre_swab_lvb(union ldlm_wire_lvb *); + struct ldlm_intent { __u64 opc; }; diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index 3362a24..84b4042 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -878,7 +878,7 @@ struct req_msg_field RMF_LDLM_INTENT = EXPORT_SYMBOL(RMF_LDLM_INTENT); struct req_msg_field RMF_DLM_LVB = - DEFINE_MSGF("dlm_lvb", 0, sizeof(struct ost_lvb), lustre_swab_ost_lvb, + DEFINE_MSGF("dlm_lvb", 0, sizeof(union ldlm_wire_lvb), lustre_swab_lvb, NULL); EXPORT_SYMBOL(RMF_DLM_LVB); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index bbe5c8b..14ee58c 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -1686,13 +1686,18 @@ void lustre_swab_generic_32s(__u32 *val) __swab32s(val); } -void lustre_swab_ost_lvb(struct ost_lvb *lvb) +void lustre_swab_lvb(union ldlm_wire_lvb *lvb) { - __swab64s(&lvb->lvb_size); - __swab64s(&lvb->lvb_mtime); - __swab64s(&lvb->lvb_atime); - __swab64s(&lvb->lvb_ctime); - __swab64s(&lvb->lvb_blocks); + /* The ldlm_wire_lvb union represents all the possible LVB types. + * Unfortunately, there is no way to know what member of the union we + * are dealing with at this point. Therefore, all LVB structures must + * have fields of the same types, although used for different purposes + */ + __swab64s(&lvb->l_ost.lvb_size); + __swab64s(&lvb->l_ost.lvb_mtime); + __swab64s(&lvb->l_ost.lvb_atime); + __swab64s(&lvb->l_ost.lvb_ctime); + __swab64s(&lvb->l_ost.lvb_blocks); } void lustre_swab_mdt_body (struct mdt_body *b) diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c index 89f4946..d410107 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -250,7 +250,7 @@ EXPORT_SYMBOL(lustre_swab_obd_ioobj); EXPORT_SYMBOL(lustre_swab_niobuf_remote); EXPORT_SYMBOL(lustre_swab_ost_body); EXPORT_SYMBOL(lustre_swab_ost_last_id); -EXPORT_SYMBOL(lustre_swab_ost_lvb); +EXPORT_SYMBOL(lustre_swab_lvb); EXPORT_SYMBOL(lustre_swab_mdt_body); EXPORT_SYMBOL(lustre_swab_mdt_ioepoch); EXPORT_SYMBOL(lustre_swab_obd_quotactl); diff --git a/lustre/utils/req-layout.c b/lustre/utils/req-layout.c index 31c4448..d21cc41 100644 --- a/lustre/utils/req-layout.c +++ b/lustre/utils/req-layout.c @@ -75,7 +75,7 @@ #define lustre_swab_ost_last_id NULL #define lustre_swab_fiemap NULL #define lustre_swab_qdata NULL -#define lustre_swab_ost_lvb NULL +#define lustre_swab_lvb NULL #define lustre_swab_mgs_config_body NULL #define lustre_swab_mgs_config_res NULL #define dump_rniobuf NULL -- 1.8.3.1