Whamcloud - gitweb
* Fixed 1299:aborted request tripped LASSERT(!req->rq_receiving_reply)
authoreeb <eeb>
Wed, 21 May 2003 13:12:47 +0000 (13:12 +0000)
committereeb <eeb>
Wed, 21 May 2003 13:12:47 +0000 (13:12 +0000)
*  Fixed ll_readpage() to read file's preferred block size to take
   advantage of obd_brw_async()

*  made obdstat names consistent ('echo' and 'filter')

*  fixed what looked like a type in portals/configure.in and hacked
   portals/knals/qswnal/Makefile.am to -I the qsw headers from the
   configured dir.

*  Put magic into portals network interface handles and put type info into
   portals ME and MD handles, and portals' own internal EQ handles.  Misuse
   now makes things fail/crash more promptly.

19 files changed:
lnet/configure.in
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-p30.h
lnet/include/lnet/lib-types.h
lnet/klnds/qswlnd/Makefile.am
lnet/lnet/api-ni.c
lnet/lnet/lib-eq.c
lnet/lnet/lib-init.c
lnet/lnet/lib-md.c
lnet/lnet/lib-me.c
lustre/portals/configure.in
lustre/portals/include/portals/lib-p30.h
lustre/portals/include/portals/lib-types.h
lustre/portals/knals/qswnal/Makefile.am
lustre/portals/portals/api-ni.c
lustre/portals/portals/lib-eq.c
lustre/portals/portals/lib-init.c
lustre/portals/portals/lib-md.c
lustre/portals/portals/lib-me.c

index ce916ac..2ee86b2 100644 (file)
@@ -13,7 +13,7 @@ AM_INIT_AUTOMAKE(portals, builtin([esyscmd], [sed -ne '/.*define IVERSION /{ s/.
 
 sinclude(build.m4)
 sinclude(archdep.m4)
-sinclude<portalsconf.m4)
+sinclude(portalsconf.m4)
 
 if test x$enable_inkernel = xyes ; then
 cp Kernelenv.mk Kernelenv.in
index ec3393b..b70e128 100644 (file)
@@ -264,8 +264,8 @@ lib_msg_free(nal_cb_t *nal, lib_msg_t *msg)
 }
 #endif
 
-extern lib_handle_t *lib_lookup_cookie (nal_cb_t *nal, __u64 cookie);
-extern void lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh);
+extern lib_handle_t *lib_lookup_cookie (nal_cb_t *nal, __u64 cookie, int type);
+extern void lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh, int type);
 extern void lib_invalidate_handle (nal_cb_t *nal, lib_handle_t *lh);
 
 static inline void
@@ -278,8 +278,8 @@ static inline lib_eq_t *
 ptl_handle2eq (ptl_handle_eq_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie
+                                              PTL_COOKIE_TYPE_EQ);
         if (lh == NULL)
                 return (NULL);
 
@@ -296,8 +296,8 @@ static inline lib_md_t *
 ptl_handle2md (ptl_handle_md_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie,
+                                              PTL_COOKIE_TYPE_MD);
         if (lh == NULL)
                 return (NULL);
 
@@ -313,7 +313,8 @@ ptl_wire_handle2md (ptl_handle_wire_t *wh, nal_cb_t *nal)
         if (wh->wh_interface_cookie != nal->ni.ni_interface_cookie)
                 return (NULL);
         
-        lh = lib_lookup_cookie (nal, wh->wh_object_cookie);
+        lh = lib_lookup_cookie (nal, wh->wh_object_cookie,
+                                PTL_COOKIE_TYPE_MD);
         if (lh == NULL)
                 return (NULL);
 
@@ -330,8 +331,8 @@ static inline lib_me_t *
 ptl_handle2me (ptl_handle_me_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie,
+                                              PTL_COOKIE_TYPE_ME);
         if (lh == NULL)
                 return (NULL);
 
index ec3393b..b70e128 100644 (file)
@@ -264,8 +264,8 @@ lib_msg_free(nal_cb_t *nal, lib_msg_t *msg)
 }
 #endif
 
-extern lib_handle_t *lib_lookup_cookie (nal_cb_t *nal, __u64 cookie);
-extern void lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh);
+extern lib_handle_t *lib_lookup_cookie (nal_cb_t *nal, __u64 cookie, int type);
+extern void lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh, int type);
 extern void lib_invalidate_handle (nal_cb_t *nal, lib_handle_t *lh);
 
 static inline void
