Whamcloud - gitweb
class/obdcontrol: fixed read, write, create to work with obdos
[fs/lustre-release.git] / lustre / obdclass / class_obd.c
index 45d2fcf..87d4b52 100644 (file)
@@ -95,7 +95,7 @@ static int obd_class_release(struct inode * inode, struct file * file)
                return -ENODEV;
        fsync_dev(inode->i_rdev);
        if (obd_dev[dev].obd_refcnt <= 0)
-               printk(KERN_ALERT "obd_class_release: refcount(%d) <= 0\n",
+               printk(KERN_ALERT "presto_psdev_release: refcount(%d) <= 0\n",
                       obd_dev[dev].obd_refcnt);
        obd_dev[dev].obd_refcnt--;
 
@@ -156,8 +156,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 {
        struct obd_device *obddev;
        /* NOTE this must be larger than any of the ioctl data structs */
-       char buff[1024];
-       void *karg = buff;
+       char buf[1024];
+       void *tmp_buf = buf;
        struct obd_conn conn;
        int err, dev;
        long int cli_id; /* connect, disconnect */
@@ -176,7 +176,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                return -EINVAL;
        case OBD_IOC_ATTACH: {
                struct obd_type *type;
-               struct oic_generic *input = karg;
+               struct oic_generic *input = tmp_buf;
 
                ENTRY;
                /* have we attached a type to this device */
@@ -290,7 +290,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        int setup_datalen;
                        void *setup_data;
                } *setup;
-               setup = karg;
+               setup = tmp_buf;
 
                ENTRY;
                /* have we attached a type to this device */
@@ -423,7 +423,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                return 0;
 
        case OBD_IOC_SYNC: {
-               struct oic_range_s *range = karg;
+               struct oic_range_s *range = tmp_buf;
 
                if (!obddev->obd_type)
                        return -ENODEV;
@@ -453,7 +453,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                return put_user(err, (int *) arg);
        }
        case OBD_IOC_CREATE: {
-               struct oic_attr_s *attr = karg;
+               struct oic_attr_s *attr = tmp_buf;
 
                err = copy_from_user(attr, (const void *)arg,  sizeof(*attr));
                if (err) {
@@ -484,7 +484,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_DESTROY: {
-               struct oic_attr_s *attr = karg;
+               struct oic_attr_s *attr = tmp_buf;
                
                /* has this minor been registered? */
                if (!obddev->obd_type)
@@ -506,7 +506,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_SETATTR: {
-               struct oic_attr_s *attr = karg;
+               struct oic_attr_s *attr = tmp_buf;
 
                /* has this minor been registered? */
                if (!obddev->obd_type)
@@ -526,13 +526,14 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_GETATTR: {
-               struct oic_attr_s *attr = karg;
+               struct oic_attr_s *attr = tmp_buf;
 
                err = copy_from_user(attr, (int *)arg, sizeof(*attr));
                if (err)
                        return err;
 
                conn.oc_id = attr->conn_id;
+               ODEBUG(&attr->obdo);
                err = OBP(obddev, getattr)(&conn, &attr->obdo);
                if ( err ) {
                        EXIT;
@@ -546,7 +547,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 
        case OBD_IOC_READ: {
                int err;
-               struct oic_rw_s *rw_s = karg;  /* read, write ioctl str */
+               struct oic_rw_s *rw_s = tmp_buf;  /* read, write ioctl str */
 
                err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
                if ( err ) {
@@ -562,8 +563,13 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        return err;
                }
 
+
                err = OBP(obddev, read)(&conn, &rw_s->obdo, rw_s->buf, 
                                        &rw_s->count, rw_s->offset);
+               
+               ODEBUG(&rw_s->obdo);
+               CDEBUG(D_INODE, "READ: conn %d, count %Ld, offset %Ld, '%s'\n",
+                      rw_s->conn_id, rw_s->count, rw_s->offset, rw_s->buf);
                if ( err ) {
                        EXIT;
                        return err;
@@ -575,7 +581,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_WRITE: {
-               struct oic_rw_s *rw_s = karg;  /* read, write ioctl str */
+               struct oic_rw_s *rw_s = tmp_buf;  /* read, write ioctl str */
 
                err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
                if ( err ) {
@@ -590,19 +596,23 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        return err;
                }
 
+               CDEBUG(D_INODE, "WRITE: conn %d, count %Ld, offset %Ld, '%s'\n",
+                      rw_s->conn_id, rw_s->count, rw_s->offset, rw_s->buf);
                err = OBP(obddev, write)(&conn, &rw_s->obdo, rw_s->buf, 
                                         &rw_s->count, rw_s->offset);
+               ODEBUG(&rw_s->obdo);
                if ( err ) {
                        EXIT;
                        return err;
                }
 
-               err = copy_to_user((int*)arg, &rw_s->count, sizeof(rw_s->count));
+               err = copy_to_user((int *)arg, &rw_s->count,
+                                  sizeof(rw_s->count));
                EXIT;
                return err;
        }
        case OBD_IOC_PREALLOCATE: {
-               struct oic_prealloc_s *prealloc = karg;
+               struct oic_prealloc_s *prealloc = tmp_buf;
 
                /* has this minor been registered? */
                if (!obddev->obd_type)
@@ -621,7 +631,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                if ( !OBT(obddev) || !OBP(obddev, preallocate) )
                        return -EOPNOTSUPP;
 
-               conn.oc_id = prealloc->cli_id;
+               conn.oc_id = prealloc->conn_id;
                err = OBP(obddev, preallocate)(&conn, &prealloc->alloc,
                                               prealloc->ids);
                if ( err ) {
@@ -660,7 +670,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                
        }
        case OBD_IOC_COPY: {
-               struct ioc_mv_s *mvdata = karg;
+               struct ioc_mv_s *mvdata = tmp_buf;
 
                if ( (!(obddev->obd_flags & OBD_SET_UP)) ||
                     (!(obddev->obd_flags & OBD_ATTACHED))) {
@@ -692,7 +702,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_MIGR: {
-               struct ioc_mv_s *mvdata = karg;
+               struct ioc_mv_s *mvdata = tmp_buf;
 
                if ( (!(obddev->obd_flags & OBD_SET_UP)) ||
                     (!(obddev->obd_flags & OBD_ATTACHED))) {
@@ -706,7 +716,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        return err;
                }
 
-               CDEBUG(D_IOCTL, "Migrate copying %d\n", sizeof(*mvdata));
+               CDEBUG(D_IOCTL, "Migrate copying %d bytes\n", sizeof(*mvdata));
 
                if ( !OBT(obddev) || !OBP(obddev, migrate) )
                        return -EOPNOTSUPP;
@@ -718,7 +728,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 
                conn.oc_id = mvdata->src_conn_id;
                err = OBP(obddev, migrate)(&conn, &mvdata->dst, &mvdata->src, 
-                                          mvdata->dst.o_size, 0);
+                                          mvdata->src.o_size, 0);
 
                return err;
        }
@@ -761,7 +771,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 
                /* get the generic data */
                karg = input.att_data;
-               err = getdata(input.att_datalen, karg);
+               err = getdata(input.att_datalen, &karg);
                if ( err ) {
                        EXIT;
                        return err;