Whamcloud - gitweb
Small bug fixes. OSC/OST almost working.
authorbraam <braam>
Thu, 3 Jan 2002 17:10:42 +0000 (17:10 +0000)
committerbraam <braam>
Thu, 3 Jan 2002 17:10:42 +0000 (17:10 +0000)
13 files changed:
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/obd_class.h
lustre/llite/request.c
lustre/mds/handler.c
lustre/obdclass/class_obd.c
lustre/obdfs/super.c
lustre/osc/Makefile.am [new file with mode: 0644]
lustre/osc/osc_request.c [new file with mode: 0644]
lustre/ost/ost_handler.c
lustre/tests/fs.sh
lustre/utils/Makefile.am
lustre/utils/obdctl.c

index c0dc843..0a26b20 100644 (file)
 
 
 /* opcodes */
+#define OST_GET_INFO  6
+#define OST_CONNECT  7
+#define OST_DISCONNECT 8
 #define OST_GETATTR  1
 #define OST_SETATTR  2
 #define OST_BRW      3
 #define OST_CREATE   4
 #define OST_DESTROY  5
-#define OST_GETINFO  6
 
 /* packet types */
 #define OST_TYPE_REQ 1
@@ -152,6 +154,7 @@ struct ost_req_packed {
 
 struct ost_rep_packed {
        __u32   result;
+       __u32   connid;
        struct obdo oa;
        __u32   buflen1;
        __u32   buflen2;
@@ -159,6 +162,21 @@ struct ost_rep_packed {
        __u32   bufoffset2;
 };
 
+struct obd_buf { 
+        __u64 addr;       // address 
+        __u64 handle;     // DMA handle
+        __u64 matchbits;  // portals match bits
+        __u32 offset;     // first bit after addr that is relevant
+        __u32 size;       // size from addr + offset that needs moving
+};
+
+struct obd_bufref { 
+        obd_id    obj_id;
+        obd_gr    obj_gr;
+        __u64     offset;
+        __u32     size; 
+        __u32     flags;
+}; 
 
 /* reply structure for OST's */
 
index 0e706d0..999e00a 100644 (file)
@@ -84,7 +84,8 @@ struct mds_request {
        struct mds_rep_hdr *rq_rephdr;
        struct mds_rep *rq_rep;
 
-       wait_queue_head_t rq_wait_for_mds_rep;
+        void * rq_reply_handle;
+       wait_queue_head_t rq_wait_for_rep;
 };
 
 
index 205adfd..d7b3a10 100644 (file)
 #include <linux/obd.h>
 #endif
 
-
-
-
-
-
 /*
  *  ======== OBD Device Declarations ===========
  */
-
-
-#define OBD_PSDEV_MAJOR 186
 #define MAX_OBD_DEVICES 8
 #define MAX_MULTI       16
-
-
 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
 
-
 #define OBD_ATTACHED 0x1
 #define OBD_SET_UP   0x2
 
@@ -50,9 +39,6 @@ struct obd_conn {
         uint32_t oc_id;
 };
 
-
-
-
 typedef struct {
        uint32_t len;
        char *   name;
@@ -91,6 +77,7 @@ struct obd_device {
                 struct snap_obd snap;
                struct trace_obd trace;
                 struct ost_obd ost;
+                struct osc_obd osc;
         } u;
 };
 
@@ -144,6 +131,12 @@ struct obd_ops {
                       obd_size count, obd_off offset);
         int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
                          obd_id *startid, obd_gr group, void *data);
+       int (*o_dmaread)(struct obd_conn *conn, int count, struct obd_buf **dest, 
+                        struct obd_bufref **source); 
+       int (*o_pre_dmawrite)(struct obd_conn *conn, int count, struct obd_buf **dstbufs, 
+                        struct obd_bufref **dest); 
+       int (*o_dmawrite)(struct obd_conn *conn, int count, struct obd_buf **dstbufs, 
+                        struct obd_buf **dest); 
 };
 
 struct obd_request {
index e7f9131..baf102e 100644 (file)
 #define REQUEST_MINOR 244
 extern int mds_queue_req(struct mds_request *);
 
+static int mds_send_req(struct mds_request *req)
+{
+       int rc;
+       init_waitqueue_head(&req->rq_wait_for_rep);
+       /* XXX replace the following with networking code */ 
+       rc = mds_queue_req(req); 
+       if (rc) { 
+               EXIT;
+               return rc;
+       }
+
+       printk("-- sleeping\n");
+       interruptible_sleep_on(&req->rq_wait_for_rep);
+       printk("-- done\n");
+       return 0;
+}
+
 int llight_getattr(ino_t ino, struct  mds_rep  *rep)
 {
        struct mds_request *request;
@@ -56,7 +73,7 @@ int llight_getattr(ino_t ino, struct  mds_rep  *rep)
 
        request->rq_reqhdr->opc = MDS_GETATTR;
        
-       rc = mds_queue_req(request);
+       rc = mds_send_req(request);
        if (rc) { 
                printk("llight request: error in handling %d\n", rc); 
                return rc;
index fe58fbc..b0ade44 100644 (file)
 // for testing
 static struct mds_obd *MDS;
 
-// for testing
+// XXX make this networked!  
 static int mds_queue_req(struct mds_request *req)
 {
+       struct mds_request *srv_request;
        
        if (!MDS) { 
                EXIT;
                return -1;
        }
 
-       list_add(&req->rq_list, &MDS->mds_reqs); 
-       init_waitqueue_head(&req->rq_wait_for_mds_rep);
-       req->rq_obd = MDS;
+       srv_request = kmalloc(sizeof(*srv_request), GFP_KERNEL);
+       if (!srv_request) { 
+               EXIT;
+               return -ENOMEM;
+       }
+
+       /* move the request buffer */
+       srv_request->rq_reqlen = req->rq_reqlen;
+       srv_request->rq_reqbuf = req->rq_reqbuf;
+       srv_request->rq_obd = MDS;
+
+       req->rq_reqbuf = NULL;
+       req->rq_reqlen = 0; 
+
+       /* remember where it came from */
+       srv_request->rq_reply_handle = req;
+
+       /* get the server working on this request */
+       spin_lock(&MDS->mds_lock); 
+       list_add(&srv_request->rq_list, &MDS->mds_reqs); 
+       spin_unlock(&MDS->mds_lock); 
        wake_up(&MDS->mds_waitq);
+
+       /* put client asleep */
        printk("-- sleeping\n");
-       interruptible_sleep_on(&req->rq_wait_for_mds_rep);
+       interruptible_sleep_on(&req->rq_wait_for_rep);
        printk("-- done\n");
        return 0;
 }
@@ -113,12 +134,25 @@ int mds_getattr(struct mds_request *req)
        return 0;
 }
 
+/* XXX replace with networking code */
 int mds_reply(struct mds_request *req)
 {
+       struct mds_request *clnt_req = req->rq_reply_handle;
+
        ENTRY;
+
+       /* free the request buffer */
        kfree(req->rq_reqbuf);
        req->rq_reqbuf = NULL; 
-       wake_up_interruptible(&req->rq_wait_for_mds_rep); 
+       
+       /* move the reply to the client */ 
+       clnt_req->rq_replen = req->rq_replen;
+       clnt_req->rq_repbuf = req->rq_repbuf;
+       req->rq_repbuf = NULL;
+       req->rq_replen = 0;
+
+       /* wake up the client */ 
+       wake_up_interruptible(&clnt_req->rq_wait_for_rep); 
        EXIT;
        return 0;
 }
@@ -139,7 +173,9 @@ int mds_error(struct mds_request *req)
        hdr->seqno = req->rq_reqhdr->seqno;
        hdr->status = req->rq_status; 
        hdr->type = MDS_TYPE_ERR;
+
        req->rq_repbuf = (char *)hdr;
+       req->rq_replen = sizeof(*hdr); 
 
        EXIT;
        return mds_reply(req);
index 84b6440..7b75e89 100644 (file)
@@ -151,8 +151,10 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        data = (struct obd_ioctl_data *)buf;
 
         switch (cmd) {
-        case TCGETS:
+        case TCGETS: { 
+               EXIT;
                 return -EINVAL;
+       }
        case OBD_IOC_DEVICE: { 
                CDEBUG(D_IOCTL, "\n");
                if (data->ioc_dev >= MAX_OBD_DEVICES ||
@@ -366,6 +368,34 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                 EXIT;
                 return err;
         }
+
+        case OBD_IOC_GETATTR: {
+                /* has this minor been registered? */
+               printk("---> getattr!"); 
+                if ( !(obd->obd_flags & OBD_ATTACHED) ||
+                     !(obd->obd_flags & OBD_SET_UP)) {
+                        CDEBUG(D_IOCTL, "Device not attached or set up\n");
+                        return -ENODEV;
+                }
+                conn.oc_id = data->ioc_conn1;
+               conn.oc_dev = obd;
+
+                if ( !OBT(obd) || !OBP(obd, getattr) ) { 
+                       EXIT;
+                        return -EOPNOTSUPP;
+               }
+
+                err = OBP(obd, getattr)(&conn, &data->ioc_obdo1);
+                if (err) {
+                        EXIT;
+                        return err;
+                }
+
+                err = copy_to_user((int *)arg, data, sizeof(*data));
+                EXIT;
+                return err;
+        }
+
 #if 0
         case OBD_IOC_SYNC: {
                 struct oic_range_s *range = tmp_buf;
@@ -747,8 +777,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
         }
 } /* obd_class_ioctl */
 
-/* Driver interface done, utility functions follow */
 
+/* Driver interface done, utility functions follow */
 int obd_register_type(struct obd_ops *ops, char *nm)
 {
         struct obd_type *type;
index f67764c..f3c36a7 100644 (file)
@@ -9,6 +9,7 @@
  * Copryright (C) 1999 Stelias Computing Inc. <braam@stelias.com>
  * Copryright (C) 1999 Seagate Technology Inc.
  * Copryright (C) 2001 Mountain View Data, Inc.
+ * Copryright (C) 2002 Cluster File Systems, Inc.
  *
  */
 
@@ -84,42 +85,13 @@ static void obdfs_options(char *options, char **dev, char **vers)
         }
 }
 
-static int obdfs_getdev(char *devpath, int *dev)
-{
-        struct dentry *dentry;
-        kdev_t devno;
-        struct nameidata nd;
-        int error = 0; 
-
-        ENTRY;
-        if (path_init(devpath, LOOKUP_POSITIVE, &nd))
-                error = path_walk(devpath, &nd);
-        if (error)
-                return error;
-
-        dentry = nd.dentry;
-        if (!S_ISCHR(dentry->d_inode->i_mode))
-                return -ENODEV;
-
-        devno = dentry->d_inode->i_rdev;
-        if ( MAJOR(devno) != OBD_PSDEV_MAJOR ) 
-                return -ENODEV;
-        
-        if ( MINOR(devno) >= MAX_OBD_DEVICES ) 
-                return -ENODEV;
-
-        *dev = devno;
-        return 0;
-}
-
-
 static struct super_block * obdfs_read_super(struct super_block *sb, 
                                             void *data, int silent)
 {
         struct inode *root = 0; 
         struct obdfs_sb_info *sbi = (struct obdfs_sb_info *)(&sb->u.generic_sbp);
         struct obd_device *obddev;
-        char *device = NULL;
+       char *device = NULL;
         char *version = NULL;
        int connected = 0;
         int devno;
@@ -144,30 +116,16 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
                 goto ERR;
         }
 
+       devno = simple_strtoul(device, NULL, 0);
         CDEBUG(D_INFO, "\n"); 
-        if ( (err = obdfs_getdev(device, &devno)) ) {
-                printk("Cannot get devno of %s, error %d\n", device, err);
-                EXIT;
-                goto ERR;;
-        }
-
-        CDEBUG(D_INFO, "\n"); 
-        if ( MAJOR(devno) != OBD_PSDEV_MAJOR ) {
-                printk(__FUNCTION__ ": wrong major number %d!\n", MAJOR(devno));
-                EXIT;
-                goto ERR;
-        }
-                
-        CDEBUG(D_INFO, "\n"); 
-        if ( MINOR(devno) >= MAX_OBD_DEVICES ) {
-                printk(__FUNCTION__ ": minor of %s too high (%d)\n",
-                       device, MINOR(devno));
+        if ( devno >= MAX_OBD_DEVICES ) {
+                printk(__FUNCTION__ ": device of %s too high (%d)\n", device, devno);
                 EXIT;
                 goto ERR;
         } 
 
         CDEBUG(D_INFO, "\n"); 
-        obddev = &obd_dev[MINOR(devno)];
+        obddev = &obd_dev[devno];
 
         CDEBUG(D_INFO, "\n"); 
         if ( ! (obddev->obd_flags & OBD_ATTACHED) || 
@@ -550,7 +508,7 @@ struct file_system_type obdfs_fs_type = {
 
 int init_obdfs(void)
 {
-        int err;
+        //int err;
 
         printk(KERN_INFO "OBDFS v0.1, braam@stelias.com\n");
 
diff --git a/lustre/osc/Makefile.am b/lustre/osc/Makefile.am
new file mode 100644 (file)
index 0000000..ce6bcb6
--- /dev/null
@@ -0,0 +1,16 @@
+# Copyright (C) 2001  Cluster File Systems, Inc.
+#
+# This code is issued under the GNU General Public License.
+# See the file COPYING in this distribution
+
+MODULE = osc
+modulefs_DATA = osc.o
+EXTRA_PROGRAMS = osc
+
+
+osc_SOURCES =  obd_pack.c osc_request.c # super.c rw.c file.c dir.c sysctl.c super.c namei.c symlink.c
+
+obd_pack.c: 
+       ln -s ../lib/obd_pack.c .
+
+include $(top_srcdir)/Rules
diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c
new file mode 100644 (file)
index 0000000..94556fb
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copryright (C) 2001 Cluster File Systems, Inc.
+ *
+ */
+
+#define EXPORT_SYMTAB
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/stat.h>
+#include <linux/errno.h>
+#include <linux/locks.h>
+#include <linux/unistd.h>
+
+#include <asm/system.h>
+#include <asm/uaccess.h>
+
+#include <linux/fs.h>
+#include <linux/stat.h>
+#include <asm/uaccess.h>
+#include <linux/vmalloc.h>
+#include <asm/segment.h>
+#include <linux/miscdevice.h>
+
+#include <linux/obd_support.h>
+#include <linux/obd_class.h>
+#include <linux/lustre_lib.h>
+#include <linux/lustre_idl.h>
+
+extern int ost_queue_req(struct obd_device *obddev, struct ost_request *);
+
+
+
+int osc_getattr(struct obd_conn *conn, struct obdo *oa)
+{
+       struct obd_device *obddev = conn->oc_dev;
+       struct ost_request *request;
+       int rc; 
+
+       request = (struct ost_request *)kmalloc(sizeof(*request), 
+                                               GFP_KERNEL); 
+       if (!request) { 
+               printk("osc_getattr: request allocation out of memory\n");
+               return -ENOMEM;
+       }
+
+       rc = ost_pack_req(NULL, 0, NULL, 0, 
+                         &request->rq_reqhdr, &request->rq_req, 
+                         &request->rq_reqlen, &request->rq_reqbuf);
+       if (rc) { 
+               printk("llight request: cannot pack request %d\n", rc); 
+               return rc;
+       }
+       
+       memcpy(&request->rq_req->oa, oa, sizeof(*oa));
+       request->rq_reqhdr->opc = OST_GETATTR;
+       
+       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);
+       if (rc) { 
+               printk("ost_gettatr: error in handling %d\n", rc); 
+               return rc;
+       }
+
+       printk("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);
+       return 0;
+}
+
+
+/* mount the file system (secretly) */
+static int osc_setup(struct obd_device *obddev, obd_count len,
+                       void *buf)
+                       
+{
+       struct obd_ioctl_data* data = buf;
+       struct osc_obd *osc = &obddev->u.osc;
+        ENTRY;
+
+       if (data->ioc_dev  < 0 || data->ioc_dev > MAX_OBD_DEVICES) { 
+               EXIT;
+               return -ENODEV;
+       }
+
+        osc->osc_tgt = &obd_dev[data->ioc_dev];
+       printk("OSC: tgt %d ost at %p\n", data->ioc_dev, &osc->osc_tgt->u.ost); 
+        if ( ! (osc->osc_tgt->obd_flags & OBD_ATTACHED) || 
+             ! (osc->osc_tgt->obd_flags & OBD_SET_UP) ){
+                printk("device not attached or not set up (%d)\n", 
+                       data->ioc_dev);
+                EXIT;
+               return -EINVAL;
+        } 
+
+        MOD_INC_USE_COUNT;
+        EXIT; 
+        return 0;
+} 
+
+static int osc_cleanup(struct obd_device * obddev)
+{
+        ENTRY;
+
+        if ( !(obddev->obd_flags & OBD_SET_UP) ) {
+                EXIT;
+                return 0;
+        }
+
+        MOD_DEC_USE_COUNT;
+        EXIT;
+        return 0;
+}
+
+
+struct obd_ops osc_obd_ops = { 
+       o_setup:   osc_setup,
+       o_cleanup: osc_cleanup, 
+       o_getattr: osc_getattr
+};
+
+static int __init osc_init(void)
+{
+        obd_register_type(&osc_obd_ops, LUSTRE_OSC_NAME);
+       return 0;
+}
+
+static void __exit osc_exit(void)
+{
+       obd_unregister_type(LUSTRE_OSC_NAME);
+}
+
+MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
+MODULE_DESCRIPTION("Lustre Object Storage Client (OSC) v1.0");
+MODULE_LICENSE("GPL"); 
+
+module_init(osc_init);
+module_exit(osc_exit);
+
index b36beca..122e71c 100644 (file)
@@ -11,6 +11,9 @@
  *  by Peter Braam <braam@clusterfs.com>
  * 
  *  This server is single threaded at present (but can easily be multi threaded). 
+ *  For testing and management it is treated as an obd_device, although it does
+ *  not export a full OBD method table (the requests are coming in over the wire, 
+ *  so object target modules do not have a full method table.)
  * 
  */
 
 #include <linux/lustre_mds.h>
 #include <linux/obd_class.h>
 
-
-// for testing
-static struct ost_obd *OST;
-
 // for testing
-static int ost_queue_req(struct ost_request *req)
+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;
        
-       if (!OST) { 
+       printk("---> OST at %d %p\n", __LINE__, ost);
+       if (!ost) { 
                EXIT;
                return -1;
        }
 
-       list_add(&req->rq_list, &OST->ost_reqs); 
-       init_waitqueue_head(&req->rq_wait_for_ost_rep);
-       req->rq_obd = OST;
-       wake_up(&OST->ost_waitq);
-       printk("-- sleeping\n");
-       interruptible_sleep_on(&req->rq_wait_for_ost_rep);
-       printk("-- done\n");
+       srv_req = kmalloc(sizeof(*srv_req), GFP_KERNEL); 
+       if (!srv_req) { 
+               EXIT;
+               return -ENOMEM;
+       }
+       memcpy(srv_req, req, sizeof(*req)); 
+       srv_req->rq_reply_handle = req;
+       srv_req->rq_obd = ost;
+       list_add(&srv_req->rq_list, &ost->ost_reqs); 
+
+       wake_up(&ost->ost_waitq);
        return 0;
 }
 
-int ost_reply(struct ost_request *req)
+
+/* XXX replace with networking code */
+int ost_reply(struct obd_device *obddev, struct ost_request *req)
 {
+       struct ost_request *clnt_req = req->rq_reply_handle;
+
        ENTRY;
+
+       /* free the request buffer */
        kfree(req->rq_reqbuf);
        req->rq_reqbuf = NULL; 
-       wake_up_interruptible(&req->rq_wait_for_ost_rep); 
+       
+       /* move the reply to the client */ 
+       clnt_req->rq_replen = req->rq_replen;
+       clnt_req->rq_repbuf = req->rq_repbuf;
+       req->rq_repbuf = NULL;
+       req->rq_replen = 0;
+       
+       /* free the server request */
+       kfree(req); 
+       /* wake up the client */ 
+       wake_up_interruptible(&clnt_req->rq_wait_for_rep); 
        EXIT;
        return 0;
 }
 
-int ost_error(struct ost_request *req)
+int ost_error(struct obd_device *obddev, struct ost_request *req)
 {
        struct ost_rep_hdr *hdr;
 
@@ -85,7 +107,7 @@ int ost_error(struct ost_request *req)
        req->rq_repbuf = (char *)hdr;
 
        EXIT;
-       return ost_reply(req);
+       return ost_reply(obddev, req);
 }
 
 static int ost_destroy(struct ost_obd *ost, struct ost_request *req)
@@ -99,7 +121,7 @@ static int ost_destroy(struct ost_obd *ost, struct ost_request *req)
        conn.oc_dev = ost->ost_tgt;
 
        rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
-                         &req->rq_reqlen, &req->rq_reqbuf); 
+                         &req->rq_replen, &req->rq_repbuf); 
        if (rc) { 
                printk("ost_destroy: cannot pack reply\n"); 
                return rc;
@@ -123,7 +145,7 @@ static int ost_getattr(struct ost_obd *ost, struct ost_request *req)
        conn.oc_dev = ost->ost_tgt;
 
        rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
-                         &req->rq_reqlen, &req->rq_reqbuf); 
+                         &req->rq_replen, &req->rq_repbuf); 
        if (rc) { 
                printk("ost_getattr: cannot pack reply\n"); 
                return rc;
@@ -148,7 +170,7 @@ static int ost_create(struct ost_obd *ost, struct ost_request *req)
        conn.oc_dev = ost->ost_tgt;
 
        rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
-                         &req->rq_reqlen, &req->rq_reqbuf); 
+                         &req->rq_replen, &req->rq_repbuf); 
        if (rc) { 
                printk("ost_create: cannot pack reply\n"); 
                return rc;
@@ -175,7 +197,7 @@ static int ost_setattr(struct ost_obd *ost, struct ost_request *req)
        conn.oc_dev = ost->ost_tgt;
 
        rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
-                         &req->rq_reqlen, &req->rq_reqbuf); 
+                         &req->rq_replen, &req->rq_repbuf); 
        if (rc) { 
                printk("ost_setattr: cannot pack reply\n"); 
                return rc;
@@ -190,11 +212,87 @@ static int ost_setattr(struct ost_obd *ost, struct ost_request *req)
        return 0;
 }
 
+static int ost_connect(struct ost_obd *ost, struct ost_request *req)
+{
+       struct obd_conn conn; 
+       int rc;
+
+       ENTRY;
+       
+       conn.oc_dev = ost->ost_tgt;
+
+       rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+                         &req->rq_replen, &req->rq_repbuf); 
+       if (rc) { 
+               printk("ost_setattr: cannot pack reply\n"); 
+               return rc;
+       }
+
+       req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_connect(&conn);
+       req->rq_rep->connid = conn.oc_id;
+
+       EXIT;
+       return 0;
+}
+
+
+static int ost_disconnect(struct ost_obd *ost, struct ost_request *req)
+{
+       struct obd_conn conn; 
+       int rc;
+
+       ENTRY;
+       
+       conn.oc_dev = ost->ost_tgt;
+       conn.oc_id = req->rq_req->connid;
+
+       rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+                         &req->rq_replen, &req->rq_repbuf); 
+       if (rc) { 
+               printk("ost_setattr: cannot pack reply\n"); 
+               return rc;
+       }
+
+       req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_disconnect(&conn);
+
+       EXIT;
+       return 0;
+}
+
+static int ost_get_info(struct ost_obd *ost, struct ost_request *req)
+{
+       struct obd_conn conn; 
+       int rc;
+       int vallen;
+       void *val;
+
+       ENTRY;
+       
+       conn.oc_id = req->rq_req->connid;
+       conn.oc_dev = ost->ost_tgt;
+
+       req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_get_info
+               (&conn, req->rq_req->buflen1, req->rq_req->buf1, &vallen, &val); 
+
+
+       rc = ost_pack_rep(val, vallen, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+                         &req->rq_replen, &req->rq_repbuf); 
+       if (rc) { 
+               printk("ost_setattr: cannot pack reply\n"); 
+               return rc;
+       }
+
+       EXIT;
+       return 0;
+}
+
+
 
 //int ost_handle(struct ost_conn *conn, int len, char *buf)