@@ -278,8 +278,8 @@ static inline lib_eq_t *
 ptl_handle2eq (ptl_handle_eq_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie
+                                              PTL_COOKIE_TYPE_EQ);
         if (lh == NULL)
                 return (NULL);
 
@@ -296,8 +296,8 @@ static inline lib_md_t *
 ptl_handle2md (ptl_handle_md_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie,
+                                              PTL_COOKIE_TYPE_MD);
         if (lh == NULL)
                 return (NULL);
 
@@ -313,7 +313,8 @@ ptl_wire_handle2md (ptl_handle_wire_t *wh, nal_cb_t *nal)
         if (wh->wh_interface_cookie != nal->ni.ni_interface_cookie)
                 return (NULL);
         
-        lh = lib_lookup_cookie (nal, wh->wh_object_cookie);
+        lh = lib_lookup_cookie (nal, wh->wh_object_cookie,
+                                PTL_COOKIE_TYPE_MD);
         if (lh == NULL)
                 return (NULL);
 
@@ -330,8 +331,8 @@ static inline lib_me_t *
 ptl_handle2me (ptl_handle_me_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie,
+                                              PTL_COOKIE_TYPE_ME);
         if (lh == NULL)
                 return (NULL);
 
index 08ea118..bece0a3 100644 (file)
@@ -241,6 +241,13 @@ typedef struct {
         unsigned int      tp_threshold;        /* # failures to simulate */
 } lib_test_peer_t;
 
