Whamcloud - gitweb
land b_md onto HEAD:
[fs/lustre-release.git] / lustre / ptlrpc / pack_generic.c
index 87f5e04..49d79dc 100644 (file)
@@ -22,8 +22,9 @@
  *
  */
 
-#define DEBUG_SUBSYSTEM S_CLASS
+#define DEBUG_SUBSYSTEM S_RPC
 
+#include <linux/obd_support.h>
 #include <linux/lustre_net.h>
 
 int lustre_pack_msg(int count, int *lens, char **bufs, int *len,
@@ -75,6 +76,7 @@ int lustre_msg_size(int count, int *lengths)
 int lustre_unpack_msg(struct lustre_msg *m, int len)
 {
         int required_len, i;
+        ENTRY;
 
         required_len = size_round(sizeof(*m));
         if (len < required_len)
@@ -84,9 +86,8 @@ int lustre_unpack_msg(struct lustre_msg *m, int len)
         m->status = NTOH__u32(m->status);
         m->type = NTOH__u32(m->type);
         m->bufcount = NTOH__u32(m->bufcount);
-        m->last_rcvd = NTOH__u64(m->last_rcvd);
+        m->last_xid = NTOH__u64(m->last_xid);
         m->last_committed = NTOH__u64(m->last_committed);
-        m->target_id = NTOH__u32(m->target_id);
 
         required_len = size_round(sizeof(*m) + m->bufcount * sizeof(__u32));
         if (len < required_len)
@@ -109,14 +110,24 @@ void *lustre_msg_buf(struct lustre_msg *m, int n)
 {
         int i, offset;
 
+        if (!m) {
+                CERROR("no message buffer!\n");
+                LBUG();
+                return NULL;
+        }
+
         if (n < 0 || n >= m->bufcount) {
-                CERROR("referencing bad sub buffer!\n");
+                CERROR("referencing bad sub buffer in %p (want %d, count %d)!\n",
+                       m, n, m->bufcount);
                 LBUG();
                 return NULL;
         }
 
-        if (m->buflens[n] == 0)
+        if (m->buflens[n] == 0) {
+                CERROR("zero-length buffer requested for buffer %d in %p\n", n,
+                       m);
                 return NULL;
+        }
 
         offset = size_round(sizeof(*m) + m->bufcount * sizeof(__u32));