-int ost_handle(struct ost_obd *ost, struct ost_request *req)
+int ost_handle(struct obd_device *obddev, struct ost_request *req)
 {
        int rc;
+       struct ost_obd *ost = &obddev->u.ost;
        struct ost_req_hdr *hdr;
 
        ENTRY;
@@ -218,6 +316,18 @@ int ost_handle(struct ost_obd *ost, struct ost_request *req)
 
        switch (req->rq_reqhdr->opc) { 
 
+       case OST_CONNECT:
+               CDEBUG(D_INODE, "connect\n");
+               rc = ost_connect(ost, req);
+               break;
+       case OST_DISCONNECT:
+               CDEBUG(D_INODE, "disconnect\n");
+               rc = ost_disconnect(ost, req);
+               break;
+       case OST_GET_INFO:
+               CDEBUG(D_INODE, "get_info\n");
+               rc = ost_get_info(ost, req);
+               break;
        case OST_CREATE:
                CDEBUG(D_INODE, "create\n");
                rc = ost_create(ost, req);
@@ -236,16 +346,16 @@ int ost_handle(struct ost_obd *ost, struct ost_request *req)
                break;
 
        default:
-               return ost_error(req);
+               return ost_error(obddev, req);
        }
 
 out:
        if (rc) { 
                printk("ost: processing error %d\n", rc);
-               ost_error(req);
+               ost_error(obddev, req);
        } else { 
                CDEBUG(D_INODE, "sending reply\n"); 
-               ost_reply(req); 
+               ost_reply(obddev, req); 
        }
 
        return 0;
@@ -253,20 +363,34 @@ out:
 
 int ost_main(void *arg)
 {
-       struct ost_obd *ost = (struct ost_obd *) arg;
+       struct obd_device *obddev = (struct obd_device *) arg;
+       struct ost_obd *ost = &obddev->u.ost;
+       ENTRY;
+       printk("---> %d\n", __LINE__);
+
 
        lock_kernel();
+       printk("---> %d\n", __LINE__);
        daemonize();
+       printk("---> %d\n", __LINE__);
        spin_lock_irq(&current->sigmask_lock);
+       printk("---> %d\n", __LINE__);
        sigfillset(&current->blocked);
+       printk("---> %d\n", __LINE__);
        recalc_sigpending(current);
+       printk("---> %d\n", __LINE__);
        spin_unlock_irq(&current->sigmask_lock);
+       printk("---> %d\n", __LINE__);
 
+       printk("---> %d\n", __LINE__);
        sprintf(current->comm, "lustre_ost");
+       printk("---> %d\n", __LINE__);
 
        /* Record that the  thread is running */
        ost->ost_thread = current;
+       printk("---> %d\n", __LINE__);
        wake_up(&ost->ost_done_waitq); 
+       printk("---> %d\n", __LINE__);
 
        /* XXX maintain a list of all managed devices: insert here */
 
@@ -288,16 +412,19 @@ int ost_main(void *arg)
                if (list_empty(&ost->ost_reqs)) { 
                        CDEBUG(D_INODE, "woke because of timer\n"); 
                } else { 
+                       printk("---> %d\n", __LINE__);
                        request = list_entry(ost->ost_reqs.next, 
                                             struct ost_request, rq_list);
+                       printk("---> %d\n", __LINE__);
                        list_del(&request->rq_list);
-                       rc = ost_handle(ost, request); 
+                       rc = ost_handle(obddev, request); 
                }
        }
 
        /* XXX maintain a list of all managed devices: cleanup here */
-
+       printk("---> %d\n", __LINE__);
        ost->ost_thread = NULL;
+       printk("---> %d\n", __LINE__);
        wake_up(&ost->ost_done_waitq);
        printk("lustre_ost: exiting\n");
        return 0;
@@ -313,14 +440,22 @@ static void ost_stop_srv_thread(struct ost_obd *ost)
        }
 }
 