+#define PTL_COOKIE_TYPE_MD    1
+#define PTL_COOKIE_TYPE_ME    2
+#define PTL_COOKIE_TYPE_EQ    3
+#define PTL_COOKIE_TYPES      4
+/* PTL_COOKIE_TYPES must be a power of 2, so the cookie type can be
+ * extracted by masking with (PTL_COOKIE_TYPES - 1) */
+
 typedef struct {
         int up;
         int refcnt;
index 6759b96..3eb4dd5 100644 (file)
@@ -13,4 +13,5 @@ EXTRA_PROGRAMS = kqswnal
 #CFLAGS:= @KCFLAGS@ 
 #CPPFLAGS:=@KCPPFLAGS@
 DEFS =
+CPPFLAGS=@CPPFLAGS@ @with_quadrics@
 kqswnal_SOURCES = qswnal.c qswnal_cb.c qswnal.h
index 1957822..b2e069e 100644 (file)
 
 #include <portals/api-support.h>
 
-#define MAX_NIS 8
+/* Put some magic in the NI handle so uninitialised/zeroed handles are easy
+ * to spot */
+#define NI_HANDLE_MAGIC  0xebc0de00
+#define NI_HANDLE_MASK   0x000000ff
+#define MAX_NIS          8         
 static nal_t *ptl_interfaces[MAX_NIS];
 int ptl_num_interfaces = 0;
 
@@ -37,7 +41,11 @@ nal_t *ptl_hndl2nal(ptl_handle_any_t *handle)
          * setup/teardown.  That ensures her NI handle can't get
          * invalidated out from under her (or worse, swapped for a
          * completely different interface!) */
-        
+
+        if (((idx ^ NI_HANDLE_MAGIC) & ~NI_HANDLE_MASK) != 0)
+                return NULL;
+
+        idx &= NI_HANDLE_MASK;
         if (idx < MAX_NIS)
                 return ptl_interfaces[idx];
 
@@ -48,6 +56,8 @@ int ptl_ni_init(void)
 {
         int i;
 
+        LASSERT (MAX_NIS <= (NI_HANDLE_MASK + 1));
+        
         for (i = 0; i < MAX_NIS; i++)
                 ptl_interfaces[i] = NULL;
 
@@ -114,7 +124,7 @@ int PtlNIInit(ptl_interface_t interface, ptl_pt_index_t ptl_size,
         for (i = 0; i < ptl_num_interfaces; i++) {
                 if (ptl_interfaces[i] == nal) {
                         nal->refct++;
-                        handle->nal_idx = i;
+                        handle->nal_idx = (NI_HANDLE_MAGIC & ~NI_HANDLE_MASK) | i;
                         fprintf(stderr, "Returning existing NAL (%d)\n", i);
                         ptl_ni_init_mutex_exit ();
                         return PTL_OK;
@@ -122,7 +132,6 @@ int PtlNIInit(ptl_interface_t interface, ptl_pt_index_t ptl_size,
         }
         nal->refct = 1;
 
-        handle->nal_idx = ptl_num_interfaces;
         if (ptl_num_interfaces >= MAX_NIS) {
                 if (nal->shutdown)
                         nal->shutdown (nal, ptl_num_interfaces);
@@ -130,6 +139,7 @@ int PtlNIInit(ptl_interface_t interface, ptl_pt_index_t ptl_size,
                 return PTL_NOSPACE;
         }
 
+        handle->nal_idx = (NI_HANDLE_MAGIC & ~NI_HANDLE_MASK) | ptl_num_interfaces;
         ptl_interfaces[ptl_num_interfaces++] = nal;
 
         ptl_eq_ni_init(nal);
@@ -143,6 +153,7 @@ int PtlNIInit(ptl_interface_t interface, ptl_pt_index_t ptl_size,
 int PtlNIFini(ptl_handle_ni_t ni)
 {
         nal_t *nal;
+        int idx;
         int rc;
 
         if (!ptl_init)
@@ -156,6 +167,8 @@ int PtlNIFini(ptl_handle_ni_t ni)
                 return PTL_INV_HANDLE;
         }
 
+        idx = ni.nal_idx & NI_HANDLE_MASK;
+
         nal->refct--;
         if (nal->refct > 0) {
                 ptl_ni_init_mutex_exit ();
@@ -167,9 +180,9 @@ int PtlNIFini(ptl_handle_ni_t ni)
 
         rc = PTL_OK;
         if (nal->shutdown)
-                rc = nal->shutdown(nal, ni.nal_idx);
+                rc = nal->shutdown(nal, idx);
 
-        ptl_interfaces[ni.nal_idx] = NULL;
+        ptl_interfaces[idx] = NULL;
         ptl_num_interfaces--;
 
         ptl_ni_init_mutex_exit ();
index 6238895..ce343c1 100644 (file)
@@ -76,7 +76,7 @@ int do_PtlEQAlloc_internal(nal_cb_t * nal, void *private, void *v_args,
         eq->eq_refcount = 0;
         eq->event_callback = args->callback_in;
 
-        lib_initialise_handle (nal, &eq->eq_lh);
+        lib_initialise_handle (nal, &eq->eq_lh, PTL_COOKIE_TYPE_EQ);
         list_add (&eq->eq_list, &nal->ni.ni_active_eqs);
 
         state_unlock(nal, &flags);
index 2df4120..d6315c6 100644 (file)
@@ -278,7 +278,7 @@ lib_setup_handle_hash (nal_cb_t *nal)
         for (i = 0; i < ni->ni_lh_hash_size; i++)
                 INIT_LIST_HEAD (&ni->ni_lh_hash_table[i]);
 
-        ni->ni_next_object_cookie = 0;
+        ni->ni_next_object_cookie = PTL_COOKIE_TYPES;
         
         return (PTL_OK);
 }
@@ -296,7 +296,7 @@ lib_cleanup_handle_hash (nal_cb_t *nal)
 }
 
 lib_handle_t *
-lib_lookup_cookie (nal_cb_t *nal, __u64 cookie) 
+lib_lookup_cookie (nal_cb_t *nal, __u64 cookie, int type
 {
         /* ALWAYS called with statelock held */
         lib_ni_t            *ni = &nal->ni;
@@ -304,6 +304,9 @@ lib_lookup_cookie (nal_cb_t *nal, __u64 cookie)
         struct list_head    *el;
         unsigned int         hash;
 
+        if ((cookie & (PTL_COOKIE_TYPES - 1)) != type)
+                return (NULL);
+        
         hash = ((unsigned int)cookie) % ni->ni_lh_hash_size;
         list = &ni->ni_lh_hash_table[hash];
         
@@ -318,13 +321,16 @@ lib_lookup_cookie (nal_cb_t *nal, __u64 cookie)
 }
 
 void
-lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh) 
+lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh, int type
 {
         /* ALWAYS called with statelock held */
         lib_ni_t       *ni = &nal->ni;
         unsigned int    hash;
+
+        LASSERT (type >= 0 && type < PTL_COOKIE_TYPES);
+        lh->lh_cookie = ni->ni_next_object_cookie | type;
+        ni->ni_next_object_cookie += PTL_COOKIE_TYPES;
         
-        lh->lh_cookie = ni->ni_next_object_cookie++;
         hash = ((unsigned int)lh->lh_cookie) % ni->ni_lh_hash_size;
         list_add (&lh->lh_hash_chain, &ni->ni_lh_hash_table[hash]);
 }
index 2ca200b..a79e2be 100644 (file)
@@ -197,7 +197,7 @@ static int lib_md_build(nal_cb_t *nal, lib_md_t *new, void *private,
                 eq->eq_refcount++;
 
         /* It's good; let handle2md succeed and add to active mds */
-        lib_initialise_handle (nal, &new->md_lh);
+        lib_initialise_handle (nal, &new->md_lh, PTL_COOKIE_TYPE_MD);
         list_add (&new->md_list, &nal->ni.ni_active_mds);
 
         return PTL_OK;
index 5a80e0a..bd1af5b 100644 (file)
@@ -63,7 +63,7 @@ int do_PtlMEAttach(nal_cb_t * nal, void *private, void *v_args, void *v_ret)
         me->unlink = args->unlink_in;
         me->md = NULL;
 
-        lib_initialise_handle (nal, &me->me_lh);
+        lib_initialise_handle (nal, &me->me_lh, PTL_COOKIE_TYPE_ME);
 
         if (args->position_in == PTL_INS_AFTER)
                 list_add_tail(&me->me_list, &(tbl->tbl[args->index_in]));
@@ -107,7 +107,7 @@ int do_PtlMEInsert(nal_cb_t * nal, void *private, void *v_args, void *v_ret)
         new->unlink = args->unlink_in;
         new->md = NULL;
 
-        lib_initialise_handle (nal, &new->me_lh);
+        lib_initialise_handle (nal, &new->me_lh, PTL_COOKIE_TYPE_ME);
 
         if (args->position_in == PTL_INS_AFTER)
                 list_add_tail(&new->me_list, &me->me_list);
index ce916ac..2ee86b2 100644 (file)
@@ -13,7 +13,7 @@ AM_INIT_AUTOMAKE(portals, builtin([esyscmd], [sed -ne '/.*define IVERSION /{ s/.
 
 sinclude(build.m4)
 sinclude(archdep.m4)
-sinclude<portalsconf.m4)
+sinclude(portalsconf.m4)
 
 if test x$enable_inkernel = xyes ; then
 cp Kernelenv.mk Kernelenv.in
index ec3393b..b70e128 100644 (file)
@@ -264,8 +264,8 @@ lib_msg_free(nal_cb_t *nal, lib_msg_t *msg)
 }
 #endif
 
-extern lib_handle_t *lib_lookup_cookie (nal_cb_t *nal, __u64 cookie);
-extern void lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh);
+extern lib_handle_t *lib_lookup_cookie (nal_cb_t *nal, __u64 cookie, int type);
+extern void lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh, int type);
 extern void lib_invalidate_handle (nal_cb_t *nal, lib_handle_t *lh);
 
 static inline void
@@ -278,8 +278,8 @@ static inline lib_eq_t *
 ptl_handle2eq (ptl_handle_eq_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie
+                                              PTL_COOKIE_TYPE_EQ);
         if (lh == NULL)
                 return (NULL);
 
@@ -296,8 +296,8 @@ static inline lib_md_t *
 ptl_handle2md (ptl_handle_md_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie,
+                                              PTL_COOKIE_TYPE_MD);
         if (lh == NULL)
                 return (NULL);
 
@@ -313,7 +313,8 @@ ptl_wire_handle2md (ptl_handle_wire_t *wh, nal_cb_t *nal)
         if (wh->wh_interface_cookie != nal->ni.ni_interface_cookie)
                 return (NULL);
         
-        lh = lib_lookup_cookie (nal, wh->wh_object_cookie);
+        lh = lib_lookup_cookie (nal, wh->wh_object_cookie,
+                                PTL_COOKIE_TYPE_MD);
         if (lh == NULL)
                 return (NULL);
 
@@ -330,8 +331,8 @@ static inline lib_me_t *
 ptl_handle2me (ptl_handle_me_t *handle, nal_cb_t *nal)
 {
         /* ALWAYS called with statelock held */
-        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie);
-        
+        lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie,
+                                              PTL_COOKIE_TYPE_ME);
         if (lh == NULL)
                 return (NULL);
 
index 08ea118..bece0a3 100644 (file)
@@ -241,6 +241,13 @@ typedef struct {
         unsigned int      tp_threshold;        /* # failures to simulate */
 } lib_test_peer_t;
 
+#define PTL_COOKIE_TYPE_MD    1
+#define PTL_COOKIE_TYPE_ME    2
+#define PTL_COOKIE_TYPE_EQ    3
+#define PTL_COOKIE_TYPES      4
+/* PTL_COOKIE_TYPES must be a power of 2, so the cookie type can be
+ * extracted by masking with (PTL_COOKIE_TYPES - 1) */
+
 typedef struct {
         int up;
         int refcnt;
index 6759b96..3eb4dd5 100644 (file)
@@ -13,4 +13,5 @@ EXTRA_PROGRAMS = kqswnal
 #CFLAGS:= @KCFLAGS@ 
 #CPPFLAGS:=@KCPPFLAGS@
 DEFS =
+CPPFLAGS=@CPPFLAGS@ @with_quadrics@
 kqswnal_SOURCES = qswnal.c qswnal_cb.c qswnal.h
index 1957822..b2e069e 100644 (file)
 
 #include <portals/api-support.h>
 
-#define MAX_NIS 8
+/* Put some magic in the NI handle so uninitialised/zeroed handles are easy
+ * to spot */
+#define NI_HANDLE_MAGIC  0xebc0de00
+#define NI_HANDLE_MASK   0x000000ff
+#define MAX_NIS          8         
 static nal_t *ptl_interfaces[MAX_NIS];
 int ptl_num_interfaces = 0;
 
@@ -37,7 +41,11 @@ nal_t *ptl_hndl2nal(ptl_handle_any_t *handle)
          * setup/teardown.  That ensures her NI handle can't get
          * invalidated out from under her (or worse, swapped for a
          * completely different interface!) */
-        
+
+        if (((idx ^ NI_HANDLE_MAGIC) & ~NI_HANDLE_MASK) != 0)
+                return NULL;
+
+        idx &= NI_HANDLE_MASK;
         if (idx < MAX_NIS)
                 return ptl_interfaces[idx];
 
@@ -48,6 +56,8 @@ int ptl_ni_init(void)
 {
         int i;
 
+        LASSERT (MAX_NIS <= (NI_HANDLE_MASK + 1));
+        
         for (i = 0; i < MAX_NIS; i++)
                 ptl_interfaces[i] = NULL;
 
@@ -114,7 +124,7 @@ int PtlNIInit(ptl_interface_t interface, ptl_pt_index_t ptl_size,
         for (i = 0; i < ptl_num_interfaces; i++) {
                 if (ptl_interfaces[i] == nal) {
                         nal->refct++;
-                        handle->nal_idx = i;
+                        handle->nal_idx = (NI_HANDLE_MAGIC & ~NI_HANDLE_MASK) | i;
                         fprintf(stderr, "Returning existing NAL (%d)\n", i);
                         ptl_ni_init_mutex_exit ();
                         return PTL_OK;
@@ -122,7 +132,6 @@ int PtlNIInit(ptl_interface_t interface, ptl_pt_index_t ptl_size,
         }
         nal->refct = 1;
 
-        handle->nal_idx = ptl_num_interfaces;
         if (ptl_num_interfaces >= MAX_NIS) {
                 if (nal->shutdown)
                         nal->shutdown (nal, ptl_num_interfaces);
@@ -130,6 +139,7 @@ int PtlNIInit(ptl_interface_t interface, ptl_pt_index_t ptl_size,
                 return PTL_NOSPACE;
         }
 
+        handle->nal_idx = (NI_HANDLE_MAGIC & ~NI_HANDLE_MASK) | ptl_num_interfaces;
         ptl_interfaces[ptl_num_interfaces++] = nal;
 
         ptl_eq_ni_init(nal);
@@ -143,6 +153,7 @@ int PtlNIInit(ptl_interface_t interface, ptl_pt_index_t ptl_size,
 int PtlNIFini(ptl_handle_ni_t ni)
 {
         nal_t *nal;
+        int idx;
         int rc;
 
         if (!ptl_init)
@@ -156,6 +167,8 @@ int PtlNIFini(ptl_handle_ni_t ni)
                 return PTL_INV_HANDLE;
         }
 
+        idx = ni.nal_idx & NI_HANDLE_MASK;
+
         nal->refct--;
         if (nal->refct > 0) {
                 ptl_ni_init_mutex_exit ();
@@ -167,9 +180,9 @@ int PtlNIFini(ptl_handle_ni_t ni)
 
         rc = PTL_OK;
         if (nal->shutdown)
-                rc = nal->shutdown(nal, ni.nal_idx);
+                rc = nal->shutdown(nal, idx);
 
-        ptl_interfaces[ni.nal_idx] = NULL;
+        ptl_interfaces[idx] = NULL;
         ptl_num_interfaces--;
 
         ptl_ni_init_mutex_exit ();
index 6238895..ce343c1 100644 (file)
@@ -76,7 +76,7 @@ int do_PtlEQAlloc_internal(nal_cb_t * nal, void *private, void *v_args,
         eq->eq_refcount = 0;
         eq->event_callback = args->callback_in;
 
-        lib_initialise_handle (nal, &eq->eq_lh);
+        lib_initialise_handle (nal, &eq->eq_lh, PTL_COOKIE_TYPE_EQ);
         list_add (&eq->eq_list, &nal->ni.ni_active_eqs);
 
         state_unlock(nal, &flags);
index 2df4120..d6315c6 100644 (file)
@@ -278,7 +278,7 @@ lib_setup_handle_hash (nal_cb_t *nal)
         for (i = 0; i < ni->ni_lh_hash_size; i++)
                 INIT_LIST_HEAD (&ni->ni_lh_hash_table[i]);
 
-        ni->ni_next_object_cookie = 0;
+        ni->ni_next_object_cookie = PTL_COOKIE_TYPES;
         
         return (PTL_OK);
 }
@@ -296,7 +296,7 @@ lib_cleanup_handle_hash (nal_cb_t *nal)
 }
 
 lib_handle_t *
-lib_lookup_cookie (nal_cb_t *nal, __u64 cookie) 
+lib_lookup_cookie (nal_cb_t *nal, __u64 cookie, int type
 {
         /* ALWAYS called with statelock held */
         lib_ni_t            *ni = &nal->ni;
@@ -304,6 +304,9 @@ lib_lookup_cookie (nal_cb_t *nal, __u64 cookie)
         struct list_head    *el;
         unsigned int         hash;
 
+        if ((cookie & (PTL_COOKIE_TYPES - 1)) != type)
+                return (NULL);
+        
         hash = ((unsigned int)cookie) % ni->ni_lh_hash_size;
         list = &ni->ni_lh_hash_table[hash];
         
@@ -318,13 +321,16 @@ lib_lookup_cookie (nal_cb_t *nal, __u64 cookie)
 }
 
 void
-lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh) 
+lib_initialise_handle (nal_cb_t *nal, lib_handle_t *lh, int type
 {
         /* ALWAYS called with statelock held */
         lib_ni_t       *ni = &nal->ni;
         unsigned int    hash;
+
+        LASSERT (type >= 0 && type < PTL_COOKIE_TYPES);
+        lh->lh_cookie = ni->ni_next_object_cookie | type;
+        ni->ni_next_object_cookie += PTL_COOKIE_TYPES;
         
-        lh->lh_cookie = ni->ni_next_object_cookie++;
         hash = ((unsigned int)lh->lh_cookie) % ni->ni_lh_hash_size;
         list_add (&lh->lh_hash_chain, &ni->ni_lh_hash_table[hash]);
 }
index 2ca200b..a79e2be 100644 (file)
@@ -197,7 +197,7 @@ static int lib_md_build(nal_cb_t *nal, lib_md_t *new, void *private,
                 eq->eq_refcount++;
 
         /* It's good; let handle2md succeed and add to active mds */
-        lib_initialise_handle (nal, &new->md_lh);
+        lib_initialise_handle (nal, &new->md_lh, PTL_COOKIE_TYPE_MD);
         list_add (&new->md_list, &nal->ni.ni_active_mds);
 
         return PTL_OK;
index 5a80e0a..bd1af5b 100644 (file)
@@ -63,7 +63,7 @@ int do_PtlMEAttach(nal_cb_t * nal, void *private, void *v_args, void *v_ret)
         me->unlink = args->unlink_in;
         me->md = NULL;
 
-        lib_initialise_handle (nal, &me->me_lh);
+        lib_initialise_handle (nal, &me->me_lh, PTL_COOKIE_TYPE_ME);
 
         if (args->position_in == PTL_INS_AFTER)
                 list_add_tail(&me->me_list, &(tbl->tbl[args->index_in]));
@@ -107,7 +107,7 @@ int do_PtlMEInsert(nal_cb_t * nal, void *private, void *v_args, void *v_ret)
         new->unlink = args->unlink_in;
         new->md = NULL;
 
-        lib_initialise_handle (nal, &new->me_lh);
+        lib_initialise_handle (nal, &new->me_lh, PTL_COOKIE_TYPE_ME);
 
         if (args->position_in == PTL_INS_AFTER)
                 list_add_tail(&new->me_list, &me->me_list);