Whamcloud - gitweb
Updating obdfs/ext2obd methods for new obdo parameters.
authoradilger <adilger>
Tue, 4 Jan 2000 01:07:15 +0000 (01:07 +0000)
committeradilger <adilger>
Tue, 4 Jan 2000 01:07:15 +0000 (01:07 +0000)
lustre/include/linux/obd_class.h
lustre/include/linux/obd_support.h
lustre/obdclass/class_obd.c
lustre/obdclass/obdcontrol
lustre/obdfs/Makefile
lustre/obdfs/namei.c
lustre/obdfs/rw.c
lustre/obdfs/super.c

index 22a2a9f..6ea3e80 100644 (file)
@@ -58,6 +58,23 @@ struct obdo {
        struct obd_ops          *o_op;
 };
 
        struct obd_ops          *o_op;
 };
 
+#define OBD_MD_FLALL   (~0UL)
+#define OBD_MD_FLID    (1UL)
+#define OBD_MD_FLATIME (1UL<<1)
+#define OBD_MD_FLMTIME (1UL<<2)
+#define OBD_MD_FLCTIME (1UL<<3)
+#define OBD_MD_FLSIZE  (1UL<<4)
+#define OBD_MD_FLBLOCKS        (1UL<<5)
+#define OBD_MD_FLBLKSZ (1UL<<6)
+#define OBD_MD_FLMODE  (1UL<<7)
+#define OBD_MD_FLUID   (1UL<<8)
+#define OBD_MD_FLGID   (1UL<<9)
+#define OBD_MD_FLFLAGS (1UL<<10)
+#define OBD_MD_FLOBDFLG        (1UL<<11)
+#define OBD_MD_FLNLINK (1UL<<12)
+#define OBD_MD_FLINLINE        (1UL<<13)
+#define OBD_MD_FLOBDMD (1UL<<14)
+
 /*
  *  ======== OBD Device Declarations ===========
  */
 /*
  *  ======== OBD Device Declarations ===========
  */
@@ -194,79 +211,86 @@ static __inline__ struct obdo *obdo_fromid(struct obd_conn *conn, obd_id id)
        return res;
 }
 
        return res;
 }
 
-#define OBD_MD_FLALL   (~0UL)
-#define OBD_MD_FLID    (1UL)
-#define OBD_MD_FLATIME (1UL<<1)
-#define OBD_MD_FLMTIME (1UL<<2)
-#define OBD_MD_FLCTIME (1UL<<3)
-#define OBD_MD_FLSIZE  (1UL<<4)
-#define OBD_MD_FLBLOCKS        (1UL<<5)
-#define OBD_MD_FLBLKSZ (1UL<<6)
-#define OBD_MD_FLMODE  (1UL<<7)
-#define OBD_MD_FLUID   (1UL<<8)
-#define OBD_MD_FLGID   (1UL<<9)
-#define OBD_MD_FLFLAGS (1UL<<10)
-#define OBD_MD_FLOBDFLG        (1UL<<11)
-#define OBD_MD_FLINLINE        (1UL<<12)
-#define OBD_MD_FLOBDMD (1UL<<13)
-
 
 
 static __inline__ void obdo_cpy_md(struct obdo *dst, struct obdo *src)
 {
 
 
 static __inline__ void obdo_cpy_md(struct obdo *dst, struct obdo *src)
 {
-
        CDEBUG(D_INODE, "flags %x\n", src->o_valid);
        CDEBUG(D_INODE, "flags %x\n", src->o_valid);
-       if ( src->o_valid & OBD_MD_FLMODE ) 
-               dst->o_mode = src->o_mode;
-       if ( src->o_valid & OBD_MD_FLUID ) 
-               dst->o_uid = src->o_uid;
-       if ( src->o_valid & OBD_MD_FLGID ) 
-               dst->o_gid = src->o_gid;
-       if ( src->o_valid & OBD_MD_FLSIZE ) 
-               dst->o_size = src->o_size;
        if ( src->o_valid & OBD_MD_FLATIME ) 
                dst->o_atime = src->o_atime;
        if ( src->o_valid & OBD_MD_FLMTIME ) 
                dst->o_mtime = src->o_mtime;
        if ( src->o_valid & OBD_MD_FLCTIME ) 
                dst->o_ctime = src->o_ctime;
        if ( src->o_valid & OBD_MD_FLATIME ) 
                dst->o_atime = src->o_atime;
        if ( src->o_valid & OBD_MD_FLMTIME ) 
                dst->o_mtime = src->o_mtime;
        if ( src->o_valid & OBD_MD_FLCTIME ) 
                dst->o_ctime = src->o_ctime;
+       if ( src->o_valid & OBD_MD_FLSIZE ) 
+               dst->o_size = src->o_size;
+       if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */
+               dst->o_blocks = src->o_blocks;
+       if ( src->o_valid & OBD_MD_FLBLKSZ )
+               dst->o_blksize = src->o_blksize;
+       if ( src->o_valid & OBD_MD_FLMODE ) 
+               dst->o_mode = src->o_mode;
+       if ( src->o_valid & OBD_MD_FLUID ) 
+               dst->o_uid = src->o_uid;
+       if ( src->o_valid & OBD_MD_FLGID ) 
+               dst->o_gid = src->o_gid;
        if ( src->o_valid & OBD_MD_FLFLAGS ) 
                dst->o_flags = src->o_flags;
        if ( src->o_valid & OBD_MD_FLFLAGS ) 
                dst->o_flags = src->o_flags;
-       /* allocation of space */
-       if ( src->o_valid & OBD_MD_FLBLOCKS ) 
-               dst->o_blocks = src->o_blocks;
+       if ( src->o_valid & OBD_MD_FLOBDFLG ) 
+               dst->o_obdflags = src->o_obdflags;
+       if ( src->o_valid & OBD_MD_FLNLINK ) 
+               dst->o_nlink = src->o_nlink;
+       if ( src->o_valid & OBD_MD_FLINLINE ) 
+               memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
+       if ( src->o_valid & OBD_MD_FLOBDMD ) 
+               memcpy(dst->o_obdmd, src->o_obdmd, sizeof(src->o_obdmd));
+
+       dst->o_valid |= src->o_valid;
 }
 
 static __inline__ void obdo_from_inode(struct obdo *dst, struct inode *src)
 {
 }
 
 static __inline__ void obdo_from_inode(struct obdo *dst, struct inode *src)
 {
-
        CDEBUG(D_INODE, "flags %x\n", dst->o_valid);
        CDEBUG(D_INODE, "flags %x\n", dst->o_valid);
-       if ( dst->o_valid & OBD_MD_FLMODE ) 
-               dst->o_mode = src->i_mode;
-       if ( dst->o_valid & OBD_MD_FLUID ) 
-               dst->o_uid = src->i_uid;
-       if ( dst->o_valid & OBD_MD_FLGID ) 
-               dst->o_gid = src->i_gid;
-       if ( dst->o_valid & OBD_MD_FLSIZE ) 
-               dst->o_size = src->i_size;
-       if ( dst->o_valid & OBD_MD_FLATIME ) 
+       if ( dst->o_valid & OBD_MD_FLID )
+               dst->o_id = src->i_ino;
+       if ( dst->o_valid & OBD_MD_FLATIME )
                dst->o_atime = src->i_atime;
                dst->o_atime = src->i_atime;
-       if ( dst->o_valid & OBD_MD_FLMTIME ) 
+       if ( dst->o_valid & OBD_MD_FLMTIME )
                dst->o_mtime = src->i_mtime;
                dst->o_mtime = src->i_mtime;
-       if ( dst->o_valid & OBD_MD_FLCTIME ) 
+       if ( dst->o_valid & OBD_MD_FLCTIME )
                dst->o_ctime = src->i_ctime;
                dst->o_ctime = src->i_ctime;
-       if ( dst->o_valid & OBD_MD_FLFLAGS ) 
-               dst->o_flags = src->i_flags;
-       /* allocation of space */
-       if ( dst->o_valid & OBD_MD_FLBLOCKS ) 
+       if ( dst->o_valid & OBD_MD_FLSIZE )
+               dst->o_size = src->i_size;
+       if ( dst->o_valid & OBD_MD_FLBLOCKS )   /* allocation of space */
                dst->o_blocks = src->i_blocks;
                dst->o_blocks = src->i_blocks;
-
+       if ( dst->o_valid & OBD_MD_FLBLKSZ )
+               dst->o_blksize = src->i_blksize;
+       if ( dst->o_valid & OBD_MD_FLMODE )
+               dst->o_mode = src->i_mode;
+       if ( dst->o_valid & OBD_MD_FLUID )
+               dst->o_uid = src->i_uid;
+       if ( dst->o_valid & OBD_MD_FLGID )
+               dst->o_gid = src->i_gid;
+       if ( dst->o_valid & OBD_MD_FLFLAGS )
+               dst->o_flags = src->i_flags;
 }
 
 static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src)
 {
 
        CDEBUG(D_INODE, "flags %x\n", src->o_valid);
 }
 
 static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src)
 {
 
        CDEBUG(D_INODE, "flags %x\n", src->o_valid);
+       if ( src->o_valid & OBD_MD_FLID )
+               dst->i_ino = src->o_id;
+       if ( src->o_valid & OBD_MD_FLATIME ) 
+               dst->i_atime = src->o_atime;
+       if ( src->o_valid & OBD_MD_FLMTIME ) 
+               dst->i_mtime = src->o_mtime;
+       if ( src->o_valid & OBD_MD_FLCTIME ) 
+               dst->i_ctime = src->o_ctime;
+       if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */
+               dst->i_blocks = src->o_blocks;
+       if ( src->o_valid & OBD_MD_FLBLKSZ )
+               dst->i_blksize = src->o_blksize;
        if ( src->o_valid & OBD_MD_FLMODE ) 
                dst->i_mode = src->o_mode;
        if ( src->o_valid & OBD_MD_FLUID ) 
        if ( src->o_valid & OBD_MD_FLMODE ) 
                dst->i_mode = src->o_mode;
        if ( src->o_valid & OBD_MD_FLUID ) 
@@ -275,18 +299,8 @@ static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src)
                dst->i_gid = src->o_gid;
        if ( src->o_valid & OBD_MD_FLSIZE ) 
                dst->i_size = src->o_size;
                dst->i_gid = src->o_gid;
        if ( src->o_valid & OBD_MD_FLSIZE ) 
                dst->i_size = src->o_size;
