From: Ben Evans Date: Mon, 12 Oct 2015 23:06:04 +0000 (-0400) Subject: LU-6746 ptlrpc: Move IT_* definitions to lustre_idl.h X-Git-Tag: 2.7.62~8 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9ea40a338c6e58a59792df56f963e58afced4e26 LU-6746 ptlrpc: Move IT_* definitions to lustre_idl.h Put IT_* definitions into an enum, as they're sent over the wire, adjust calls, print statements, etc. to use the new enum. Signed-off-by: Ben Evans Change-Id: Ie6ad700ac185459ace72ea67563864e43c548ec3 Reviewed-on: http://review.whamcloud.com/16228 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index c314664..1de86e6 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -2891,8 +2891,26 @@ union ldlm_gl_desc { extern void lustre_swab_gl_desc(union ldlm_gl_desc *); +enum ldlm_intent_flags { + IT_OPEN = 0x00000001, + IT_CREAT = 0x00000002, + IT_OPEN_CREAT = 0x00000003, + IT_READDIR = 0x00000004, + IT_GETATTR = 0x00000008, + IT_LOOKUP = 0x00000010, + IT_UNLINK = 0x00000020, + IT_TRUNC = 0x00000040, + IT_GETXATTR = 0x00000080, + IT_EXEC = 0x00000100, + IT_PIN = 0x00000200, + IT_LAYOUT = 0x00000400, + IT_QUOTA_DQACQ = 0x00000800, + IT_QUOTA_CONN = 0x00001000, + IT_SETXATTR = 0x00002000, +}; + struct ldlm_intent { - __u64 opc; + __u64 opc; }; extern void lustre_swab_ldlm_intent (struct ldlm_intent *i); diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 5e4a131..7a26d6f 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1104,7 +1104,7 @@ extern struct obd_ops ldlm_obd_ops; extern char *ldlm_lockname[]; extern char *ldlm_typename[]; -extern char *ldlm_it2str(int it); +extern const char *ldlm_it2str(enum ldlm_intent_flags it); /** * Just a fancy CDEBUG call with log level preset to LDLM_DEBUG. diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 7e23de3..9498abb 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -759,22 +759,6 @@ struct obd_device { struct lu_context; -/* /!\ must be coherent with include/linux/namei.h on patched kernel */ -#define IT_OPEN (1 << 0) -#define IT_CREAT (1 << 1) -#define IT_READDIR (1 << 2) -#define IT_GETATTR (1 << 3) -#define IT_LOOKUP (1 << 4) -#define IT_UNLINK (1 << 5) -#define IT_TRUNC (1 << 6) -#define IT_GETXATTR (1 << 7) -#define IT_EXEC (1 << 8) -#define IT_PIN (1 << 9) -#define IT_LAYOUT (1 << 10) -#define IT_QUOTA_DQACQ (1 << 11) -#define IT_QUOTA_CONN (1 << 12) -#define IT_SETXATTR (1 << 13) - static inline int it_to_lock_mode(struct lookup_intent *it) { /* CREAT needs to be tested before open (both could be set) */ diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 13741a0..ac92352 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -108,31 +108,31 @@ void ldlm_convert_policy_to_local(struct obd_export *exp, enum ldlm_type type, convert(wpolicy, lpolicy); } -char *ldlm_it2str(int it) -{ - switch (it) { - case IT_OPEN: - return "open"; - case IT_CREAT: - return "creat"; - case (IT_OPEN | IT_CREAT): - return "open|creat"; - case IT_READDIR: - return "readdir"; - case IT_GETATTR: - return "getattr"; - case IT_LOOKUP: - return "lookup"; - case IT_UNLINK: - return "unlink"; - case IT_GETXATTR: - return "getxattr"; - case IT_LAYOUT: - return "layout"; - default: - CERROR("Unknown intent %d\n", it); - return "UNKNOWN"; - } +const char *ldlm_it2str(enum ldlm_intent_flags it) +{ + switch (it) { + case IT_OPEN: + return "open"; + case IT_CREAT: + return "creat"; + case (IT_OPEN | IT_CREAT): + return "open|creat"; + case IT_READDIR: + return "readdir"; + case IT_GETATTR: + return "getattr"; + case IT_LOOKUP: + return "lookup"; + case IT_UNLINK: + return "unlink"; + case IT_GETXATTR: + return "getxattr"; + case IT_LAYOUT: + return "layout"; + default: + CERROR("Unknown intent 0x%08x\n", it); + return "UNKNOWN"; + } } EXPORT_SYMBOL(ldlm_it2str); diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 760feb5..7f96019 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -1445,16 +1445,16 @@ existing_lock: dlm_req->lock_flags, dlm_rep->lock_flags, lock->l_flags); LDLM_ERROR(lock, "sync lock"); - if (dlm_req->lock_flags & LDLM_FL_HAS_INTENT) { - struct ldlm_intent *it; - - it = req_capsule_client_get(&req->rq_pill, - &RMF_LDLM_INTENT); - if (it != NULL) { - CERROR("This is intent %s ("LPU64")\n", - ldlm_it2str(it->opc), it->opc); - } - } + if (dlm_req->lock_flags & LDLM_FL_HAS_INTENT) { + struct ldlm_intent *it; + + it = req_capsule_client_get(&req->rq_pill, + &RMF_LDLM_INTENT); + if (it != NULL) { + CERROR("This is intent %s ("LPU64")\n", + ldlm_it2str(it->opc), it->opc); + } + } } } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index d50e5a7..f6600d0 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -3296,54 +3296,55 @@ static int mdt_intent_reint(enum mdt_it_code opcode, RETURN(ELDLM_LOCK_ABORTED); } -static int mdt_intent_code(long itcode) +static int mdt_intent_code(enum ldlm_intent_flags itcode) { - int rc; + int rc; - switch(itcode) { - case IT_OPEN: - rc = MDT_IT_OPEN; - break; - case IT_OPEN|IT_CREAT: - rc = MDT_IT_OCREAT; - break; - case IT_CREAT: - rc = MDT_IT_CREATE; - break; - case IT_READDIR: - rc = MDT_IT_READDIR; - break; - case IT_GETATTR: - rc = MDT_IT_GETATTR; - break; - case IT_LOOKUP: - rc = MDT_IT_LOOKUP; - break; - case IT_UNLINK: - rc = MDT_IT_UNLINK; - break; - case IT_TRUNC: - rc = MDT_IT_TRUNC; - break; - case IT_GETXATTR: - rc = MDT_IT_GETXATTR; - break; - case IT_LAYOUT: - rc = MDT_IT_LAYOUT; - break; + switch (itcode) { + case IT_OPEN: + rc = MDT_IT_OPEN; + break; + case IT_OPEN|IT_CREAT: + rc = MDT_IT_OCREAT; + break; + case IT_CREAT: + rc = MDT_IT_CREATE; + break; + case IT_READDIR: + rc = MDT_IT_READDIR; + break; + case IT_GETATTR: + rc = MDT_IT_GETATTR; + break; + case IT_LOOKUP: + rc = MDT_IT_LOOKUP; + break; + case IT_UNLINK: + rc = MDT_IT_UNLINK; + break; + case IT_TRUNC: + rc = MDT_IT_TRUNC; + break; + case IT_GETXATTR: + rc = MDT_IT_GETXATTR; + break; + case IT_LAYOUT: + rc = MDT_IT_LAYOUT; + break; case IT_QUOTA_DQACQ: case IT_QUOTA_CONN: rc = MDT_IT_QUOTA; break; - default: - CERROR("Unknown intent opcode: %ld\n", itcode); - rc = -EINVAL; - break; - } - return rc; + default: + CERROR("Unknown intent opcode: 0x%08x\n", itcode); + rc = -EINVAL; + break; + } + return rc; } -static int mdt_intent_opc(long itopc, struct mdt_thread_info *info, +static int mdt_intent_opc(enum ldlm_intent_flags itopc, + struct mdt_thread_info *info, struct ldlm_lock **lockp, __u64 flags) { struct req_capsule *pill = info->mti_pill; diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 737e989..97e527c 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -2227,7 +2227,7 @@ void lustre_swab_ldlm_policy_data(union ldlm_wire_policy_data *d) void lustre_swab_ldlm_intent (struct ldlm_intent *i) { - __swab64s (&i->opc); + __swab64s(&i->opc); } void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r) diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index 9a76efc..f855f7f 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -46,15 +46,12 @@ #include #include #include - -#include "ptlrpc_internal.h" - void lustre_assert_wire_constants(void) { /* Wire protocol assertions generated by 'wirecheck' * (make -C lustre/utils newwiretest) - * running on Linux q 2.6.32-431.5.1.el6.lustre.x86_64 #1 SMP Wed Feb 12 11:01:08 CST 2014 x8 - * with gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) */ + * running on Linux centss05 2.6.32.431.29.2.el6_lustre #1 SMP Tue Sep 23 16:06:38 CDT 2014 x + * with gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) */ /* Constants... */ @@ -3083,6 +3080,34 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct ldlm_intent, opc)); LASSERTF((int)sizeof(((struct ldlm_intent *)0)->opc) == 8, "found %lld\n", (long long)(int)sizeof(((struct ldlm_intent *)0)->opc)); + LASSERTF(IT_OPEN == 1, "found %lld\n", + (long long)IT_OPEN); + LASSERTF(IT_CREAT == 2, "found %lld\n", + (long long)IT_CREAT); + LASSERTF(IT_READDIR == 4, "found %lld\n", + (long long)IT_READDIR); + LASSERTF(IT_GETATTR == 8, "found %lld\n", + (long long)IT_GETATTR); + LASSERTF(IT_LOOKUP == 16, "found %lld\n", + (long long)IT_LOOKUP); + LASSERTF(IT_UNLINK == 32, "found %lld\n", + (long long)IT_UNLINK); + LASSERTF(IT_TRUNC == 64, "found %lld\n", + (long long)IT_TRUNC); + LASSERTF(IT_GETXATTR == 128, "found %lld\n", + (long long)IT_GETXATTR); + LASSERTF(IT_EXEC == 256, "found %lld\n", + (long long)IT_EXEC); + LASSERTF(IT_PIN == 512, "found %lld\n", + (long long)IT_PIN); + LASSERTF(IT_LAYOUT == 1024, "found %lld\n", + (long long)IT_LAYOUT); + LASSERTF(IT_QUOTA_DQACQ == 2048, "found %lld\n", + (long long)IT_QUOTA_DQACQ); + LASSERTF(IT_QUOTA_CONN == 4096, "found %lld\n", + (long long)IT_QUOTA_CONN); + LASSERTF(IT_SETXATTR == 8192, "found %lld\n", + (long long)IT_SETXATTR); /* Checks for struct ldlm_resource_desc */ LASSERTF((int)sizeof(struct ldlm_resource_desc) == 40, "found %lld\n", diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index deb7437..c99ac1d 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -1296,6 +1296,20 @@ check_ldlm_intent(void) BLANK_LINE(); CHECK_STRUCT(ldlm_intent); CHECK_MEMBER(ldlm_intent, opc); + CHECK_VALUE(IT_OPEN); + CHECK_VALUE(IT_CREAT); + CHECK_VALUE(IT_READDIR); + CHECK_VALUE(IT_GETATTR); + CHECK_VALUE(IT_LOOKUP); + CHECK_VALUE(IT_UNLINK); + CHECK_VALUE(IT_TRUNC); + CHECK_VALUE(IT_GETXATTR); + CHECK_VALUE(IT_EXEC); + CHECK_VALUE(IT_PIN); + CHECK_VALUE(IT_LAYOUT); + CHECK_VALUE(IT_QUOTA_DQACQ); + CHECK_VALUE(IT_QUOTA_CONN); + CHECK_VALUE(IT_SETXATTR); } static void diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index b8b939e..1ac6ae1 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -61,8 +61,9 @@ void lustre_assert_wire_constants(void) { /* Wire protocol assertions generated by 'wirecheck' * (make -C lustre/utils newwiretest) - * running on Linux q 2.6.32-431.5.1.el6.lustre.x86_64 #1 SMP Wed Feb 12 11:01:08 CST 2014 x8 - * with gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) */ + * running on Linux centss05 2.6.32.431.29.2.el6_lustre #1 SMP Tue Sep 23 16:06:38 CDT 2014 x + * with gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) */ + /* Constants... */ LASSERTF(PTL_RPC_MSG_REQUEST == 4711, "found %lld\n", @@ -3090,6 +3091,34 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct ldlm_intent, opc)); LASSERTF((int)sizeof(((struct ldlm_intent *)0)->opc) == 8, "found %lld\n", (long long)(int)sizeof(((struct ldlm_intent *)0)->opc)); + LASSERTF(IT_OPEN == 1, "found %lld\n", + (long long)IT_OPEN); + LASSERTF(IT_CREAT == 2, "found %lld\n", + (long long)IT_CREAT); + LASSERTF(IT_READDIR == 4, "found %lld\n", + (long long)IT_READDIR); + LASSERTF(IT_GETATTR == 8, "found %lld\n", + (long long)IT_GETATTR); + LASSERTF(IT_LOOKUP == 16, "found %lld\n", + (long long)IT_LOOKUP); + LASSERTF(IT_UNLINK == 32, "found %lld\n", + (long long)IT_UNLINK); + LASSERTF(IT_TRUNC == 64, "found %lld\n", + (long long)IT_TRUNC); + LASSERTF(IT_GETXATTR == 128, "found %lld\n", + (long long)IT_GETXATTR); + LASSERTF(IT_EXEC == 256, "found %lld\n", + (long long)IT_EXEC); + LASSERTF(IT_PIN == 512, "found %lld\n", + (long long)IT_PIN); + LASSERTF(IT_LAYOUT == 1024, "found %lld\n", + (long long)IT_LAYOUT); + LASSERTF(IT_QUOTA_DQACQ == 2048, "found %lld\n", + (long long)IT_QUOTA_DQACQ); + LASSERTF(IT_QUOTA_CONN == 4096, "found %lld\n", + (long long)IT_QUOTA_CONN); + LASSERTF(IT_SETXATTR == 8192, "found %lld\n", + (long long)IT_SETXATTR); /* Checks for struct ldlm_resource_desc */ LASSERTF((int)sizeof(struct ldlm_resource_desc) == 40, "found %lld\n",