-static void ost_start_srv_thread(struct ost_obd *ost)
+static void ost_start_srv_thread(struct obd_device *obd)
 {
+       struct ost_obd *ost = &obd->u.ost;
+       ENTRY;
+
        init_waitqueue_head(&ost->ost_waitq);
+       printk("---> %d\n", __LINE__);
        init_waitqueue_head(&ost->ost_done_waitq);
-       kernel_thread(ost_main, (void *)ost, 
+       printk("---> %d\n", __LINE__);
+       kernel_thread(ost_main, (void *)obd, 
                      CLONE_VM | CLONE_FS | CLONE_FILES);
+       printk("---> %d\n", __LINE__);
        while (!ost->ost_thread) 
                sleep_on(&ost->ost_done_waitq);
+       printk("---> %d\n", __LINE__);
+       EXIT;
 }
 
 /* mount the file system (secretly) */
@@ -349,6 +484,7 @@ static int ost_setup(struct obd_device *obddev, obd_count len,
                return -EINVAL;
         } 
 
+       ost->ost_conn.oc_dev = tgt;
        err = tgt->obd_type->typ_ops->o_connect(&ost->ost_conn);
        if (err) { 
                printk("lustre ost: fail to connect to device %d\n", 
@@ -356,14 +492,17 @@ 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;
-       OST = ost;
 
+       printk("---> %d\n", __LINE__);
        spin_lock_init(&obddev->u.ost.fo_lock);
 
-       ost_start_srv_thread(ost);
+       printk("---> %d\n", __LINE__);
+       ost_start_srv_thread(obddev);
+       printk("---> %d\n", __LINE__);
 
         MOD_INC_USE_COUNT;
         EXIT; 
@@ -389,7 +528,6 @@ static int ost_cleanup(struct obd_device * obddev)
                 return -EBUSY;
         }
 
-       OST = NULL;
        ost_stop_srv_thread(ost);
 
        if (!list_empty(&ost->ost_reqs)) {
@@ -431,7 +569,6 @@ MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
 MODULE_DESCRIPTION("Lustre Object Storage Target (OST) v0.01");
 MODULE_LICENSE("GPL");
 
-
 // for testing (maybe this stays)
 EXPORT_SYMBOL(ost_queue_req);
 
index 23a4a67..1db9a94 100644 (file)
@@ -3,8 +3,25 @@
 #
 # This code is issued under the GNU General Public License.
 # See the file COPYING in this distribution
+#!/bin/sh
 
-insmod loop
+R=/r
+
+insmod /lib/modules/2.4.17/kernel/drivers/block/loop.o
 dd if=/dev/zero of=/tmp/fs bs=1024 count=10000
-losetup /dev/loop0 /tmp/fs
-mke2fs -b 4096 /dev/loop0
+mke2fs -b 4096 -F /tmp/fs
+losetup /dev/loop/0 /tmp/fs
+
+insmod $R/usr/src/obd/class/obdclass.o 
+insmod $R/usr/src/obd/ext2obd/obdext2.o
+mknod /dev/obd c 10 241
+
+$R/usr/src/obd/utils/obdctl <<EOF
+device 0
+attach obdext2
+setup /dev/loop/0
+quit
+EOF
+
+insmod $R/usr/src/obd/obdfs/obdfs.o
+mount -t obdfs -o device=0 none /mnt
index 2e8010b..cfe358e 100644 (file)
@@ -7,4 +7,3 @@ CPPFLAGS :=
 LDADD := -lreadline -ltermcap # -lefence
 bin_PROGRAMS = obdctl
 obdctl_SOURCES = parser.c obdctl.c
-
index 4be1b2e..47a4f98 100644 (file)
@@ -257,6 +257,7 @@ static int jt_setup(int argc, char **argv)
 
        data.ioc_inllen1 =  strlen(argv[1]) + 1;
        data.ioc_inlbuf1 = argv[1];
+       data.ioc_dev = strtoul(argv[1], NULL, 0); 
        if ( argc == 3 ) { 
                data.ioc_inllen2 = strlen(argv[2]) + 1;
                data.ioc_inlbuf2 = argv[2];
@@ -293,7 +294,9 @@ static int jt_create(int argc, char **argv)
        IOCINIT(data);
        if (argc > 1) { 
                num = strtoul(argv[1], NULL, 0);
-       } else
+       } else { 
+               printf("usage %s num [mode] [silent]\n", argv[0]); 
+       }
 
        if (argc > 2) { 
                data.ioc_obdo1.o_mode = strtoul(argv[2], NULL, 0);
@@ -320,6 +323,31 @@ static int jt_create(int argc, char **argv)
        return 0;
 }
 
+static int jt_getattr(int argc, char **argv)
+{
+       struct obd_ioctl_data data;
+       int rc;
+
+       IOCINIT(data);
+       if (argc != 1) { 
+               data.ioc_obdo1.o_id = strtoul(argv[1], NULL, 0);
+               data.ioc_obdo1.o_valid = 0xffffffff;
+               printf("getting attr for %Ld\n", data.ioc_obdo1.o_id);
+       } else { 
+               printf("usage %s id\n", argv[0]); 
+               return 0;
+       }
+
+       rc = ioctl(fd, OBD_IOC_GETATTR , &data);
+       if (rc) { 
+               printf("Error: %s\n", strerror(rc)); 
+       } else { 
+               printf("attr obdo %Ld, mode %o\n", data.ioc_obdo1.o_id, 
+                      data.ioc_obdo1.o_mode);
+       }
+       return 0;
+}
+
 command_t list[] = {
        {"device", jt_device, 0, "set current device (args device no)"},
     {"attach", jt_attach, 0, "name the typed of device (args: type data"},
@@ -327,6 +355,7 @@ command_t list[] = {
     {"detach", jt_detach, 0, "detach the current device (arg: )"},
     {"cleanup", jt_cleanup, 0, "cleanup the current device (arg: )"},
     {"create", jt_create, 0, "create [count [mode [silent]]]"},
+    {"getattr", jt_getattr, 0, "getattr id"},
     {"connect", jt_connect, 0, "connect - get a connection to device"},
     {"disconnect", jt_disconnect, 0, "disconnect - break connection to device"},
     {"help", Parser_help, 0, "help"},