Whamcloud - gitweb
Fix small typos in ost/osc
authorbraam <braam>
Fri, 18 Jan 2002 06:01:30 +0000 (06:01 +0000)
committerbraam <braam>
Fri, 18 Jan 2002 06:01:30 +0000 (06:01 +0000)
lustre/include/linux/obdo.h
lustre/lib/obd_pack.c
lustre/mds/Makefile.am
lustre/obdfs/Makefile.am
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/tests/ostreq.sh
lustre/utils/parser.h

index c410354..a111fd5 100644 (file)
@@ -89,15 +89,15 @@ static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
 #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
index 482826a..b0044da 100644 (file)
@@ -205,3 +205,4 @@ int ost_unpack_rep(char *buf, int len,
        EXIT;
        return 0;
 }
+
index 4f1864d..c81056b 100644 (file)
@@ -3,6 +3,8 @@
 # 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
index b154c51..8470dc1 100644 (file)
@@ -3,6 +3,8 @@
 # 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
index 94556fb..e8721f0 100644 (file)
 #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, 
@@ -52,25 +49,112 @@ int osc_getattr(struct obd_conn *conn, struct obdo *oa)
                          &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;
 }
 
@@ -104,6 +188,7 @@ static int osc_setup(struct obd_device *obddev, obd_count len,
         return 0;
 } 
 
+
 static int osc_cleanup(struct obd_device * obddev)
 {
         ENTRY;
@@ -122,7 +207,8 @@ static int osc_cleanup(struct obd_device * obddev)
 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)
index 122e71c..6e87dd0 100644 (file)
@@ -42,7 +42,6 @@ static int ost_queue_req(struct obd_device *obddev, struct ost_request *req)
        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;
@@ -53,11 +52,17 @@ static int ost_queue_req(struct obd_device *obddev, struct ost_request *req)
                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;
 }
@@ -69,6 +74,7 @@ int ost_reply(struct obd_device *obddev, struct ost_request *req)
        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);
@@ -77,6 +83,11 @@ int ost_reply(struct obd_device *obddev, struct ost_request *req)
        /* 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;
        
@@ -140,6 +151,7 @@ static int ost_getattr(struct ost_obd *ost, struct ost_request *req)
        int rc;
 
        ENTRY;
+       printk("ost getattr entered\n"); 
        
        conn.oc_id = req->rq_req->connid;
        conn.oc_dev = ost->ost_tgt;
@@ -151,6 +163,7 @@ static int ost_getattr(struct ost_obd *ost, struct ost_request *req)
                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); 
@@ -229,8 +242,10 @@ static int ost_connect(struct ost_obd *ost, struct ost_request *req)
        }
 
        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;
 }
@@ -296,9 +311,9 @@ int ost_handle(struct obd_device *obddev, struct ost_request *req)
        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));
@@ -318,6 +333,7 @@ int ost_handle(struct obd_device *obddev, struct ost_request *req)
 
        case OST_CONNECT:
                CDEBUG(D_INODE, "connect\n");
+               printk("----> connect \n"); 
                rc = ost_connect(ost, req);
                break;
        case OST_DISCONNECT:
@@ -350,6 +366,7 @@ int ost_handle(struct obd_device *obddev, struct ost_request *req)
        }
 
 out:
+       req->rq_rephdr->status = rc;
        if (rc) { 
                printk("ost: processing error %d\n", rc);
                ost_error(obddev, req);
@@ -475,7 +492,7 @@ static int ost_setup(struct obd_device *obddev, obd_count len,
        }
 
         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", 
@@ -492,17 +509,13 @@ static int ost_setup(struct obd_device *obddev, obd_count len,
                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; 
index 84d0924..634f443 100644 (file)
@@ -3,15 +3,18 @@
 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
@@ -21,6 +24,9 @@ setup /dev/loop/0
 device 1
 attach ost
 setup 0
+device 2
+attach osc
+setup 1
 quit
 EOF
 
index a35ab75..6bb252f 100644 (file)
@@ -52,4 +52,4 @@ char *Parser_strarg(char *inp, const char *prompt, const char *deft,
 int Parser_arg2int(const char *inp, long *result, int base);
 
 
-#endif _PARSER_H_
+#endif