-       if ( src->o_valid & OBD_MD_FLATIME ) 
-               dst->i_atime = src->o_atime;
-       if ( src->o_valid & OBD_MD_FLMTIME ) 
-               dst->i_mtime = src->o_mtime;
-       if ( src->o_valid & OBD_MD_FLCTIME ) 
-               dst->i_ctime = src->o_ctime;
        if ( src->o_valid & OBD_MD_FLFLAGS ) 
                dst->i_flags = src->o_flags;
        if ( src->o_valid & OBD_MD_FLFLAGS ) 
                dst->i_flags = src->o_flags;
-       /* allocation of space */
-       if ( src->o_valid & OBD_MD_FLBLOCKS ) 
-               dst->i_blocks = src->o_blocks;
-
 }
 
 static __inline__ int obdo_cmp_md(struct obdo *dst, struct obdo *src)
 }
 
 static __inline__ int obdo_cmp_md(struct obdo *dst, struct obdo *src)
index bc075e9..153002f 100644 (file)
@@ -74,21 +74,15 @@ extern int obd_print_entry;
        }
 
 #define ODEBUG(obdo) { \
        }
 
 #define ODEBUG(obdo) { \
-               printk("]]%s line %d[[  id %Ld, atm %Ld, mtim %Ld, ctm %Ld, size %Ld, blocks %Ld\n",\
+               printk("]]%s line %d[[  id %Ld, atm %Ld, mtm %Ld, ctm %Ld, size %Ld, blocks %Ld\n",\
                       __FUNCTION__ , __LINE__, \
                       __FUNCTION__ , __LINE__, \
-                      obdo->o_ino, obdo->o_atime, obdo->o_mtime,\
+                      obdo->o_id, obdo->o_atime, obdo->o_mtime,\
                       obdo->o_ctime, obdo->o_size, obdo->o_blocks);\
                       obdo->o_ctime, obdo->o_size, obdo->o_blocks);\
-               printk("]]%s line %d[[  mode %o, uid %d, gid %d, flg %0x, obdflg %0x, nlnk %d, valid %0x\n", \
+               printk("]]%s line %d[[  mode %o, uid %d, gid %d, flg %0xld, obdflg %0xld, nlnk %d, valid %0xld\n", \
                       __FUNCTION__ , __LINE__, \
                       obdo->o_mode, obdo->o_uid, obdo->o_gid,\
                       obdo->o_flags, obdo->o_obdflags, obdo->o_nlink,\
                       obdo->o_valid);\
                       __FUNCTION__ , __LINE__, \
                       obdo->o_mode, obdo->o_uid, obdo->o_gid,\
                       obdo->o_flags, obdo->o_obdflags, obdo->o_nlink,\
                       obdo->o_valid);\
-               printk("blk: %d %d %d %d %d %d %d %d %d %d\n",\
-                      ((long)obdo->o_inline)[0], ((long)obdo->o_inline)[1],\
-                      ((long)obdo->o_inline)[2], ((long)obdo->o_inline)[3],\
-                      ((long)obdo->o_inline)[4], ((long)obdo->o_inline)[5],\
-                      ((long)obdo->o_inline)[6], ((long)obdo->o_inline)[7],\
-                      ((long)obdo->o_inline)[8], ((long)obdo->o_inline)[9]);\
        }
 
 
        }
 
 
index 3208e8c..a64e9ef 100644 (file)
@@ -189,22 +189,19 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        return -EBUSY;
                }
 
                        return -EBUSY;
                }
 
-               ENTRY;
                /* get data structures */
                /* get data structures */
-               err = copy_from_user(&input, (void *)arg, sizeof(input));
+               err = copy_from_user(input, (void *)arg, sizeof(*input));
                if ( err ) {
                        EXIT;
                        return err;
                }
 
                if ( err ) {
                        EXIT;
                        return err;
                }
 
-               ENTRY;
                err = getdata(input->att_typelen + 1, &input->att_type);
                if ( err ) {
                        EXIT;
                        return err;
                }
 
                err = getdata(input->att_typelen + 1, &input->att_type);
                if ( err ) {
                        EXIT;
                        return err;
                }
 
-               ENTRY;
                /* find the type */
                type = obd_nm_to_type(input->att_type);
                OBD_FREE(input->att_type, input->att_typelen + 1);
                /* find the type */
                type = obd_nm_to_type(input->att_type);
                OBD_FREE(input->att_type, input->att_typelen + 1);
@@ -292,8 +289,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                struct ioc_setup {
                        int setup_datalen;
                        void *setup_data;
                struct ioc_setup {
                        int setup_datalen;
                        void *setup_data;
-               } *input;
-               input = karg;
+               } *setup;
+               setup = karg;
 
                ENTRY;
                /* have we attached a type to this device */
 
                ENTRY;
                /* have we attached a type to this device */
@@ -312,13 +309,13 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                }
 
                /* get main structure */
                }
 
                /* get main structure */
-               err = copy_from_user(&input, (void *) arg, sizeof(input));
+               err = copy_from_user(setup, (void *) arg, sizeof(*setup));
                if (err) {
                        EXIT;
                        return err;
                }
 
                if (err) {
                        EXIT;
                        return err;
                }
 
-               err = getdata(input->setup_datalen, &input->setup_data);
+               err = getdata(setup->setup_datalen, &setup->setup_data);
                if (err) {
                        EXIT;
                        return err;
                if (err) {
                        EXIT;
                        return err;
@@ -336,8 +333,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        return 0;
                }
 
                        return 0;
                }
 
