X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flib%2Fobd_pack.c;h=8b3c33a6674fb054235e723f50dafc908467177d;hb=d6520c930baf30f46fd4eda438cc661d0bc90fbb;hp=691ae37da93562bd93566ca13033aac8a26c397a;hpb=dec61de39f0afd578d4687811b84981f8c41a6ae;p=fs%2Flustre-release.git diff --git a/lustre/lib/obd_pack.c b/lustre/lib/obd_pack.c index 691ae37..8b3c33a 100644 --- a/lustre/lib/obd_pack.c +++ b/lustre/lib/obd_pack.c @@ -22,186 +22,59 @@ * */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#define DEBUG_SUBSYSTEM S_OST -#include -#include #include -#include -#include +#include - -int ost_pack_req(char *buf1, int buflen1, char *buf2, int buflen2, - struct ost_req_hdr **hdr, struct ost_req **req, - int *len, char **buf) +void ost_pack_ioo(void **tmp, struct lov_stripe_md *lsm, int bufcnt) { - char *ptr; - struct ost_req_packed *preq; - - *len = sizeof(**hdr) + size_round(buflen1) + size_round(buflen2) + - sizeof(*preq); - - *buf = kmalloc(*len, GFP_KERNEL); - if (!*buf) { - EXIT; - return -ENOMEM; - } - - memset(*buf, 0, *len); - *hdr = (struct ost_req_hdr *)(*buf); - - preq = (struct ost_req_packed *)(*buf + sizeof(**hdr)); - ptr = *buf + sizeof(**hdr) + sizeof(*preq); - *req = (struct ost_req *)(*buf + sizeof(**hdr)); - - (*hdr)->type = OST_TYPE_REQ; - - (*req)->buflen1 = NTOH__u32(buflen1); - if (buf1) { - preq->bufoffset1 = (__u32)(ptr - (char *)preq); - LOGL(buf1, buflen1, ptr); - } - - (*req)->buflen2 = NTOH__u32(buflen2); - if (buf2) { - preq->bufoffset2 = (__u32)(ptr - (char *)preq); - LOGL(buf2, buflen2, ptr); - } - return 0; + struct obd_ioobj *ioo = *tmp; + char *c = *tmp; + + ioo->ioo_id = HTON__u64(lsm->lsm_object_id); + ioo->ioo_gr = HTON__u64(0); + ioo->ioo_type = HTON__u32(S_IFREG); + ioo->ioo_bufcnt = HTON__u32(bufcnt); + *tmp = c + sizeof(*ioo); } -int ost_unpack_req(char *buf, int len, - struct ost_req_hdr **hdr, struct ost_req **req) +void ost_unpack_ioo(void **tmp, struct obd_ioobj **ioop) { - struct ost_req_packed *reqp; - __u32 off1, off2; - - if (len < sizeof(**hdr) + sizeof(*reqp)) { - EXIT; - return -EINVAL; - } - - *hdr = (struct ost_req_hdr *) (buf); - reqp = (struct ost_req_packed *) (buf + sizeof(**hdr)); - *req = (struct ost_req *) (buf + sizeof(**hdr)); - - (*req)->buflen1 = NTOH__u32(reqp->buflen1); - (*req)->buflen2 = NTOH__u32(reqp->buflen2); - off1 = NTOH__u32(reqp->bufoffset1); - off2 = NTOH__u32(reqp->bufoffset2); - - if (len < sizeof(**hdr) + sizeof(*reqp) + size_round(reqp->buflen1) + - size_round(reqp->buflen2) ) { - EXIT; - return -EINVAL; - } - - if ((*req)->buflen1) { - (*req)->buf1 = (buf + sizeof(**hdr) + off1); - } else { - (*req)->buf1 = 0; - } - if ((*req)->buflen2) { - (*req)->buf2 = (buf + sizeof(**hdr) + off2); - } else { - (*req)->buf2 = 0; - } - - EXIT; - return 0; + char *c = *tmp; + struct obd_ioobj *ioo = *tmp; + *ioop = *tmp; + + ioo->ioo_id = NTOH__u64(ioo->ioo_id); + ioo->ioo_gr = NTOH__u64(ioo->ioo_gr); + ioo->ioo_type = NTOH__u32(ioo->ioo_type); + ioo->ioo_bufcnt = NTOH__u32(ioo->ioo_bufcnt); + *tmp = c + sizeof(*ioo); } -int ost_pack_rep(void *buf1, __u32 buflen1, void *buf2, __u32 buflen2, - struct ost_rep_hdr **hdr, struct ost_rep **rep, - int *len, char **buf) +void ost_pack_niobuf(void **tmp, __u64 offset, __u32 len, __u32 flags, + __u32 xid) { - char *ptr; - - *len = sizeof(**hdr) + size_round(buflen1) + size_round(buflen2) + - sizeof(**rep); - - *buf = kmalloc(*len, GFP_KERNEL); - if (!*buf) { - EXIT; - return -ENOMEM; - } - - memset(*buf, 0, *len); - *hdr = (struct ost_rep_hdr *)(*buf); - *rep = (struct ost_rep *)(*buf + sizeof(**hdr)); - ptr = *buf + sizeof(**hdr) + sizeof(**rep); - - (*rep)->buflen1 = NTOH__u32(buflen1); - if (buf1) { - LOGL(buf1, buflen1, ptr); - } - - (*rep)->buflen2 = NTOH__u32(buflen2); - if (buf2) { - LOGL(buf2, buflen2, ptr); - } - return 0; + struct niobuf_remote *nb = *tmp; + char *c = *tmp; + + nb->offset = HTON__u64(offset); + nb->len = HTON__u32(len); + nb->flags = HTON__u32(flags); + nb->xid = HTON__u32(xid); + *tmp = c + sizeof(*nb); } - -int ost_unpack_rep(char *buf, int len, - struct ost_rep_hdr **hdr, struct ost_rep **rep) +void ost_unpack_niobuf(void **tmp, struct niobuf_remote **nbp) { - struct ost_rep_packed *prep; - __u32 off1, off2; - - if (len < sizeof(**hdr) + sizeof(**rep)) { - EXIT; - return -EINVAL; - } + char *c = *tmp; + struct niobuf_remote *nb = *tmp; - *hdr = (struct ost_rep_hdr *) (buf); - *rep = (struct ost_rep *) (buf + sizeof(**hdr)); - prep = (struct ost_rep_packed *) (buf + sizeof(**hdr)); - (*rep)->buflen1 = NTOH__u32(prep->buflen1); - (*rep)->buflen2 = NTOH__u32(prep->buflen2); - off1 = prep->bufoffset1; - off2 = prep->bufoffset2; + *nbp = *tmp; - if (len < sizeof(**hdr) + sizeof(*prep) + size_round((*rep)->buflen1) + - size_round((*rep)->buflen2) ) { - EXIT; - return -EINVAL; - } + nb->offset = NTOH__u64(nb->offset); + nb->len = NTOH__u32(nb->len); + nb->flags = NTOH__u32(nb->flags); - if ((*rep)->buflen1) { - (*rep)->buf1 = (buf + sizeof(**hdr) + off1); - } else { - (*rep)->buf1 = 0; - } - if ((*rep)->buflen2) { - (*rep)->buf2 = (buf + sizeof(**hdr) + off2); - } else { - (*rep)->buf2 = 0; - } - - EXIT; - return 0; + *tmp = c + sizeof(*nb); } -