*
*/
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/sched.h>
-#include <linux/lp.h>
-#include <linux/slab.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/skbuff.h>
-#include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
-#include <linux/fs.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/list.h>
-#include <asm/io.h>
-#include <asm/segment.h>
-#include <asm/system.h>
-#include <asm/poll.h>
-#include <asm/uaccess.h>
+#define DEBUG_SUBSYSTEM S_OST
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
#include <linux/obd_ost.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
+#include <linux/lustre_net.h>
-
-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 obdo *oa, 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(oa->o_id);
+ ioo->ioo_gr = HTON__u64(oa->o_gr);
+ ioo->ioo_type = HTON__u32(oa->o_mode);
+ 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;
- }
-
- *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;
+ char *c = *tmp;
+ struct niobuf_remote *nb = *tmp;
- if (len < sizeof(**hdr) + sizeof(*prep) + size_round((*rep)->buflen1) +
- size_round((*rep)->buflen2) ) {
- EXIT;
- return -EINVAL;
- }
+ *nbp = *tmp;
- 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;
- }
+ nb->offset = NTOH__u64(nb->offset);
+ nb->len = NTOH__u32(nb->len);
+ nb->flags = NTOH__u32(nb->flags);
- EXIT;
- return 0;
+ *tmp = c + sizeof(*nb);
}