-               err = OBP(obddev, setup)(obddev, input->setup_datalen,
-                                        input->setup_data);
+               err = OBP(obddev, setup)(obddev, setup->setup_datalen,
+                                        setup->setup_data);
 
                if ( err )  {
                        obddev->obd_flags &= ~OBD_SET_UP;
 
                if ( err )  {
                        obddev->obd_flags &= ~OBD_SET_UP;
@@ -427,12 +424,12 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 
                /* XXX sync needs to be done */
        case OBD_IOC_SYNC: {
 
                /* XXX sync needs to be done */
        case OBD_IOC_SYNC: {
-               struct oic_range_s *foo = karg;
+               struct oic_range_s *range = karg;
 
                if (!obddev->obd_type)
                        return -ENODEV;
 
 
                if (!obddev->obd_type)
                        return -ENODEV;
 
-               err = copy_from_user(&foo, (const void *)arg,  sizeof(foo));
+               err = copy_from_user(range, (const void *)arg,  sizeof(*range));
                if (err) {
                        EXIT;
                        return err;
                if (err) {
                        EXIT;
                        return err;
@@ -441,9 +438,9 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                return put_user(err, (int *) arg);
        }
        case OBD_IOC_CREATE: {
                return put_user(err, (int *) arg);
        }
        case OBD_IOC_CREATE: {
-               struct oic_attr_s *foo = karg;
+               struct oic_attr_s *attr = karg;
 
 
-               err = copy_from_user(&foo, (const void *)arg,  sizeof(foo));
+               err = copy_from_user(attr, (const void *)arg,  sizeof(*attr));
                if (err) {
                        EXIT;
                        return err;
                if (err) {
                        EXIT;
                        return err;
@@ -455,30 +452,30 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        CDEBUG(D_IOCTL, "Device not attached or set up\n");
                        return -ENODEV;
                }
                        CDEBUG(D_IOCTL, "Device not attached or set up\n");
                        return -ENODEV;
                }
-               conn.oc_id = foo->conn_id;
+               conn.oc_id = attr->conn_id;
 
                if ( !OBT(obddev) || !OBP(obddev, create) )
                        return -EOPNOTSUPP;
 
 
                if ( !OBT(obddev) || !OBP(obddev, create) )
                        return -EOPNOTSUPP;
 
-               err = OBP(obddev, create)(&conn, &foo->obdo);
+               err = OBP(obddev, create)(&conn, &attr->obdo);
                if (err) {
                        EXIT;
                        return err;
                }
 
                if (err) {
                        EXIT;
                        return err;
                }
 
-               err = copy_to_user((int *)arg, &foo, sizeof(foo));
+               err = copy_to_user((int *)arg, attr, sizeof(*attr));
                EXIT;
                return err;
        }
 
        case OBD_IOC_DESTROY: {
                EXIT;
                return err;
        }
 
        case OBD_IOC_DESTROY: {
-               struct oic_attr_s *foo = karg;
+               struct oic_attr_s *attr = karg;
                
                /* has this minor been registered? */
                if (!obddev->obd_type)
                        return -ENODEV;
 
                
                /* has this minor been registered? */
                if (!obddev->obd_type)
                        return -ENODEV;
 
-               err = copy_from_user(&foo, (int *)arg, sizeof(*foo));
+               err = copy_from_user(attr, (int *)arg, sizeof(*attr));
                if ( err ) {
                        EXIT;
                        return err;
                if ( err ) {
                        EXIT;
                        return err;
@@ -487,47 +484,47 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                if ( !OBT(obddev) || !OBP(obddev, destroy) )
                        return -EOPNOTSUPP;
 
                if ( !OBT(obddev) || !OBP(obddev, destroy) )
                        return -EOPNOTSUPP;
 
-               conn.oc_id = foo->conn_id;
-               err = OBP(obddev, destroy)(&conn, &foo->obdo);
+               conn.oc_id = attr->conn_id;
+               err = OBP(obddev, destroy)(&conn, &attr->obdo);
                EXIT;
                return err;
        }
 
        case OBD_IOC_SETATTR: {
                EXIT;
                return err;
        }
 
        case OBD_IOC_SETATTR: {
-               struct oic_attr_s *foo = karg;
+               struct oic_attr_s *attr = karg;
 
                /* has this minor been registered? */
                if (!obddev->obd_type)
                        return -ENODEV;
 
 
                /* has this minor been registered? */
                if (!obddev->obd_type)
                        return -ENODEV;
 
-               err = copy_from_user(&foo, (int *)arg, sizeof(foo));
+               err = copy_from_user(attr, (int *)arg, sizeof(*attr));
                if (err)
                        return err;
 
                if ( !OBT(obddev) || !OBP(obddev, setattr) )
                        return -EOPNOTSUPP;
                
                if (err)
                        return err;
 
                if ( !OBT(obddev) || !OBP(obddev, setattr) )
                        return -EOPNOTSUPP;
                
-               conn.oc_id = foo->conn_id;
-               err = OBP(obddev, setattr)(&conn, &foo->obdo);
+               conn.oc_id = attr->conn_id;
+               err = OBP(obddev, setattr)(&conn, &attr->obdo);
                EXIT;
                return err;
        }
 
        case OBD_IOC_GETATTR: {
                EXIT;
                return err;
        }
 
        case OBD_IOC_GETATTR: {
-               struct oic_attr_s *foo = karg;
+               struct oic_attr_s *attr = karg;
 
 
-               err = copy_from_user(&foo, (int *)arg, sizeof(foo));
+               err = copy_from_user(attr, (int *)arg, sizeof(*attr));
                if (err)
                        return err;
 
                if (err)
                        return err;
 
-               conn.oc_id = foo->conn_id;
-               err = OBP(obddev, getattr)(&conn, &foo->obdo);
+               conn.oc_id = attr->conn_id;
+               err = OBP(obddev, getattr)(&conn, &attr->obdo);
                if ( err ) {
                        EXIT;
                        return err;
                }
 
                if ( err ) {
                        EXIT;
                        return err;
                }
 
-               err = copy_to_user((int *)arg, &foo, sizeof(foo));
+               err = copy_to_user((int *)arg, attr, sizeof(*attr));
                EXIT;
                return err;
        }
                EXIT;
                return err;
        }
@@ -536,7 +533,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                int err;
                struct oic_rw_s *rw_s = karg;  /* read, write ioctl str */
 
                int err;
                struct oic_rw_s *rw_s = karg;  /* read, write ioctl str */
 
-               err = copy_from_user(&rw_s, (int *)arg, sizeof(rw_s));
+               err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
                if ( err ) {
                        EXIT;
                        return err;
                if ( err ) {
                        EXIT;
                        return err;
@@ -565,7 +562,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 */
 
        case OBD_IOC_WRITE: {
                struct oic_rw_s *rw_s = karg;  /* read, write ioctl str */
 
-               err = copy_from_user(&rw_s, (int *)arg, sizeof(rw_s));
+               err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
                if ( err ) {
                        EXIT;
                        return err;
                if ( err ) {
                        EXIT;
                        return err;
@@ -596,7 +593,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                if (!obddev->obd_type)
                        return -ENODEV;
 
                if (!obddev->obd_type)
                        return -ENODEV;
 
-               err = copy_from_user(&prealloc, (int *)arg, sizeof(prealloc));
+               err = copy_from_user(prealloc, (int *)arg, sizeof(*prealloc));
                if (err) 
                        return -EFAULT;
 
                if (err) 
                        return -EFAULT;
 
@@ -617,7 +614,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        return err;
                }
 
                        return err;
                }
 
-               err =copy_to_user((int *)arg, &prealloc, sizeof(prealloc));
+               err =copy_to_user((int *)arg, prealloc, sizeof(*prealloc));
                EXIT;
                return err;
        }
                EXIT;
                return err;
        }
@@ -657,7 +654,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                }
 
                /* get main structure */
                }
 
                /* get main structure */
-               err = copy_from_user(&mvdata, (void *) arg, sizeof(*mvdata));
+               err = copy_from_user(mvdata, (void *) arg, sizeof(*mvdata));
                if (err) {
                        EXIT;
                        return err;
                if (err) {
                        EXIT;
                        return err;
@@ -688,13 +685,13 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        return -ENODEV;
                }
 
                        return -ENODEV;
                }
 
-               err = copy_from_user(&mvdata, (void *) arg, sizeof(*mvdata));
+               err = copy_from_user(mvdata, (void *) arg, sizeof(*mvdata));
                if (err) {
                        EXIT;
                        return err;
                }
 
                if (err) {
                        EXIT;
                        return err;
                }
 
-               CDEBUG(D_IOCTL, "Migrate copying %d\n", sizeof(mvdata));
+               CDEBUG(D_IOCTL, "Migrate copying %d\n", sizeof(*mvdata));
 
                if ( !OBT(obddev) || !OBP(obddev, migrate) )
                        return -EOPNOTSUPP;
 
                if ( !OBT(obddev) || !OBP(obddev, migrate) )
                        return -EOPNOTSUPP;
index 6a755aa..f8fbfc9 100755 (executable)
@@ -73,13 +73,14 @@ eval 'sub OBD_SNAP_RESTORE() { &_IOC(3, ord(\'f\'), 43, 4);}' unless
 eval 'sub OBD_EXT2_RUNIT () { &_IOC(3, ord(\'f\'), 61, 4);}' unless
   defined(&OBD_EXT2_RUNIT);
 
 eval 'sub OBD_EXT2_RUNIT () { &_IOC(3, ord(\'f\'), 61, 4);}' unless
   defined(&OBD_EXT2_RUNIT);
 
-eval 'sub ATTR_MODE () {1;}' unless defined(&ATTR_MODE);
-eval 'sub ATTR_UID () {2;}' unless defined(&ATTR_UID);
-eval 'sub ATTR_GID () {4;}' unless defined(&ATTR_GID);
-eval 'sub ATTR_SIZE () {8;}' unless defined(&ATTR_SIZE);
-eval 'sub ATTR_ATIME () {16;}' unless defined(&ATTR_ATIME);
-eval 'sub ATTR_MTIME () {32;}' unless defined(&ATTR_MTIME);
-eval 'sub ATTR_CTIME () {64;}' unless defined(&ATTR_CTIME);
+eval 'sub OBD_MD_FLALL   () {~0;}'   unless defined(&OBD_MD_FLALL);
+eval 'sub OBD_MD_FLATIME () {1<<1;}' unless defined(&OBD_MD_FLATIME);
+eval 'sub OBD_MD_FLMTIME () {1<<2;}' unless defined(&OBD_MD_FLMTIME);
+eval 'sub OBD_MD_FLCTIME () {1<<3;}' unless defined(&OBD_MD_FLCTIME);
+eval 'sub OBD_MD_FLSIZE  () {1<<4;}' unless defined(&OBD_MD_FLSIZE);
+eval 'sub OBD_MD_FLMODE  () {1<<7;}' unless defined(&OBD_MD_FLMODE);
+eval 'sub OBD_MD_FLUID   () {1<<8;}' unless defined(&OBD_MD_FLUID);
+eval 'sub OBD_MD_FLGID   () {1<<9;}' unless defined(&OBD_MD_FLGID);
 
 use Getopt::Long;
 use File::stat;
 
 use Getopt::Long;
 use File::stat;
@@ -171,7 +172,7 @@ sub obdo_print {
 
     my $obdo = shift;
 
 
     my $obdo = shift;
 
-    printf "id: %d\ngrp: %d\natime: %s\nmtime: %s\nctime: %s\nsize: %d\nblocks: %d\nblksize: %d\nmode: %x\nuid: %d\ngid: %d\nflags: %x\nobdflags: %x\nnlink: %d\nvalid: %x\ninline: %s\nobdmd: %s\n", 
+    printf "id: %d\ngrp: %d\natime: %s\nmtime: %s\nctime: %s\nsize: %d\nblocks: %d\nblksize: %d\nmode: %o\nuid: %d\ngid: %d\nflags: %x\nobdflags: %x\nnlink: %d\nvalid: %x\ninline: %s\nobdmd: %s\n",
     $obdo->{id},
     $obdo->{gr},
     $obdo->{atime},
     $obdo->{id},
     $obdo->{gr},
     $obdo->{atime},
@@ -185,8 +186,8 @@ sub obdo_print {
     $obdo->{gid},
     $obdo->{flags},
     $obdo->{obdflags},
     $obdo->{gid},
     $obdo->{flags},
     $obdo->{obdflags},
-    $obdo->{nlink},    
-    $obdo->{valid},    
+    $obdo->{nlink},
+    $obdo->{valid},
     $obdo->{inline},
     $obdo->{obdmd};
 }
     $obdo->{inline},
     $obdo->{obdmd};
 }
@@ -384,7 +385,8 @@ usage:
        $data = pack("iii", $snapdev, $snapidx, $tableno);
        $datalen = 3 * 4;
     } elsif ($type eq "ext2_obd") {
        $data = pack("iii", $snapdev, $snapidx, $tableno);
        $datalen = 3 * 4;
     } elsif ($type eq "ext2_obd") {
-       1;
+       $data = pack("i", 4711);   # bogus data
+       $datalen = 0;
     } else {
        print "error: unknown attach type $type\n";
        goto usage;
     } else {
        print "error: unknown attach type $type\n";
        goto usage;
@@ -938,8 +940,8 @@ sub Create {
        print "Creating 1 object...\n";
        $rc = ioctl(DEV_OBD, &OBD_IOC_CREATE, $packed);
        if (!defined($quiet)) {
        print "Creating 1 object...\n";
        $rc = ioctl(DEV_OBD, &OBD_IOC_CREATE, $packed);
        if (!defined($quiet)) {
-           my $ino = unpack("L", $packed);
-           print "Created object #$ino.\n";
+           my $obdo = obdo_unpack($packed, 4);
+           print "Created object #$obdo->{id}.\n";
        }
     } else {
        my $i;
        }
     } else {
        my $i;
@@ -989,7 +991,7 @@ sub Destroy {
     my $arg = shift;
 
     if (!defined($arg) || scalar($arg) < 1) {
     my $arg = shift;
 
     if (!defined($arg) || scalar($arg) < 1) {
-       print "destroy requires the object number to destroy.\n";
+       print "usage: destroy <object number>\n";
        return;
     }
 
        return;
     }
 
@@ -1022,6 +1024,7 @@ sub Getattr {
     # see Setattr
     my $obdo;
     $obdo->{id} = $inode;
     # see Setattr
     my $obdo;
     $obdo->{id} = $inode;
+    $obdo->{valid} = &OBD_MD_FLALL;
     my $packed = pack("L", $::client_id) . obdo_pack($obdo);
     my $rc = ioctl(DEV_OBD, &OBD_IOC_GETATTR, $packed);
 
     my $packed = pack("L", $::client_id) . obdo_pack($obdo);
     my $rc = ioctl(DEV_OBD, &OBD_IOC_GETATTR, $packed);
 
@@ -1043,58 +1046,48 @@ sub Setattr {
     }
 
     my $inode = shift;
     }
 
     my $inode = shift;
-    my $valid = 0;
-    my $mode = oct(shift);
-    my $uid = shift;
-    my $gid = shift;
-    my $size = shift;
-    my $atime = shift;
-    my $mtime = shift;
-    my $ctime = shift;
 
 
-    if (defined($uid)) {
-       $valid |= &ATTR_UID;
+    if (!defined($inode) || scalar($inode) < 1) {
+       print "invalid arguments; type \"help setattr\" for a synopsis\n";
+       return;
     }
     }
-    if (defined($gid)) {
-       $valid |= &ATTR_GID;
+
+    # XXX we do not currently set all of the fields in the obdo
+    my $obdo;
+    $obdo->{id} = $inode;
+    $obdo->{mode} = oct(shift);
+    $obdo->{uid} = shift;
+    $obdo->{gid} = shift;
+    $obdo->{size} = shift;
+    $obdo->{atime} = shift;
+    $obdo->{mtime} = shift;
+    $obdo->{ctime} = shift;
+    $obdo->{valid} = 0;
+
+    if (defined($obdo->{atime})) {
+       $obdo->{valid} |= &OBD_MD_FLATIME;
     }
     }
-    if (defined($size)) {
-       $valid |= &ATTR_SIZE;
+    if (defined($obdo->{mtime})) {
+       $obdo->{valid} |= &OBD_MD_FLMTIME;
     }
     }
-    if (defined($atime)) {
-       $valid |= &ATTR_ATIME;
+    if (defined($obdo->{ctime})) {
+       $obdo->{valid} |= &OBD_MD_FLCTIME;
     }
     }
-    if (defined($mtime)) {
-       $valid |= &ATTR_MTIME;
+    if (defined($obdo->{size})) {
+       $obdo->{valid} |= &OBD_MD_FLSIZE;
     }
     }
-    if (defined($ctime)) {
-       $valid |= &ATTR_CTIME;
+    if (defined($obdo->{mode})) {
+       $obdo->{valid} |= &OBD_MD_FLMODE;
     }
     }
-    if (defined($mode)) {
-       $valid |= &ATTR_MODE;
+    if (defined($obdo->{uid})) {
+       $obdo->{valid} |= &OBD_MD_FLUID;
     }
     }
-
-    if (!defined($inode) || scalar($inode) < 1) {
-       print "invalid arguments; type \"help setattr\" for a synopsis\n";
-       return;
+    if (defined($obdo->{gid})) {
+       $obdo->{valid} |= &OBD_MD_FLGID;
     }
 
     }
 
-    #struct iattr {
-    #        unsigned int    ia_valid; (32)
-    #        umode_t         ia_mode; (16)
-    #        uid_t           ia_uid; (16)
-    #        gid_t           ia_gid; (16)
-    # -- 16 bit alignment here! --
-    #        off_t           ia_size; (32)
-    #        time_t          ia_atime; (32)
-    #        time_t          ia_mtime; (32)
-    #        time_t          ia_ctime; (32)
-    #        unsigned int    ia_attr_flags; (32)
-    #};
-
-    printf "valid is %x, mode is %o\n", $valid, $mode;
-    my $packed = pack("ILLSssx2ILLLL", $::client_id, $inode, $valid, $mode,
-                     $uid, $gid, $size, $atime, $mtime, $ctime, 0);
+    printf "valid is %x, mode is %o\n", $obdo->{valid}, $obdo->{mode};
+    my $packed = pack("L", $::client_id) . obdo_pack($obdo);
     my $rc = ioctl(DEV_OBD, &OBD_IOC_SETATTR, $packed);
 
     if (!defined $rc) {
     my $rc = ioctl(DEV_OBD, &OBD_IOC_SETATTR, $packed);
 
     if (!defined $rc) {
index eb60ab1..173d49c 100644 (file)
@@ -5,6 +5,6 @@
 include ../config.mk
 
 MODULE = obdfs.o
 include ../config.mk
 
 MODULE = obdfs.o
-CFILES= flush.c file.c dir.c sysctl.c super.c rw.c namei.c symlink.c
+CFILES=file.c dir.c sysctl.c super.c rw.c namei.c symlink.c # flushd.c 
 
 include ../make.rules
 
 include ../make.rules
index b16a5ef..86065bd 100644 (file)
@@ -454,19 +454,25 @@ int obdfs_create (struct inode * dir, struct dentry * dentry, int mode)
        struct page *page;
        struct ext2_dir_entry_2 * de;
        int err = -EIO;
        struct page *page;
        struct ext2_dir_entry_2 * de;
        int err = -EIO;
-       obd_id id;
+       struct obdo *oa;
 
         ENTRY;
 
 
         ENTRY;
 
-       /*
-        * N.B. Several error exits in ext2_new_inode don't set err.
-        */
-       err = iops(dir)->o_create(iid(dir), 0, &id);
+       oa = obdo_alloc(oa);
+       if (!oa) {
+               EXIT;
+               return -ENOMEM;
+       }
+
+       err = IOPS(dir, create)(IID(dir), 0, oa);
+
        if ( err ) 
                return err;
        if ( err ) 
                return err;
-       inode =  iget(dir->i_sb, (ino_t)id);
+       obdo_to_inode(inode, oa);
+       inode = iget(dir->i_sb, inode->i_ino);
        if (!inode || !list_empty(&inode->i_dentry)) {
        if (!inode || !list_empty(&inode->i_dentry)) {
-               CDEBUG(D_INODE, "No inode, ino %ld\n", id);
+               CDEBUG(D_INODE, "No inode, ino %ld\n", inode->i_ino);
+               obdo_free(oa);
                EXIT;
                return -EIO;
        }
                EXIT;
                return -EIO;
        }
@@ -474,18 +480,23 @@ int obdfs_create (struct inode * dir, struct dentry * dentry, int mode)
        inode->i_op = &obdfs_file_inode_operations;
        inode->i_mode = mode;
        mark_inode_dirty(inode);
        inode->i_op = &obdfs_file_inode_operations;
        inode->i_mode = mode;
        mark_inode_dirty(inode);
-       page = obdfs_add_entry (dir, dentry->d_name.name, dentry->d_name.len, &de, &err);
+       page = obdfs_add_entry (dir, dentry->d_name.name, dentry->d_name.len,
+                               &de, &err);
        if (!page) {
                inode->i_nlink--;
                mark_inode_dirty(inode);
                iput (inode);
        if (!page) {
                inode->i_nlink--;
                mark_inode_dirty(inode);
                iput (inode);
+               obdo_free(oa);
                EXIT;
                return err;
        }
        de->inode = cpu_to_le32(inode->i_ino);
        ext2_set_de_type(dir->i_sb, de, S_IFREG);
        dir->i_version = ++event;
                EXIT;
                return err;
        }
        de->inode = cpu_to_le32(inode->i_ino);
        ext2_set_de_type(dir->i_sb, de, S_IFREG);
        dir->i_version = ++event;
-       iops(dir)->o_brw(WRITE, iid(dir), dir, page, 0);
+       oa->o_id = dir->i_ino; /* Note: this is a different OA than above */
+       err = IOPS(dir, brw)(WRITE, IID(dir), oa, (char *)page_address(page),
+                            PAGE_SIZE, (page->index) << PAGE_SHIFT, 0);
+       obdo_free(oa);
        UnlockPage(page);
 #if 0
        if (IS_SYNC(dir)) {
        UnlockPage(page);
 #if 0
        if (IS_SYNC(dir)) {
@@ -504,33 +515,42 @@ int obdfs_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev)
        struct inode * inode;
        struct page *page;
        struct ext2_dir_entry_2 * de;
        struct inode * inode;
        struct page *page;
        struct ext2_dir_entry_2 * de;
+       struct obdo *oa;
        int err;
 
        int err;
 
-       obd_id id;
-
         ENTRY;
 
         ENTRY;
 
-       /*
-        * N.B. Several error exits in ext2_new_inode don't set err.
-        */
-       err = iops(dir)->o_create(iid(dir), 0, &id);
+       oa = obdo_alloc();
+       if (!oa) {
+               EXIT;
+               return -ENOMEM;
+       }
+       err = IOPS(dir, create)(IID(dir), 0, oa);
        if ( err ) 
                return err;
        if ( err ) 
                return err;
-       inode =  iget(dir->i_sb, (ino_t)id);
-       if (!inode)
+       obdo_to_inode(inode, oa);
+       inode = iget(dir->i_sb, inode->i_ino);
+       if (!inode) {
+               obdo_free(oa);
+               EXIT;
                return -EIO;
                return -EIO;
+       }
 
        inode->i_uid = current->fsuid;
        init_special_inode(inode, mode, rdev);
 
        inode->i_uid = current->fsuid;
        init_special_inode(inode, mode, rdev);
-       page = obdfs_add_entry (dir, dentry->d_name.name, dentry->d_name.len, &de, &err);
+       page = obdfs_add_entry (dir, dentry->d_name.name, dentry->d_name.len,
+                               &de, &err);
        if (!page)
                goto out_no_entry;
        de->inode = cpu_to_le32(inode->i_ino);
        dir->i_version = ++event;
        ext2_set_de_type(dir->i_sb, de, inode->i_mode);
        mark_inode_dirty(inode);
        if (!page)
                goto out_no_entry;
        de->inode = cpu_to_le32(inode->i_ino);
        dir->i_version = ++event;
        ext2_set_de_type(dir->i_sb, de, inode->i_mode);
        mark_inode_dirty(inode);
-       iops(dir)->o_brw(WRITE, iid(dir), dir, page, 0);
+       oa->o_id = dir->i_ino; /* Note: this is a different OA than above */
+       err = IOPS(dir, brw)(WRITE, IID(dir), oa, (char *)page_address(page),
+                              PAGE_SIZE, (page->index) << PAGE_SHIFT, 0);
        UnlockPage(page);
        UnlockPage(page);
+       obdo_free(oa);
 
 #if 0
        if (IS_SYNC(dir)) {
 
 #if 0
        if (IS_SYNC(dir)) {
@@ -556,8 +576,8 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        struct inode * inode;
        struct page *page, *inode_page;
        struct ext2_dir_entry_2 * de;
        struct inode * inode;
        struct page *page, *inode_page;
        struct ext2_dir_entry_2 * de;
+       struct obdo *ioa, *doa;
        int err;
        int err;
-       obd_id id;
 
        ENTRY;
 
 
        ENTRY;
 
@@ -565,13 +585,30 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        if (dir->i_nlink >= EXT2_LINK_MAX)
                goto out;
 
        if (dir->i_nlink >= EXT2_LINK_MAX)
                goto out;
 
-       err = iops(dir)->o_create(iid(dir), 0, &id);
-       if ( err ) 
+       ioa = obdo_alloc();
+       if (!ioa) {
+               EXIT;
+               return -ENOMEM;
+       }
+       doa = obdo_alloc();
+       if (!ioa) {
+               EXIT;
+               return -ENOMEM;
+       }
+
+       err = IOPS(dir, create)(IID(dir), 0, ioa);
+       if ( err ) {
+               obdo_free(oa);
+               EXIT;
                return err;
                return err;
-       inode =  iget(dir->i_sb, (ino_t)id);
-       if (!inode)
+       }
+       obdo_to_inode(inode, ioa);
+       inode = iget(dir->i_sb, inode->i_ino);
+       if (!inode) {
+               obdo_free(oa);
+               EXIT;
                return -EIO;
                return -EIO;
-
+       }
 
        inode->i_op = &obdfs_dir_inode_operations;
        inode->i_blocks = 0;    
 
        inode->i_op = &obdfs_dir_inode_operations;
        inode->i_blocks = 0;    
@@ -580,6 +617,7 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
                inode->i_nlink--; /* is this nlink == 0? */
                mark_inode_dirty(inode);
                iput (inode);
                inode->i_nlink--; /* is this nlink == 0? */
                mark_inode_dirty(inode);
                iput (inode);
+               obdo_free(oa);
                return err;
        }
 
                return err;
        }
 
@@ -598,7 +636,13 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        strcpy (de->name, "..");
        ext2_set_de_type(dir->i_sb, de, S_IFDIR);
        
        strcpy (de->name, "..");
        ext2_set_de_type(dir->i_sb, de, S_IFDIR);
        
-       iops(dir)->o_brw(WRITE, iid(dir), inode, inode_page, 1);
+       oa->o_id = dir->i_ino;
+       err = IOPS(dir, brw)(WRITE, IID(dir), oa, (char *)page_address(inode_page),
+                            PAGE_SIZE, (inode_page->index) << PAGE_SHIFT, 1);
+
+       obdo_to_inode(dir, doa); /* copy o_blocks to i_blocks */
+       obdo_free(doa);
+
        inode->i_blocks = PAGE_SIZE/inode->i_sb->s_blocksize;
        inode->i_size = PAGE_SIZE;
        UnlockPage(inode_page);
        inode->i_blocks = PAGE_SIZE/inode->i_sb->s_blocksize;
        inode->i_size = PAGE_SIZE;
        UnlockPage(inode_page);
index 558cfed..aa18c72 100644 (file)
@@ -39,7 +39,7 @@ int console_loglevel;
 #if 0
 int obdfs_brw(struct inode *dir, int rw, struct page *page, int create)
 {
 #if 0
 int obdfs_brw(struct inode *dir, int rw, struct page *page, int create)
 {
-       return iops(dir)->o_brw(rw, iid(dir), dir, page, create);
+       return IOPS(dir, brw)(rw, IID(dir), dir, page, create);
 }
 #endif
 
 }
 #endif
 
@@ -47,22 +47,33 @@ int obdfs_brw(struct inode *dir, int rw, struct page *page, int create)
 int obdfs_readpage(struct dentry *dentry, struct page *page)
 {
        struct inode *inode = dentry->d_inode;
 int obdfs_readpage(struct dentry *dentry, struct page *page)
 {
        struct inode *inode = dentry->d_inode;
-       struct obdfs_wreq *wreq;
-       int rc = 0;
+       struct obdo *oa;
+       int err;
 
         ENTRY;
        PDEBUG(page, "READ");
 
         ENTRY;
        PDEBUG(page, "READ");
-       rc =  iops(inode)->o_brw(READ, iid(inode),inode, page, 0);
-       if (rc == PAGE_SIZE ) {
+       oa = obdo_alloc();
+       if (!oa) {
+               printk("obdfs_readpage: obdo_alloc failure\n");
+               EXIT;
+               return -ENOMEM;
+       }
+
+       oa->o_id = inode->i_ino;
+       err = IOPS(inode, brw)(READ, IID(inode), oa, (char *)page_address(page),
+                              PAGE_SIZE, (page->index) << PAGE_SHIFT, 0);
+       obdo_to_inode(inode, oa); /* copy o_blocks to i_blocks */
+       obdo_free(oa);
+
+       if (err == PAGE_SIZE ) {
                SetPageUptodate(page);
                UnlockPage(page);
        } 
        PDEBUG(page, "READ");
                SetPageUptodate(page);
                UnlockPage(page);
        } 
        PDEBUG(page, "READ");
-       if ( rc == PAGE_SIZE ) 
-               rc = 0;
-       } 
+       if ( err == PAGE_SIZE ) 
+               err = 0;
        EXIT;
        EXIT;
-       return rc;
+       return err;
 }
 
 static kmem_cache_t *obdfs_wreq_cachep;
 }
 
 static kmem_cache_t *obdfs_wreq_cachep;
@@ -123,12 +134,22 @@ obdfs_remove_from_page_cache(struct obdfs_wreq *wreq)
 {
        struct inode *inode = wreq->wb_inode;
        struct page *page = wreq->wb_page;
 {
        struct inode *inode = wreq->wb_inode;
        struct page *page = wreq->wb_page;
-       int rc;
+       struct obdo *oa;
+       int err;
 
        ENTRY;
        CDEBUG(D_INODE, "removing inode %ld page %p, wreq: %p\n",
               inode->i_ino, page, wreq);
 
        ENTRY;
        CDEBUG(D_INODE, "removing inode %ld page %p, wreq: %p\n",
               inode->i_ino, page, wreq);
-       rc = iops(inode)->o_brw(WRITE, iid(inode), inode, page, 1);
+       oa = obdo_alloc();
+       if (!oa) {
+               printk("obdfs_remove_from_page_cache: obdo_alloc failure\n");
+               EXIT;
+               return -ENOMEM;
+       }
+       oa->o_id = inode->i_ino;
+       err = IOPS(inode, brw)(WRITE, IID(inode), oa,(char *)page_address(page),
+                              PAGE_SIZE, (page->index) << PAGE_SHIFT, 1);
+       obdo_to_inode(inode, oa); /* copy o_blocks to i_blocks */
        /* XXX probably should handle error here somehow.  I think that
         *     ext2 also does the same thing - discard write even if error?
         */
        /* XXX probably should handle error here somehow.  I think that
         *     ext2 also does the same thing - discard write even if error?
         */
@@ -137,7 +158,7 @@ obdfs_remove_from_page_cache(struct obdfs_wreq *wreq)
        kmem_cache_free(obdfs_wreq_cachep, wreq);
 
        EXIT;
        kmem_cache_free(obdfs_wreq_cachep, wreq);
 
        EXIT;
-       return rc;
+       return err;
 }
 
 /*
 }
 
 /*
@@ -182,17 +203,17 @@ obdfs_add_to_page_cache(struct inode *inode, struct page *page)
 int obdfs_writepage(struct dentry *dentry, struct page *page)
 {
         struct inode *inode = dentry->d_inode;
 int obdfs_writepage(struct dentry *dentry, struct page *page)
 {
         struct inode *inode = dentry->d_inode;
-       int rc;
+       int err;
 
         ENTRY;
        PDEBUG(page, "WRITEPAGE");
        /* XXX flush stuff */
 
         ENTRY;
        PDEBUG(page, "WRITEPAGE");
        /* XXX flush stuff */
-       rc = obdfs_add_to_page_cache(inode, page);
+       err = obdfs_add_to_page_cache(inode, page);
 
 
-       if (!rc)
+       if (!err)
                SetPageUptodate(page);
        PDEBUG(page,"WRITEPAGE");
                SetPageUptodate(page);
        PDEBUG(page,"WRITEPAGE");
-       return rc;
+       return err;
 }
 
 /*
 }
 
 /*
@@ -204,14 +225,28 @@ int obdfs_writepage(struct dentry *dentry, struct page *page)
  * If the writer ends up delaying the write, the writer needs to
  * increment the page use counts until he is done with the page.
  */
  * If the writer ends up delaying the write, the writer needs to
  * increment the page use counts until he is done with the page.
  */
-int obdfs_write_one_page(struct file *file, struct page *page, unsigned long offset, unsigned long bytes, const char * buf)
+int obdfs_write_one_page(struct file *file, struct page *page,
+                        unsigned long offset, unsigned long bytes,
+                        const char * buf)
 {
        long status;
         struct inode *inode = file->f_dentry->d_inode;
 
        ENTRY;
        if ( !Page_Uptodate(page) ) {
 {
        long status;
         struct inode *inode = file->f_dentry->d_inode;
 
        ENTRY;
        if ( !Page_Uptodate(page) ) {
-               status =  iops(inode)->o_brw(READ, iid(inode), inode, page, 1);
+               struct obdo *oa;
+               oa = obdo_alloc();
+               if (!oa) {
+                       printk("obdfs_write_one_page: obdo_alloc failure\n");
+                       EXIT;
+                       return -ENOMEM;
+               }
+               oa->o_id = inode->i_ino;
+               status = IOPS(inode, brw)(READ, IID(inode), oa,
+                                         (char *)page_address(page), PAGE_SIZE,                                          (page->index) << PAGE_SHIFT, 1);
+               obdo_to_inode(inode, oa); /* copy o_blocks to i_blocks */
+               obdo_free(oa);
+
                if (status == PAGE_SIZE ) {
                        SetPageUptodate(page);
                } else { 
                if (status == PAGE_SIZE ) {
                        SetPageUptodate(page);
                } else { 
@@ -253,12 +288,14 @@ void report_inode(struct page * page) {
 
    modeled on NFS code.
 */
 
    modeled on NFS code.
 */
-struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create, int locked)
+struct page *obdfs_getpage(struct inode *inode, unsigned long offset,
+                          int create, int locked)
 {
        struct page *page_cache;
        struct page ** hash;
        struct page * page;
 {
        struct page *page_cache;
        struct page ** hash;
        struct page * page;
-       int rc;
+       struct obdo *oa;
+       int err;
 
         ENTRY;
 
 
         ENTRY;
 
@@ -274,7 +311,7 @@ struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create
        hash = page_hash(&inode->i_data, offset);
        page = grab_cache_page(&inode->i_data, offset);
 
        hash = page_hash(&inode->i_data, offset);
        page = grab_cache_page(&inode->i_data, offset);
 
-       PDEBUG(page, "GETPAGE: got page - before reading\n");
+       PDEBUG(page, "obdfs_getpage: got page - before reading\n");
        /* now check if the data in the page is up to date */
        if ( Page_Uptodate(page)) { 
                if (!locked)
        /* now check if the data in the page is up to date */
        if ( Page_Uptodate(page)) { 
                if (!locked)
@@ -285,12 +322,24 @@ struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create
 
        /* it's not: read it */
        if (! page) {
 
        /* it's not: read it */
        if (! page) {
-           printk("get_page_map says no dice ...\n");
-           return 0;
+               printk("obdfs_getpage: says no dice ...\n");
+               return NULL;
        }
 
        }
 
-       rc = iops(inode)->o_brw(READ, iid(inode), inode, page, create);
-       if ( rc != PAGE_SIZE ) {
+       oa = obdo_alloc();
+       if (!oa) {
+               printk("obdfs_getpage: obdo_alloc failure\n");
+               EXIT;
+               return NULL;
+       }
+       oa->o_id = inode->i_ino;
+       err = IOPS(inode, brw)(READ, IID(inode), oa, (char *)page_address(page),
+                              PAGE_SIZE, (page->index) << PAGE_SHIFT, create);
+
+       obdo_to_inode(inode, oa); /* XXX to copy o_blocks */
+       obdo_free(oa);
+
+       if ( err != PAGE_SIZE ) {
                SetPageError(page);
                UnlockPage(page);
                return page;
                SetPageError(page);
                UnlockPage(page);
                return page;
index 293f265..5c663ea 100644 (file)
@@ -130,7 +130,6 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
         struct inode *root = 0; 
        struct obdfs_sb_info *sbi = (struct obdfs_sb_info *)(&sb->u.generic_sbp);
        struct obd_device *obddev;
         struct inode *root = 0; 
        struct obdfs_sb_info *sbi = (struct obdfs_sb_info *)(&sb->u.generic_sbp);
        struct obd_device *obddev;
-        int error = 0;
        char *device = NULL;
        char *version = NULL;
        int devno;
        char *device = NULL;
        char *version = NULL;
        int devno;
@@ -139,7 +138,6 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
        unsigned long blocksize_bits;
        unsigned long root_ino;
        int scratch;
        unsigned long blocksize_bits;
        unsigned long root_ino;
        int scratch;
-       
 
        ENTRY;
         MOD_INC_USE_COUNT; 
 
        ENTRY;
         MOD_INC_USE_COUNT; 
@@ -155,7 +153,7 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
        }
 
        if ( (err = obdfs_getdev(device, &devno)) ) {
        }
 
        if ( (err = obdfs_getdev(device, &devno)) ) {
-               printk("Cannot get devno of %s, error %d\n", device, err);
+               printk("Cannot get devno of %s, err %d\n", device, err);
                MOD_DEC_USE_COUNT;
                EXIT;
                return NULL;
                MOD_DEC_USE_COUNT;
                EXIT;
                return NULL;
@@ -190,44 +188,41 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
        sbi->osi_ops = sbi->osi_obd->obd_type->typ_ops;
        
        sbi->osi_conn.oc_dev = obddev;
        sbi->osi_ops = sbi->osi_obd->obd_type->typ_ops;
        
        sbi->osi_conn.oc_dev = obddev;
-        error  = sbi->osi_ops->o_connect(&sbi->osi_conn);
-       if ( error ) {
+        err  = sbi->osi_ops->o_connect(&sbi->osi_conn);
+       if ( err ) {
                printk("OBDFS: cannot connect to %s\n", device);
                printk("OBDFS: cannot connect to %s\n", device);
-               goto error;
+               goto ERR;
        }
 
        INIT_LIST_HEAD(&sbi->osi_list);
 
        sbi->osi_super = sb;
 
        }
 
        INIT_LIST_HEAD(&sbi->osi_list);
 
        sbi->osi_super = sb;
 
-       error = sbi->osi_ops->o_get_info(&sbi->osi_conn,
+       err = sbi->osi_ops->o_get_info(&sbi->osi_conn,
                                         strlen("blocksize"), 
                                         "blocksize", 
                                         &scratch, (void *)&blocksize);
                                         strlen("blocksize"), 
                                         "blocksize", 
                                         &scratch, (void *)&blocksize);
-       if ( error ) {
+       if ( err ) {
                printk("Getinfo call to drive failed (blocksize)\n");
                printk("Getinfo call to drive failed (blocksize)\n");
-               goto error;
+               goto ERR;
        }
 
        }
 
-       error = sbi->osi_ops->o_get_info(&sbi->osi_conn,
-                                        strlen("blocksize_bits"), 
-                                        "blocksize_bits", 
-                                        &scratch, (void *)&blocksize_bits);
-       if ( error ) {
+       err = sbi->osi_ops->o_get_info(&sbi->osi_conn, strlen("blocksize_bits"),
+                                      "blocksize_bits", &scratch,
+                                      (void *)&blocksize_bits);
+       if ( err ) {
                printk("Getinfo call to drive failed (blocksize_bits)\n");
                printk("Getinfo call to drive failed (blocksize_bits)\n");
-               goto error;
+               goto ERR;
        }
 
        }
 
-       error = sbi->osi_ops->o_get_info(&sbi->osi_conn,
+       err = sbi->osi_ops->o_get_info(&sbi->osi_conn,
                                         strlen("root_ino"), 
                                         "root_ino", 
                                         &scratch, (void *)&root_ino);
                                         strlen("root_ino"), 
                                         "root_ino", 
                                         &scratch, (void *)&root_ino);
-       if ( error ) {
+       if ( err ) {
                printk("Getinfo call to drive failed (root_ino)\n");
                printk("Getinfo call to drive failed (root_ino)\n");
-               goto error;
+               goto ERR;
        }
        }
-       
-
 
         lock_super(sb);
        
 
         lock_super(sb);
        
@@ -241,9 +236,9 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
         if (!root || is_bad_inode(root)) {
            printk("OBDFS: bad iget for root\n");
            sb->s_dev = 0;
         if (!root || is_bad_inode(root)) {
            printk("OBDFS: bad iget for root\n");
            sb->s_dev = 0;
-           error = ENOENT;
+           err = ENOENT;
            unlock_super(sb);
            unlock_super(sb);
-           goto error;
+           goto ERR;
        } 
        
 
        } 
        
 
@@ -256,7 +251,7 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
        EXIT;  
         return sb;
 
        EXIT;  
         return sb;
 
- error:
+ERR:
        EXIT;  
        MOD_DEC_USE_COUNT;
        if (sbi) {
        EXIT;  
        MOD_DEC_USE_COUNT;
        if (sbi) {
@@ -275,8 +270,6 @@ static void obdfs_put_super(struct super_block *sb)
         struct obdfs_sb_info *sbi;
 
         ENTRY;
         struct obdfs_sb_info *sbi;
 
         ENTRY;
-
-
         sb->s_dev = 0;
        
        /* XXX flush stuff */
         sb->s_dev = 0;
        
        /* XXX flush stuff */
@@ -295,16 +288,31 @@ static void obdfs_put_super(struct super_block *sb)
 /* all filling in of inodes postponed until lookup */
 void obdfs_read_inode(struct inode *inode)
 {
 /* all filling in of inodes postponed until lookup */
 void obdfs_read_inode(struct inode *inode)
 {
-       int error;
-       ENTRY;
+       struct obdo *oa;
+       int err;
 
 
-       error = IOPS(inode, getattr)(IID(inode), inode);
-       if (error) {
-               printk("obdfs_read_inode: obd_getattr fails (%d)\n", error);
+       ENTRY;
+       oa = obdo_alloc();
+       if (!oa) {
+               printk("obdfs_read_inode: obdo_alloc failed\n");
+               EXIT;
+               return;
+       }
+       oa->o_valid = OBD_MD_FLALL;
+       oa->o_id = inode->i_ino;
+       err = IOPS(inode, getattr)(IID(inode), oa);
+       if (err) {
+               printk("obdfs_read_inode: obd_getattr fails (%d)\n", err);
+               obdo_free(oa);
+               EXIT;
                return;
        }
                return;
        }
-       CDEBUG(D_INODE, "ino %ld, mode: %o\n", inode->i_ino, inode->i_mode);
+
+       ODEBUG(oa);
+       obdo_to_inode(inode, oa);
+       obdo_free(oa);
        IDEBUG(inode);
        IDEBUG(inode);
+
        if (S_ISREG(inode->i_mode))
                inode->i_op = &obdfs_file_inode_operations;
        else if (S_ISDIR(inode->i_mode))
        if (S_ISREG(inode->i_mode))
                inode->i_op = &obdfs_file_inode_operations;
        else if (S_ISDIR(inode->i_mode))
@@ -314,16 +322,24 @@ void obdfs_read_inode(struct inode *inode)
        else
                /* XXX what do we pass here??? */
                init_special_inode(inode, inode->i_mode, 0 /* XXX XXX */ );
        else
                /* XXX what do we pass here??? */
                init_special_inode(inode, inode->i_mode, 0 /* XXX XXX */ );
+
        return;
 }
 
 static void obdfs_write_inode(struct inode *inode) 
 {
        return;
 }
 
 static void obdfs_write_inode(struct inode *inode) 
 {
-       int error;
+       struct obdo *oa;
+       int err;
        
        
-       error = IOPS(inode, setattr)(IID(inode), inode);
-       if (error) {
-               printk("obdfs_write_inode: obd_setattr fails (%d)\n", error);
+       oa = obdo_alloc();
+       oa->o_valid = OBD_MD_FLALL;
+       obdo_from_inode(oa, inode);
+       err = IOPS(inode, setattr)(IID(inode), oa);
+
+       obdo_free(oa);
+
+       if (err) {
+               printk("obdfs_write_inode: obd_setattr fails (%d)\n", err);
                return;
        }
        
                return;
        }
        
@@ -332,38 +348,88 @@ static void obdfs_write_inode(struct inode *inode)
 
 static void obdfs_delete_inode(struct inode *inode)
 {
 
 static void obdfs_delete_inode(struct inode *inode)
 {
-       int error;
+       struct obdo *oa;
+       int err;
         ENTRY;
 
         ENTRY;
 
-       error = IOPS(inode, destroy)(IID(inode), inode);
-       if (error) {
-               printk("obdfs_delete_node: ibd_destroy fails (%d)\n", error);
+       oa = obdo_alloc();
+       /* XXX we currently assume "id" is all that's needed for destroy */
+       oa->o_id = inode->i_ino;
+       err = IOPS(inode, destroy)(IID(inode), oa);
+       obdo_free(oa);
+
+       if (err) {
+               printk("obdfs_delete_node: obd_destroy fails (%d)\n", err);
                return;
        }
 
        EXIT;
 }
 
                return;
        }
 
        EXIT;
 }
 
-static int  obdfs_notify_change(struct dentry *de, struct iattr *iattr)
+
+static void obdo_setattr(struct obdo *oa, struct iattr *attr)
+{
+       unsigned int ia_valid = attr->ia_valid;
+
+       if (ia_valid & ATTR_ATIME) {
+               oa->o_atime = attr->ia_atime;
+               oa->o_valid |= OBD_MD_FLATIME;
+       }
+       if (ia_valid & ATTR_MTIME) {
+               oa->o_mtime = attr->ia_mtime;
+               oa->o_valid |= OBD_MD_FLMTIME;
+       }
+       if (ia_valid & ATTR_CTIME) {
+               oa->o_ctime = attr->ia_ctime;
+               oa->o_valid |= OBD_MD_FLCTIME;
+       }
+       if (ia_valid & ATTR_SIZE) {
+               oa->o_size = attr->ia_size;
+               oa->o_valid |= OBD_MD_FLSIZE;
+       }
+       if (ia_valid & ATTR_MODE) {
+               oa->o_mode = attr->ia_mode;
+               oa->o_valid |= OBD_MD_FLMODE;
+               if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
+                       oa->o_mode &= ~S_ISGID;
+       }
+       if (ia_valid & ATTR_UID)
+       {
+               oa->o_uid = attr->ia_uid;
+               oa->o_valid |= OBD_MD_FLUID;
+       }
+       if (ia_valid & ATTR_GID) {
+               oa->o_gid = attr->ia_gid;
+               oa->o_valid |= OBD_MD_FLGID;
+       }
+}
+
+
+static int obdfs_notify_change(struct dentry *de, struct iattr *attr)
 {
        struct inode *inode = de->d_inode;
 {
        struct inode *inode = de->d_inode;
-       struct iattr saved_copy;
-       int error;
+       struct obdo *oa;
+       int err;
 
        ENTRY;
 
        ENTRY;
-       inode_to_iattr(inode, &saved_copy);
-
-       inode_setattr(inode, iattr);
-        error = IOPS(inode, setattr)(IID(inode), inode);
-       if ( error ) {
-               inode_setattr(inode, &saved_copy);
-               printk("obdfs_notify_change: obd_setattr fails (%d)\n", error);
-               return error;
+       oa = obdo_alloc();
+       if (!oa) {
+               printk("obdfs_notify_change: obdo_alloc fails\n");
+               return -ENOMEM;
        }
 
        }
 
+       oa->o_id = inode->i_ino;
+       obdo_setattr(oa, attr);
+        err = IOPS(inode, setattr)(IID(inode), oa);
+       if ( err ) {
+               printk("obdfs_notify_change: obd_setattr fails (%d)\n", err);
+               return err;
+       }
+       inode_setattr(inode, attr);
+
        CDEBUG(D_INODE, "inode blocks now %ld\n", inode->i_blocks);
        EXIT;
        CDEBUG(D_INODE, "inode blocks now %ld\n", inode->i_blocks);
        EXIT;
-        return error;
+        return err;
 }
 
 
 }
 
 
@@ -371,20 +437,20 @@ static int obdfs_statfs(struct super_block *sb, struct statfs *buf,
                       int bufsize)
 {
        struct statfs tmp;
                       int bufsize)
 {
        struct statfs tmp;
-       int error;
+       int err;
 
        ENTRY;
 
 
        ENTRY;
 
-       error = OPS(sb,statfs)(ID(sb), &tmp);
-       if ( error ) { 
-               printk("obdfs_notify_change: obd_statfs fails (%d)\n", error);
-               return error;
+       err = OPS(sb,statfs)(ID(sb), &tmp);
+       if ( err ) { 
+               printk("obdfs_notify_change: obd_statfs fails (%d)\n", err);
+               return err;
        }
        copy_to_user(buf, &tmp, (bufsize<sizeof(tmp)) ? bufsize : sizeof(tmp));
 
        EXIT;
 
        }
        copy_to_user(buf, &tmp, (bufsize<sizeof(tmp)) ? bufsize : sizeof(tmp));
 
        EXIT;
 
-       return error
+       return err; 
 }
 
 struct file_system_type obdfs_fs_type = {
 }
 
 struct file_system_type obdfs_fs_type = {