#ifdef OPS
#warning "*** WARNING redefining OPS"
#else
-#define OPS(sb,op) ((struct obdfs_sb_info *)(& ## sb ## ->u.generic_sbp))->osi_ops->o_ ## op
-#define IOPS(inode,op) ((struct obdfs_sb_info *)(& ## inode->i_sb ## ->u.generic_sbp))->osi_ops->o_ ## op
+#define OPS(sb,op) ((struct obdfs_sb_info *)(& (sb)->u.generic_sbp))->osi_ops->o_ ## op
+#define IOPS(inode,op) ((struct obdfs_sb_info *)(&(inode)->i_sb->u.generic_sbp))->osi_ops->o_ ## op
#endif
#ifdef ID
#warning "*** WARNING redefining ID"
#else
-#define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
-#define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
+#define ID(sb) (&((struct obdfs_sb_info *)( &(sb)->u.generic_sbp))->osi_conn)
+#define IID(inode) (&((struct obdfs_sb_info *)( &(inode)->i_sb->u.generic_sbp))->osi_conn)
#endif
#define OBDFS_SUPER_MAGIC 0x4711
# This code is issued under the GNU General Public License.
# See the file COPYING in this distribution
+DEFS=
+
MODULE = mds
modulefs_DATA = mds.o
EXTRA_PROGRAMS = mds
# This code is issued under the GNU General Public License.
# See the file COPYING in this distribution
+DEFS=
+
MODULE = obdfs
modulefs_DATA = obdfs.o
EXTRA_PROGRAMS = obdfs
#include <linux/lustre_lib.h>
#include <linux/lustre_idl.h>
-extern int ost_queue_req(struct obd_device *obddev, struct ost_request *);
+extern int ost_queue_req(struct obd_device *, struct ost_request *);
-
-
-int osc_getattr(struct obd_conn *conn, struct obdo *oa)
+struct ost_request *osc_prep_req(int size, int opcode)
{
- struct obd_device *obddev = conn->oc_dev;
struct ost_request *request;
- int rc;
+ int rc;
+ ENTRY;
- request = (struct ost_request *)kmalloc(sizeof(*request),
- GFP_KERNEL);
+ request = (struct ost_request *)kmalloc(sizeof(*request), GFP_KERNEL);
if (!request) {
printk("osc_getattr: request allocation out of memory\n");
- return -ENOMEM;
+ return NULL;
}
rc = ost_pack_req(NULL, 0, NULL, 0,
&request->rq_reqlen, &request->rq_reqbuf);
if (rc) {
printk("llight request: cannot pack request %d\n", rc);
- return rc;
+ return NULL;
+ }
+ request->rq_reqhdr->opc = opcode;
+
+ EXIT;
+ return request;
+}
+
+extern int osc_queue_wait(struct obd_conn *conn, struct ost_request *req)
+{
+ struct obd_device *client = conn->oc_dev;
+ struct obd_device *target = client->u.osc.osc_tgt;
+ int rc;
+
+ ENTRY;
+ /* set the connection id */
+ req->rq_req->connid = conn->oc_id;
+
+ CDEBUG(D_INODE, "tgt at %p, conn id %d, opcode %d request at: %p\n",
+ &conn->oc_dev->u.osc.osc_tgt->u.ost,
+ conn->oc_id, req->rq_reqhdr->opc, req);
+
+ /* XXX fix the race here (wait_for_event?)*/
+ /* hand the packet over to the server */
+ rc = ost_queue_req(target, req);
+ if (rc) {
+ printk("osc_queue_wait: error %d, opcode %d\n", rc,
+ req->rq_reqhdr->opc);
+ return -rc;
+ }
+
+ /* wait for the reply */
+ init_waitqueue_head(&req->rq_wait_for_rep);
+ interruptible_sleep_on(&req->rq_wait_for_rep);
+
+ ost_unpack_rep(req->rq_repbuf, req->rq_replen, &req->rq_rephdr,
+ &req->rq_rep);
+ printk("-->osc_queue_wait: buf %p len %d status %d\n",
+ req->rq_repbuf, req->rq_replen, req->rq_rephdr->status);
+
+ EXIT;
+ return req->rq_rephdr->status;
+}
+
+void osc_free_req(struct ost_request *request)
+{
+ if (request->rq_repbuf)
+ kfree(request->rq_repbuf);
+ kfree(request);
+}
+
+
+int osc_connect(struct obd_conn *conn)
+{
+ struct ost_request *request;
+ int rc;
+ ENTRY;
+
+ request = osc_prep_req(sizeof(*request), OST_CONNECT);
+ if (!request) {
+ printk("osc_connect: cannot pack req!\n");
+ return -ENOMEM;
+ }
+
+ rc = osc_queue_wait(conn, request);
+ if (rc) {
+ EXIT;
+ goto out;
+ }
+
+ CDEBUG(D_INODE, "received connid %d\n", request->rq_rep->connid);
+
+ conn->oc_id = request->rq_rep->connid;
+ out:
+ osc_free_req(request);
+ EXIT;
+ return rc;
+}
+
+int osc_getattr(struct obd_conn *conn, struct obdo *oa)
+{
+ struct ost_request *request;
+ int rc;
+
+ request = osc_prep_req(sizeof(*request), OST_GETATTR);
+ if (!request) {
+ printk("osc_connect: cannot pack req!\n");
+ return -ENOMEM;
}
memcpy(&request->rq_req->oa, oa, sizeof(*oa));
- request->rq_reqhdr->opc = OST_GETATTR;
+ request->rq_req->oa.o_valid = ~0;
- printk("osc_getattr ost tgt at %p\n", &obddev->u.osc.osc_tgt->u.ost);
- rc = ost_queue_req(obddev->u.osc.osc_tgt, request);
+ rc = osc_queue_wait(conn, request);
if (rc) {
- printk("ost_gettatr: error in handling %d\n", rc);
- return rc;
+ EXIT;
+ goto out;
}
- printk("mode: %o\n", request->rq_rep->oa.o_mode);
+ CDEBUG(D_INODE, "mode: %o\n", request->rq_rep->oa.o_mode);
if (oa) {
memcpy(oa, &request->rq_rep->oa, sizeof(*oa));
}
- kfree(request->rq_repbuf);
- kfree(request);
+
+ out:
+ osc_free_req(request);
return 0;
}
return 0;
}
+
static int osc_cleanup(struct obd_device * obddev)
{
ENTRY;
struct obd_ops osc_obd_ops = {
o_setup: osc_setup,
o_cleanup: osc_cleanup,
- o_getattr: osc_getattr
+ o_getattr: osc_getattr,
+ o_connect: osc_connect
};
static int __init osc_init(void)
struct ost_request *srv_req;
struct ost_obd *ost = &obddev->u.ost;
- printk("---> OST at %d %p\n", __LINE__, ost);
if (!ost) {
EXIT;
return -1;
EXIT;
return -ENOMEM;
}
- memcpy(srv_req, req, sizeof(*req));
- srv_req->rq_reply_handle = req;
+
+ printk("---> OST at %d %p, incoming req %p, srv_req %p\n",
+ __LINE__, ost, req, srv_req);
+
+ memset(srv_req, 0, sizeof(*req));
+ srv_req->rq_reqbuf = req->rq_reqbuf;
+ srv_req->rq_reqlen = req->rq_reqlen;
srv_req->rq_obd = ost;
- list_add(&srv_req->rq_list, &ost->ost_reqs);
+ srv_req->rq_reply_handle = req;
+ list_add(&srv_req->rq_list, &ost->ost_reqs);
wake_up(&ost->ost_waitq);
return 0;
}
struct ost_request *clnt_req = req->rq_reply_handle;
ENTRY;
+ printk("ost_reply: req %p clnt_req at %p\n", req, clnt_req);
/* free the request buffer */
kfree(req->rq_reqbuf);
/* move the reply to the client */
clnt_req->rq_replen = req->rq_replen;
clnt_req->rq_repbuf = req->rq_repbuf;
+
+ printk("---> client req %p repbuf %p len %d status %d\n",
+ clnt_req, clnt_req->rq_repbuf, clnt_req->rq_replen,
+ req->rq_rephdr->status);
+
req->rq_repbuf = NULL;
req->rq_replen = 0;
int rc;
ENTRY;
+ printk("ost getattr entered\n");
conn.oc_id = req->rq_req->connid;
conn.oc_dev = ost->ost_tgt;
return rc;
}
req->rq_rep->oa.o_id = req->rq_req->oa.o_id;
+ req->rq_rep->oa.o_valid = req->rq_req->oa.o_valid;
req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_getattr
(&conn, &req->rq_rep->oa);
}
req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_connect(&conn);
- req->rq_rep->connid = conn.oc_id;
+ printk("ost_connect: rep buffer %p, id %d\n", req->rq_repbuf,
+ conn.oc_id);
+ req->rq_rep->connid = conn.oc_id;
EXIT;
return 0;
}
struct ost_req_hdr *hdr;
ENTRY;
+ printk("ost_handle: req at %p\n", req);
hdr = (struct ost_req_hdr *)req->rq_reqbuf;
-
if (NTOH__u32(hdr->type) != OST_TYPE_REQ) {
printk("lustre_ost: wrong packet type sent %d\n",
NTOH__u32(hdr->type));
case OST_CONNECT:
CDEBUG(D_INODE, "connect\n");
+ printk("----> connect \n");
rc = ost_connect(ost, req);
break;
case OST_DISCONNECT:
}
out:
+ req->rq_rephdr->status = rc;
if (rc) {
printk("ost: processing error %d\n", rc);
ost_error(obddev, req);
}
tgt = &obd_dev[data->ioc_dev];
-
+ ost->ost_tgt = tgt;
if ( ! (tgt->obd_flags & OBD_ATTACHED) ||
! (tgt->obd_flags & OBD_SET_UP) ){
printk("device not attached or not set up (%d)\n",
return -EINVAL;
}
- printk("---> OST at %d %p\n", __LINE__, ost);
INIT_LIST_HEAD(&ost->ost_reqs);
ost->ost_thread = NULL;
ost->ost_flags = 0;
- printk("---> %d\n", __LINE__);
spin_lock_init(&obddev->u.ost.fo_lock);
- printk("---> %d\n", __LINE__);
ost_start_srv_thread(obddev);
- printk("---> %d\n", __LINE__);
MOD_INC_USE_COUNT;
EXIT;
R=/r
insmod /lib/modules/2.4.17/kernel/drivers/block/loop.o
+insmod $R/usr/src/obd/class/obdclass.o
+insmod $R/usr/src/obd/ext2obd/obdext2.o
+insmod $R/usr/src/obd/ost/ost.o
+insmod $R/usr/src/obd/osc/osc.o
+
dd if=/dev/zero of=/tmp/fs bs=1024 count=10000
mke2fs -F /tmp/fs
losetup /dev/loop/0 /tmp/fs
+echo 4095 > /proc/sys/obd/debug
+echo 4095 > /proc/sys/obd/trace
-insmod $R/usr/src/obd/class/obdclass.o
-insmod $R/usr/src/obd/ext2obd/obdext2.o
-insmod $R/usr/src/obd/ost/ost.o
-insmod $R/usr/src/obd/osc/osc.o
mknod /dev/obd c 10 241
$R/usr/src/obd/utils/obdctl <<EOF
device 1
attach ost
setup 0
+device 2
+attach osc
+setup 1
quit
EOF
int Parser_arg2int(const char *inp, long *result, int base);
-#endif _PARSER_H_
+#endif