Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* merge b_recovery into HEAD
[fs/lustre-release.git]
/
lustre
/
ptlrpc
/
pack_generic.c
diff --git
a/lustre/ptlrpc/pack_generic.c
b/lustre/ptlrpc/pack_generic.c
index
3b377bc
..
49d79dc
100644
(file)
--- a/
lustre/ptlrpc/pack_generic.c
+++ b/
lustre/ptlrpc/pack_generic.c
@@
-22,10
+22,9
@@
*
*/
*
*/
-#define EXPORT_SYMTAB
-
-#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,
#include <linux/lustre_net.h>
int lustre_pack_msg(int count, int *lens, char **bufs, int *len,
@@
-38,7
+37,7
@@
int lustre_pack_msg(int count, int *lens, char **bufs, int *len,
for (i = 0; i < count; i++)
size += size_round(lens[i]);
for (i = 0; i < count; i++)
size += size_round(lens[i]);
- *len = size
of(*m) + count * sizeof(__u32
) + size;
+ *len = size
_round(sizeof(*m) + count * sizeof(__u32)
) + size;
OBD_ALLOC(*msg, *len);
if (!*msg)
OBD_ALLOC(*msg, *len);
if (!*msg)
@@
-49,7
+48,7
@@
int lustre_pack_msg(int count, int *lens, char **bufs, int *len,
for (i = 0; i < count; i++)
m->buflens[i] = HTON__u32(lens[i]);
for (i = 0; i < count; i++)
m->buflens[i] = HTON__u32(lens[i]);
- ptr = (char *)m + size
of(*m) + sizeof(__u32) * count
;
+ ptr = (char *)m + size
_round(sizeof(*m) + count * sizeof(__u32))
;
for (i = 0; i < count; i++) {
char *tmp = NULL;
if (bufs)
for (i = 0; i < count; i++) {
char *tmp = NULL;
if (bufs)
@@
-64,12
+63,12
@@
int lustre_pack_msg(int count, int *lens, char **bufs, int *len,
* with the given sub-buffer lengths. */
int lustre_msg_size(int count, int *lengths)
{
* with the given sub-buffer lengths. */
int lustre_msg_size(int count, int *lengths)
{
- int size =
sizeof(struct lustre_msg)
, i;
+ int size =
0
, i;
for (i = 0; i < count; i++)
size += size_round(lengths[i]);
for (i = 0; i < count; i++)
size += size_round(lengths[i]);
- size +=
count * sizeof(__u32
);
+ size +=
size_round(sizeof(struct lustre_msg) + count * sizeof(__u32)
);
return size;
}
return size;
}
@@
-77,21
+76,20
@@
int lustre_msg_size(int count, int *lengths)
int lustre_unpack_msg(struct lustre_msg *m, int len)
{
int required_len, i;
int lustre_unpack_msg(struct lustre_msg *m, int len)
{
int required_len, i;
+ ENTRY;
- required_len = size
of(*m
);
+ required_len = size
_round(sizeof(*m)
);
if (len < required_len)
RETURN(-EINVAL);
m->opc = NTOH__u32(m->opc);
if (len < required_len)
RETURN(-EINVAL);
m->opc = NTOH__u32(m->opc);
- m->xid = NTOH__u32(m->xid);
m->status = NTOH__u32(m->status);
m->type = NTOH__u32(m->type);
m->status = NTOH__u32(m->status);
m->type = NTOH__u32(m->type);
- m->connid = NTOH__u32(m->connid);
m->bufcount = NTOH__u32(m->bufcount);
m->bufcount = NTOH__u32(m->bufcount);
- m->last_
rcvd = NTOH__u64(m->last_rcv
d);
+ m->last_
xid = NTOH__u64(m->last_xi
d);
m->last_committed = NTOH__u64(m->last_committed);
m->last_committed = NTOH__u64(m->last_committed);
- required_len
+= m->bufcount * sizeof(__u32
);
+ required_len
= size_round(sizeof(*m) + m->bufcount * sizeof(__u32)
);
if (len < required_len)
RETURN(-EINVAL);
if (len < required_len)
RETURN(-EINVAL);
@@
-112,16
+110,26
@@
void *lustre_msg_buf(struct lustre_msg *m, int n)
{
int i, offset;
{
int i, offset;
+ if (!m) {
+ CERROR("no message buffer!\n");
+ LBUG();
+ return NULL;
+ }
+
if (n < 0 || n >= m->bufcount) {
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;
}
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;
return NULL;
+ }
- offset = size
of(*m) + m->bufcount * sizeof(__u32
);
+ offset = size
_round(sizeof(*m) + m->bufcount * sizeof(__u32)
);
for (i = 0; i < n; i++)
offset += size_round(m->buflens[i]);
for (i = 0; i < n; i++)
offset += size_round(m->buflens[i]);