[prev in list] [next in list] [prev in thread] [next in thread]
List: lustre-cvs
Subject: [Lustre-cvs] CVS: obd/lib mds_pack.c,1.2,1.3 obd_pack.c,1.1,1.2
From: "Peter J. Braam" <braam () users ! sourceforge ! net>
Date: 2001-12-30 6:17:17
[Download RAW message or body]
Update of /cvsroot/lustre/obd/lib
In directory usw-pr-cvs1:/tmp/cvs-serv10086/lib
Modified Files:
mds_pack.c obd_pack.c
Log Message:
Most of the code for the OST target.
lib/obd_pack.c - routines for packing/unpacking of OST requests
lib/mds_pack.c - fixes (should be 64bit safe now)
autogen.sh - no more Makefile.in in CVS
tests/testreq.c tests/umreq.sh tests of the RPC infrastructure
Index: mds_pack.c
===================================================================
RCS file: /cvsroot/lustre/obd/lib/mds_pack.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mds_pack.c 2001/12/29 00:20:43 1.2
+++ mds_pack.c 2001/12/30 06:17:15 1.3
@@ -3,22 +3,22 @@
*
* Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
*
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
+ * This file is part of Lustre, http://www.lustre.org.
*
- * InterMezzo is free software; you can redistribute it and/or
+ * Lustre is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
- * InterMezzo is distributed in the hope that it will be useful,
+ * Lustre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
+ * along with Lustre; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * Unpacking of KML records
+ * (Un)packing of MDS and OST request records
*
*/
@@ -48,6 +48,7 @@
#include <linux/obd_support.h>
#include <linux/lustre_lib.h>
#include <linux/lustre_idl.h>
+#include <linux/lustre_mds.h>
int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen,
@@ -55,9 +56,10 @@
int *len, char **buf)
{
char *ptr;
+ struct mds_req_packed *preq;
*len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
- sizeof(**req);
+ sizeof(*preq);
*buf = kmalloc(*len, GFP_KERNEL);
if (!*buf) {
@@ -67,18 +69,21 @@
memset(*buf, 0, *len);
*hdr = (struct mds_req_hdr *)(*buf);
- *req = (struct mds_req *)(*buf + sizeof(**hdr));
- ptr = *buf + sizeof(**hdr) + sizeof(**req);
+ preq = (struct mds_req_packed *)(*buf + sizeof(**hdr));
+ ptr = *buf + sizeof(**hdr) + sizeof(*preq);
+
(*hdr)->type = MDS_TYPE_REQ;
(*req)->namelen = NTOH__u32(namelen);
if (name) {
+ preq->name_offset = (__u32)(ptr - (char *)preq);
LOGL(name, namelen, ptr);
}
(*req)->tgtlen = NTOH__u32(tgtlen);
if (tgt) {
+ preq->tgt_offset = (__u32)(ptr - (char *)preq);
LOGL(tgt, tgtlen, ptr);
}
return 0;
@@ -88,13 +93,21 @@
int mds_unpack_req(char *buf, int len,
struct mds_req_hdr **hdr, struct mds_req **req)
{
+ struct mds_req_packed *preq;
+ __u32 off1, off2;
+ char *name, *tgt;
+
if (len < sizeof(**hdr) + sizeof(**req)) {
EXIT;
return -EINVAL;
}
*hdr = (struct mds_req_hdr *) (buf);
- *req = (struct mds_req *) (buf + sizeof(**hdr));
+ preq = (struct mds_req_packed *) (buf + sizeof(**hdr));
+ off1 = preq->name_offset;
+ off2 = preq->tgt_offset;
+
+ *req = (struct mds_req *) (buf + sizeof(**hdr));
(*req)->namelen = NTOH__u32((*req)->namelen);
(*req)->tgtlen = NTOH__u32((*req)->namelen);
@@ -105,22 +118,106 @@
}
if ((*req)->namelen) {
- (*req)->name = buf + sizeof(**hdr) + sizeof(**req);
+ name = buf + sizeof(**hdr) + off1;
} else {
- (*req)->name = NULL;
+ name = NULL;
}
if ((*req)->tgtlen) {
- (*req)->tgt = buf + sizeof(**hdr) + sizeof(**req) +
- size_round((*req)->namelen);
+ tgt = buf + sizeof(**hdr) + off2;
} else {
- (*req)->tgt = NULL;
+ tgt = NULL;
+ }
+ (*req)->name = name;
+ (*req)->tgt = tgt;
+
+ EXIT;
+ return 0;
+}
+
+int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen,
+ struct mds_rep_hdr **hdr, struct mds_rep **rep,
+ int *len, char **buf)
+{
+ char *ptr;
+ struct mds_rep_packed *prep;
+
+ *len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
+ sizeof(*prep);
+
+ *buf = kmalloc(*len, GFP_KERNEL);
+ if (!*buf) {
+ EXIT;
+ return -ENOMEM;
+ }
+
+ memset(*buf, 0, *len);
+ *hdr = (struct mds_rep_hdr *)(*buf);
+
+ prep = (struct mds_rep_packed *)(*buf + sizeof(**hdr));
+ ptr = *buf + sizeof(**hdr) + sizeof(*prep);
+
+ (*hdr)->type = MDS_TYPE_REP;
+
+ (*rep)->namelen = NTOH__u32(namelen);
+ if (name) {
+ prep->name_offset = (__u32)(ptr - (char *)prep);
+ LOGL(name, namelen, ptr);
+ }
+
+ (*rep)->tgtlen = NTOH__u32(tgtlen);
+ if (tgt) {
+ prep->tgt_offset = (__u32)(ptr - (char *)prep);
+ LOGL(tgt, tgtlen, ptr);
+ }
+ return 0;
+}
+
+
+int mds_unpack_rep(char *buf, int len,
+ struct mds_rep_hdr **hdr, struct mds_rep **rep)
+{
+ struct mds_rep_packed *prep;
+ __u32 off1, off2;
+
+ if (len < sizeof(**hdr) + sizeof(**rep)) {
+ EXIT;
+ return -EINVAL;
+ }
+
+ *hdr = (struct mds_rep_hdr *) (buf);
+ prep = (struct mds_rep_packed *) (buf + sizeof(**hdr));
+ off1 = prep->name_offset;
+ off2 = prep->tgt_offset;
+
+ *rep = (struct mds_rep *) (buf + sizeof(**hdr));
+ (*rep)->namelen = NTOH__u32((*rep)->namelen);
+ (*rep)->tgtlen = NTOH__u32((*rep)->namelen);
+
+ if (len < sizeof(**hdr) + sizeof(**rep) + (*rep)->namelen +
+ (*rep)->tgtlen ) {
+ EXIT;
+ return -EINVAL;
+ }
+
+ if ((*rep)->namelen) {
+ (*rep)->name = buf + sizeof(**hdr) + off1;
+ } else {
+ (*rep)->name = NULL;
+ }
+
+ if ((*rep)->tgtlen) {
+ (*rep)->tgt = buf + sizeof(**hdr) + off2;
+ } else {
+ (*rep)->tgt = NULL;
}
+
EXIT;
return 0;
}
+#if 0
int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen,
struct mds_rep_hdr **hdr, struct mds_rep **rep,
int *len, char **buf)
@@ -189,3 +286,4 @@
EXIT;
return 0;
}
+#endif
Index: obd_pack.c
===================================================================
RCS file: /cvsroot/lustre/obd/lib/obd_pack.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- obd_pack.c 2001/12/29 00:20:43 1.1
+++ obd_pack.c 2001/12/30 06:17:15 1.2
@@ -3,22 +3,22 @@
*
* Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
*
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
+ * This file is part of Lustre, http://www.lustre.org.
*
- * InterMezzo is free software; you can redistribute it and/or
+ * Lustre is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
- * InterMezzo is distributed in the hope that it will be useful,
+ * Lustre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
+ * along with Lustre; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * Unpacking of KML records
+ * (Un)packing of OST requests
*
*/
@@ -46,18 +46,21 @@
#include <asm/uaccess.h>
#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>
-int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen,
- struct mds_req_hdr **hdr, struct mds_req **req,
+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)
{
char *ptr;
+ struct ost_req_packed *preq;
- *len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
- sizeof(**req);
+ *len = sizeof(**hdr) + size_round(buflen1) + size_round(buflen2) +
+ sizeof(*preq);
*buf = kmalloc(*len, GFP_KERNEL);
if (!*buf) {
@@ -66,68 +69,77 @@
}
memset(*buf, 0, *len);
- *hdr = (struct mds_req_hdr *)(*buf);
- *req = (struct mds_req *)(*buf + sizeof(**hdr));
- ptr = *buf + sizeof(**hdr) + sizeof(**req);
-
- (*hdr)->type = MDS_TYPE_REQ;
-
- (*req)->namelen = NTOH__u32(namelen);
- if (name) {
- LOGL(name, namelen, ptr);
+ *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)->tgtlen = NTOH__u32(tgtlen);
- if (tgt) {
- LOGL(tgt, tgtlen, ptr);
+ (*req)->buflen2 = NTOH__u32(buflen2);
+ if (buf2) {
+ preq->bufoffset2 = (__u32)(ptr - (char *)preq);
+ LOGL(buf2, buflen2, ptr);
}
return 0;
}
-
-int mds_unpack_req(char *buf, int len,
- struct mds_req_hdr **hdr, struct mds_req **req)
+int ost_unpack_req(char *buf, int len,
+ struct ost_req_hdr **hdr, struct ost_req **req)
{
- if (len < sizeof(**hdr) + sizeof(**req)) {
+ struct ost_req_packed *reqp;
+ __u32 off1, off2;
+
+ if (len < sizeof(**hdr) + sizeof(*reqp)) {
EXIT;
return -EINVAL;
}
- *hdr = (struct mds_req_hdr *) (buf);
- *req = (struct mds_req *) (buf + sizeof(**hdr));
- (*req)->namelen = NTOH__u32((*req)->namelen);
- (*req)->tgtlen = NTOH__u32((*req)->namelen);
+ *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(**req) + (*req)->namelen +
- (*req)->tgtlen ) {
+ if (len < sizeof(**hdr) + sizeof(*reqp) + size_round(reqp->buflen1) +
+ size_round(reqp->buflen2) ) {
EXIT;
return -EINVAL;
}
- if ((*req)->namelen) {
- (*req)->name = buf + sizeof(**hdr) + sizeof(**req);
+ if ((*req)->buflen1) {
+ (*req)->buf1 = (buf + sizeof(**hdr) + off1);
} else {
- (*req)->name = NULL;
+ (*req)->buf1 = 0;
}
-
- if ((*req)->tgtlen) {
- (*req)->tgt = buf + sizeof(**hdr) + sizeof(**req) +
- size_round((*req)->namelen);
+ if ((*req)->buflen2) {
+ (*req)->buf2 = (buf + sizeof(**hdr) + off2);
} else {
- (*req)->tgt = NULL;
+ (*req)->buf2 = 0;
}
EXIT;
return 0;
}
-int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen,
- struct mds_rep_hdr **hdr, struct mds_rep **rep,
+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)
{
char *ptr;
- *len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
+ *len = sizeof(**hdr) + size_round(buflen1) + size_round(buflen2) +
sizeof(**rep);
*buf = kmalloc(*len, GFP_KERNEL);
@@ -137,53 +149,57 @@
}
memset(*buf, 0, *len);
- *hdr = (struct mds_rep_hdr *)(*buf);
- *rep = (struct mds_rep *)(*buf + sizeof(**hdr));
+ *hdr = (struct ost_rep_hdr *)(*buf);
+ *rep = (struct ost_rep *)(*buf + sizeof(**hdr));
ptr = *buf + sizeof(**hdr) + sizeof(**rep);
- (*rep)->namelen = NTOH__u32(namelen);
- if (name) {
- LOGL(name, namelen, ptr);
+ (*rep)->buflen1 = NTOH__u32(buflen1);
+ if (buf1) {
+ LOGL(buf1, buflen1, ptr);
}
- (*rep)->tgtlen = NTOH__u32(tgtlen);
- if (tgt) {
- LOGL(tgt, tgtlen, ptr);
+ (*rep)->buflen2 = NTOH__u32(buflen2);
+ if (buf2) {
+ LOGL(buf2, buflen2, ptr);
}
return 0;
}
-int mds_unpack_rep(char *buf, int len,
- struct mds_rep_hdr **hdr, struct mds_rep **rep)
+int ost_unpack_rep(char *buf, int len,
+ struct ost_rep_hdr **hdr, struct ost_rep **rep)
{
+ struct ost_rep_packed *prep;
+ __u32 off1, off2;
+
if (len < sizeof(**hdr) + sizeof(**rep)) {
EXIT;
return -EINVAL;
}
- *hdr = (struct mds_rep_hdr *) (buf);
- *rep = (struct mds_rep *) (buf + sizeof(**hdr));
- (*rep)->namelen = NTOH__u32((*rep)->namelen);
- (*rep)->tgtlen = NTOH__u32((*rep)->namelen);
+ *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;
- if (len < sizeof(**hdr) + sizeof(**rep) + (*rep)->namelen +
- (*rep)->tgtlen ) {
+ if (len < sizeof(**hdr) + sizeof(*prep) + size_round((*rep)->buflen1) +
+ size_round((*rep)->buflen2) ) {
EXIT;
return -EINVAL;
}
- if ((*rep)->namelen) {
- (*rep)->name = buf + sizeof(**hdr) + sizeof(**rep);
+ if ((*rep)->buflen1) {
+ (*rep)->buf1 = (buf + sizeof(**hdr) + off1);
} else {
- (*rep)->name = NULL;
+ (*rep)->buf1 = 0;
}
-
- if ((*rep)->tgtlen) {
- (*rep)->tgt = buf + sizeof(**hdr) + sizeof(**rep) +
- size_round((*rep)->namelen);
+ if ((*rep)->buflen2) {
+ (*rep)->buf2 = (buf + sizeof(**hdr) + off2);
} else {
- (*rep)->tgt = NULL;
+ (*rep)->buf2 = 0;
}
EXIT;
_______________________________________________
Lustre-cvs mailing list
Lustre-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lustre-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic