Whamcloud - gitweb
Changes to accomodate the snapshot features!
authorbraam <braam>
Wed, 24 Nov 1999 21:15:51 +0000 (21:15 +0000)
committerbraam <braam>
Wed, 24 Nov 1999 21:15:51 +0000 (21:15 +0000)
lustre/include/linux/obd_class.h
lustre/include/linux/obd_snap.h
lustre/include/linux/obd_support.h
lustre/include/linux/obdfs.h
lustre/obdfs/dir.c
lustre/obdfs/rw.c
lustre/obdfs/super.c

index c779efa..4f16f4f 100644 (file)
 
 
 #define OBD_PSDEV_MAJOR 120
-#define MAX_OBD_DEVICES 2
+#define MAX_OBD_DEVICES 8
 #define MAX_MULTI 16
 
-typedef int objid;
+typedef unsigned long   objid;
 typedef struct inode obdattr;
+#if 0
+struct obdattr {
+       objid                   oa_id;
+       umode_t                 oa_mode;
+       nlink_t                 oa_nlink;
+       uid_t                   oa_uid;
+       gid_t                   oa_gid;
+       off_t                   oa_size;
+       time_t                  oa_atime;
+       time_t                  oa_mtime;
+       time_t                  oa_ctime;
+       unsigned long           oa_blksize;
+       unsigned long           oa_blocks;
+       char                    oa_data[116];
+       struct obd_ops         *oa_op;
+};
+
+#endif
 
 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
 
+       
+
 
 
 #define OBD_ATTACHED 0x1
 #define OBD_SET_UP   0x2
 
+struct obd_conn {
+       struct obd_device *oc_dev;
+       unsigned int oc_id;
+};
+
 /* corresponds to one of the obdx */
 struct obd_device {
        struct obd_type *obd_type;
@@ -34,8 +59,7 @@ struct obd_device {
        int obd_flags;
        int obd_refcnt; 
        int obd_multi_count;
-       struct obd_device *obd_multi_dev[MAX_MULTI];
-       struct obd_conn_info obd_multi_conns[MAX_MULTI];
+       struct obd_conn obd_multi_conn[MAX_MULTI];
        unsigned int obd_gen_last_id;
        unsigned long obd_gen_prealloc_quota;
        struct list_head obd_gen_clients;
@@ -50,25 +74,28 @@ struct obd_device {
 
 struct obd_ops {
        int (*o_attach)(struct obd_device *, int len, void *);
+       int (*o_detach)(struct obd_device *);
        int (*o_format)(struct obd_device *, int len, void *);
        int (*o_partition)(struct obd_device *, int len, void *);
-       int (*o_connect)(struct obd_device *, struct obd_conn_info *info);
-       int (*o_disconnect)(unsigned int conn_id);
+       int (*o_connect)(struct obd_conn *conn);
+       int (*o_disconnect)(struct obd_conn *);
        int (*o_setup) (struct obd_device *dev, int len, void *data);
        int (*o_cleanup)(struct obd_device *dev);
-       int (*o_setattr)(unsigned int conn_id, unsigned long id, struct inode *iattr);
-       int (*o_getattr)(unsigned int conn_id, unsigned long id, struct inode *iattr);
-       int (*o_statfs)(unsigned int conn_id, struct statfs *statfs);
-       int (*o_create)(int conn_id, int prealloc_ino, int *er);
-       int (*o_destroy)(unsigned int conn_id, unsigned long ino);
-       unsigned long (*o_read)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
-       unsigned long (*o_read2)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
-       unsigned long (*o_write)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
-       int (*o_brw)(int rw, int conn, obdattr *obj, struct page *page, int create);
-       long (*o_preallocate)(unsigned int conn_id, int req, long inodes[32], int *err);
-       int (*o_cleanup_device)(struct obd_device *);
-       int  (*o_get_info)(unsigned int conn_id, int keylen, void *key, int *vallen, void **val);
-       int  (*o_set_info)(unsigned int conn_id, int keylen, void *key, int vallen, void *val);
+       int (*o_setattr)(struct obd_conn *, obdattr *oa);
+       int (*o_getattr)(struct obd_conn *, obdattr *oa);
+       int (*o_statfs)(struct obd_conn *, struct statfs *statfs);
+       int (*o_create)(struct obd_conn *, int prealloc_ino, int *er);
+       int (*o_destroy)(struct obd_conn *, obdattr *oa);
+       int (*o_read)(struct obd_conn *, obdattr *ino, char *buf, unsigned long *count, loff_t offset);
+       int (*o_read2)(struct obd_conn *, obdattr *oa, char *buf, unsigned long *count, loff_t offset);
+       int (*o_write)(struct obd_conn *, obdattr *oa, char *buf, unsigned long *count, loff_t offset);
+       int (*o_brw)(int rw, struct obd_conn * conn, obdattr *obj, struct page *page, int create);
+       int (*o_preallocate)(struct obd_conn *, unsigned long *req, long inodes[32]);
+       int  (*o_get_info)(struct obd_conn *, int keylen, void *key, int *vallen, void **val);
+       int  (*o_set_info)(struct obd_conn *, int keylen, void *key, int vallen, void *val);
+       int (*o_migrate)(struct obd_conn *, obdattr *src, obdattr *dst);
+       int (*o_copy)(struct obd_conn *dev, obdattr *source, obdattr *target);
+
 };
 
 #define OBP(dev,op) dev->obd_type->typ_ops->o_ ## op
@@ -84,21 +111,22 @@ struct obd_client {
        struct list_head cli_prealloc_inodes;
 };
 
+
 struct obd_prealloc_inode {
        struct list_head obd_prealloc_chain;
        unsigned long inode;
 };
 
 /* generic operations shared by various OBD types */
-int gen_connect (struct obd_device *obddev, 
-                    struct obd_conn_info * conninfo);
-int gen_disconnect(unsigned int conn_id);
+int gen_connect (struct obd_conn *conn);
+int gen_disconnect(struct obd_conn *conn);
 int gen_multi_setup(struct obd_device *obddev, int len, void *data);
 int gen_multi_cleanup(struct obd_device *obddev);
 int gen_multi_attach(struct obd_device *obddev, int len, void *data);
-struct obd_client *gen_client(int cli_id);
-int gen_multi_cleanup_device(struct obd_device *obddev);
+struct obd_client *gen_client(struct obd_conn *);
+int gen_multi_detach(struct obd_device *obddev);
 int gen_cleanup(struct obd_device *obddev);
+int gen_copy_data(struct obd_conn *, obdattr *source, obdattr *target);
 
 
 
@@ -130,13 +158,21 @@ struct oic_attr_s {
        unsigned long ino;
        struct iattr iattr;
 };
+
+struct ioc_mv_s {
+       unsigned int conn_id;
+       objid  src;
+       objid  tgt;
+};
+
 struct oic_rw_s {
        unsigned int conn_id;
-       unsigned long inode;
+       unsigned long id;
        char * buf;
        unsigned long count;
        loff_t offset;
 };
+
 struct oic_partition {
        int partition;
        unsigned int size;
@@ -144,7 +180,7 @@ struct oic_partition {
 
 
 #define OBD_IOC_CREATE                 _IOR ('f',  3, long)
-#define OBD_IOC_SETUP_OBDDEV           _IOW ('f',  4, long)
+#define OBD_IOC_SETUP                  _IOW ('f',  4, long)
 #define OBD_IOC_CLEANUP                _IO  ('f',  5      )
 #define OBD_IOC_DESTROY                _IOW ('f',  6, long)
 #define OBD_IOC_PREALLOCATE            _IOWR('f',  7, long)
@@ -161,6 +197,9 @@ struct oic_partition {
 #define OBD_IOC_FORMAT                 _IOWR('f', 18, long)
 #define OBD_IOC_PARTITION              _IOWR('f', 19, long)
 #define OBD_IOC_ATTACH                 _IOWR('f', 20, long)
+#define OBD_IOC_DETACH                 _IOWR('f', 21, long)
+#define OBD_IOC_COPY                   _IOWR('f', 22, long)
+#define OBD_IOC_MIGR                   _IOWR('f', 23, long)
 
 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 32      )
 
@@ -169,5 +208,60 @@ struct oic_partition {
 extern void obd_sysctl_init (void);
 extern void obd_sysctl_clean (void);
 
+#define CHKCONN(conn)  do { if (!gen_client(conn)) {\
+               printk("%s %d invalid client %u\n", __FILE__, __LINE__, \
+                      conn->oc_id);\
+               return -EINVAL; }} while (0) 
+
+
+/* support routines */
+static __inline__ obdattr *obd_empty_oa(void)
+{
+       obdattr *res = NULL;
+       OBD_ALLOC(res, obdattr *, sizeof(*res));
+       return res;
+}
+
+static __inline__ void obd_free_oa(obdattr *oa)
+{
+       if ( !oa ) 
+               return;
+       OBD_FREE(oa,sizeof(*oa));
+}
+
+
+
+static __inline__ obdattr *obd_oa_fromid(struct obd_conn *conn,  objid id)
+{
+       obdattr *res = NULL;
+
+       OBD_ALLOC(res, obdattr *, sizeof(*res));
+       if ( !res ) 
+               return NULL;
+
+       res->i_ino = id;
+       if (conn->oc_dev->obd_type->typ_ops->o_getattr(conn, res)) {
+               OBD_FREE(res, sizeof(*res));
+               return NULL;
+       }
+       
+       return res;
+}
+
+/* #define obd_cpy_obdo(a,b) memcpy(a, b, sizeof(*a)) */
+
+static __inline__ void obd_cpy_appmd(obdattr *a, obdattr *b)
+{
+       a->i_mode = b->i_mode;
+       a->i_uid = b->i_uid;
+       a->i_gid = b->i_gid;
+       a->i_size = b->i_size;
+       a->i_atime = b->i_atime;
+       a->i_mtime = b->i_mtime;
+       a->i_ctime = b->i_ctime;
+       a->i_flags = b->i_flags;
+       /* allocation of space */
+       a->i_blocks = b->i_blocks;
+}
 
 #endif /* __LINUX_CLASS_OBD_H */
index ddb2d8c..cf03c00 100644 (file)
@@ -4,17 +4,23 @@
 #define OBD_SNAP_MAGIC 0x47224722
 
 #define SNAP_MAX  8 /* must fit in "u" area of struct inode */
+struct snap {
+       time_t time;
+       int index;
+};
+
 struct snap_obd_data {
        int snap_dev;             /* which device contains the data */
        unsigned int snap_no;     /* which snapshot are we accessing */
        unsigned int snap_count;  /* how many snapshots exist */
-       time_t snap_times[SNAP_MAX];
+       struct snap snap_snaps[SNAP_MAX]; /* times must be incr or attach will fail */
 };
 
 struct snap_obd {
        unsigned int snap_no;    /* which snapshot are we accessing */
        unsigned int snap_count; /* how many snapshots exist */
        time_t snap_times[SNAP_MAX];
+       int snap_index[SNAP_MAX];
 };
 
 struct snap_object_data {
index 01d69f7..6a835a3 100644 (file)
@@ -21,7 +21,7 @@ extern int obd_print_entry;
 #define D_PSDEV       1 /* debug information from psdev.c */
 #define D_INODE       2
 #define D_SUPER       4
-#define D_UNUSED3     8
+#define D_SNAP        8
 #define D_UNUSED4    16
 #define D_WARNING    32 /* misc warnings */
 #define D_EXT2       64 /* anything from ext2_debug */
@@ -77,7 +77,7 @@ extern int obd_print_entry;
                \
                CDEBUG(D_IOCTL, " ** %s, cmd: %s, off %ld, uptodate: %s, "\
                       "locked: %s, cnt %d page %p pages %ld** \n", __FUNCTION__,\
-                      cmd, offset, uptodate, locked, count, page, page->mapping->nrpages);\
+                      cmd, offset, uptodate, locked, count, page, (!page->mapping) ? -1 : page->mapping->nrpages);\
        } else { CDEBUG(D_IOCTL, "** %s, no page\n", __FUNCTION__); }}
 
 
@@ -140,18 +140,13 @@ static inline void inode_cpy(struct inode *dest, struct inode *src)
        dest->i_flags = src->i_flags;
        /* allocation of space */
        dest->i_blocks = src->i_blocks;
-
-       if ( !dest->i_blocks) 
-               memcpy(&dest->u, &src->u, sizeof(src->u));
+       if ( !dest->i_blocks) {
+               CDEBUG(D_IOCTL, "copying inline data: ino %ld\n", dest->i_ino);
+               memcpy(&dest->u.ext2_i.i_data, &src->u.ext2_i.i_data, 
+                      sizeof(src->u.ext2_i.i_data));
+       }
 }
 
 
 
-
-
-
-
-
-
-
 #endif
index 67b229d..d583530 100644 (file)
@@ -44,7 +44,7 @@ int obdfs_check_dir_entry (const char * function, struct inode * dir,
                           unsigned long offset);
 
 struct obdfs_sb_info {
-       struct obd_conn_info osi_conn_info;
+       struct obd_conn osi_conn;
        struct super_block *osi_super;
        struct obd_device *osi_obd;
        struct obd_ops *osi_ops;     
@@ -66,10 +66,10 @@ static inline struct obd_ops *iops(struct inode *i)
        return sbi->osi_ops;
 }
 
-static inline int iid(struct inode *i)
+static inline struct obd_conn *iid(struct inode *i)
 {
        struct obdfs_sb_info *sbi = (struct obdfs_sb_info *) &i->i_sb->u.generic_sbp;
-       return sbi->osi_conn_info.conn_id;
+       return &sbi->osi_conn;
 }
 
 #define NOLOCK 0
@@ -85,8 +85,8 @@ static inline int iid(struct inode *i)
 #ifdef ID
 #warning "*** WARNING redefining ID"
 #else
-#define ID(sb) (((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn_info.conn_id)
-#define IID(inode) (((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn_info.conn_id)
+#define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
+#define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
 #endif
 
 #define OBDFS_SUPER_MAGIC 0x4711
index 14150a9..a59ed56 100644 (file)
@@ -38,8 +38,8 @@
 #include <linux/locks.h>
 #include <linux/quotaops.h>
 #include <linux/iobuf.h>
-#include <linux/obdfs.h>
 #include <linux/obd_support.h>
+#include <linux/obdfs.h>
 
 #if 0
 static ssize_t obdfs_dir_read (struct file * filp, char * buf,
index 1957c44..1d6399f 100644 (file)
@@ -36,6 +36,13 @@ int console_loglevel;
 
 /* VFS super_block ops */
 
+#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);
+}
+#endif
+
 /* returns the page unlocked, but with a reference */
 int obdfs_readpage(struct file *file, struct page *page)
 {
index 96b82fc..f8c5415 100644 (file)
@@ -84,22 +84,17 @@ void obdfs_options(char *options, char **dev, char **vers)
        char *this_char;
 
        if (!options)
-               goto out;
+               return;
 
        for (this_char = strtok (options, ",");
             this_char != NULL;
             this_char = strtok (NULL, ",")) {
                CDEBUG(D_SUPER, "this_char %s\n", this_char);
-               if ( (!*dev && (*dev = obdfs_read_opt("device", this_char))) ||
+               if ( (!*dev && (*dev = obdfs_read_opt("device", this_char)))||
                     (!*vers && (*vers = obdfs_read_opt("version", this_char))) )
                        continue;
                
        }
-
- out:
-       if (!*dev) {
-               *dev = "/dev/obd0";
-       }
 }
 
 static int obdfs_getdev(char *devpath, int *dev)
@@ -183,7 +178,8 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
        sbi->osi_obd = obddev;
        sbi->osi_ops = sbi->osi_obd->obd_type->typ_ops;
        
-        error  = sbi->osi_ops->o_connect(sbi->osi_obd, &sbi->osi_conn_info);
+       sbi->osi_conn.oc_dev = obddev;
+        error  = sbi->osi_ops->o_connect(&sbi->osi_conn);
        if ( error ) {
                printk("OBDFS: cannot connect to %s\n", device);
                goto error;
@@ -193,7 +189,7 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
 
        sbi->osi_super = sb;
 
-       error = sbi->osi_ops->o_get_info(sbi->osi_conn_info.conn_id, 
+       error = sbi->osi_ops->o_get_info(&sbi->osi_conn,
                                         strlen("blocksize"), 
                                         "blocksize", 
                                         &scratch, (void *)&blocksize);
@@ -202,7 +198,7 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
                goto error;
        }
 
-       error = sbi->osi_ops->o_get_info(sbi->osi_conn_info.conn_id, 
+       error = sbi->osi_ops->o_get_info(&sbi->osi_conn,
                                         strlen("blocksize_bits"), 
                                         "blocksize_bits", 
                                         &scratch, (void *)&blocksize_bits);
@@ -211,7 +207,7 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
                goto error;
        }
 
-       error = sbi->osi_ops->o_get_info(sbi->osi_conn_info.conn_id, 
+       error = sbi->osi_ops->o_get_info(&sbi->osi_conn,
                                         strlen("root_ino"), 
                                         "root_ino", 
                                         &scratch, (void *)&root_ino);
@@ -292,12 +288,12 @@ void obdfs_read_inode(struct inode *inode)
        int error;
        ENTRY;
 
-       error = IOPS(inode, getattr)(IID(inode), inode->i_ino, inode);
+       error = IOPS(inode, getattr)(IID(inode), inode);
        if (error) {
                printk("obdfs_read_inode: obd_getattr fails (%d)\n", error);
                return;
        }
-
+       CDEBUG(D_INODE, "ino %ld, COWFL %x\n", inode->i_ino, inode->i_flags & 0x0010000);
        IDEBUG(inode);
        inode->i_op = &obdfs_inode_ops;
        return;
@@ -307,12 +303,12 @@ static void obdfs_write_inode(struct inode *inode)
 {
        int error;
        
-       error = IOPS(inode, setattr)(IID(inode), inode->i_ino, inode);
+       error = IOPS(inode, setattr)(IID(inode), inode);
        if (error) {
                printk("obdfs_write_inode: obd_setattr fails (%d)\n", error);
                return;
        }
-
+       
        return;
 }
 
@@ -321,7 +317,7 @@ static void obdfs_delete_inode(struct inode *inode)
        int error;
         ENTRY;
 
-       error = IOPS(inode, destroy)(IID(inode), inode->i_ino);
+       error = IOPS(inode, destroy)(IID(inode), inode);
        if (error) {
                printk("obdfs_delete_node: ibd_destroy fails (%d)\n", error);
                return;
@@ -340,12 +336,14 @@ static int  obdfs_notify_change(struct dentry *de, struct iattr *iattr)
        inode_to_iattr(inode, &saved_copy);
 
        inode_setattr(inode, iattr);
-        error = IOPS(inode, setattr)(IID(inode), inode->i_ino, inode);
+        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;
        }
+
+       CDEBUG(D_INODE, "inode blocks now %ld\n", inode->i_blocks);
        EXIT;
         return error;
 }