Whamcloud - gitweb
ext2obd.c: changed ext2obd_from_inode to set obdflags
authoradilger <adilger>
Fri, 14 Jan 2000 15:09:34 +0000 (15:09 +0000)
committeradilger <adilger>
Fri, 14 Jan 2000 15:09:34 +0000 (15:09 +0000)
snap/*.c: updated to work with obdos properly
obdfs/*: make sure we don't hold ANY obdo data

lustre/include/linux/obd_class.h
lustre/include/linux/obd_ext2.h
lustre/include/linux/obdfs.h
lustre/obdfs/rw.c
lustre/obdfs/super.c

index f74f3f7..5e29768 100644 (file)
@@ -76,6 +76,7 @@ struct obdo {
 #define OBD_MD_FLGENER (0x2000UL)
 #define OBD_MD_FLINLINE        (0x4000UL)
 #define OBD_MD_FLOBDMD (0x8000UL)
+#define OBD_MD_FLNOTOBD        (~(OBD_MD_FLOBDMD | OBD_MD_FLOBDFLG))
 
 /*
  *  ======== OBD Device Declarations ===========
@@ -190,12 +191,12 @@ extern kmem_cache_t *obdo_cachep;
 
 static __inline__ struct obdo *obdo_alloc(void)
 {
-       struct obdo *res = NULL;
+       struct obdo *oa = NULL;
 
-       res = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
-       memset(res, 0, sizeof (*res));
+       oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
+       memset(oa, 0, sizeof (*oa));
 
-       return res;
+       return oa;
 }
 
 static __inline__ void obdo_free(struct obdo *oa)
@@ -207,26 +208,27 @@ static __inline__ void obdo_free(struct obdo *oa)
 
 
 
-static __inline__ struct obdo *obdo_fromid(struct obd_conn *conn, obd_id id)
+static __inline__ struct obdo *obdo_fromid(struct obd_conn *conn, obd_id id,
+                                          obd_flag valid)
 {
-       struct obdo *res = NULL;
+       struct obdo *oa;
        int err;
 
-       res = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
-       if ( !res ) {
+       oa = obdo_alloc();
+       if ( !oa ) {
                EXIT;
                return ERR_PTR(-ENOMEM);
        }
-       memset(res, 0, sizeof(*res));
-       res->o_id = id;
-       res->o_valid = OBD_MD_FLALL;
-       if ((err = OBP(conn->oc_dev, getattr)(conn, res))) {
-               OBD_FREE(res, sizeof(*res));
+       memset(oa, 0, sizeof(*oa));
+       oa->o_id = id;
+       oa->o_valid = valid;
+       if ((err = OBP(conn->oc_dev, getattr)(conn, oa))) {
+               obdo_free(oa);
                EXIT;
                return ERR_PTR(err);
        }
        EXIT;
-       return res;
+       return oa;
 }
 
 static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr)
@@ -291,16 +293,24 @@ static __inline__ void obdo_cpy_md(struct obdo *dst, struct obdo *src)
                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_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_FLGENER ) 
                dst->o_generation = src->o_generation;
-       if ( src->o_valid & OBD_MD_FLINLINE ) 
+       if ( src->o_valid & OBD_MD_FLINLINE &&
+            src->o_obdflags & OBD_FL_INLINEDATA) {
                memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
-       if ( src->o_valid & OBD_MD_FLOBDMD ) 
+               dst->o_obdflags |= OBD_FL_INLINEDATA;
+       }
+       if ( src->o_valid & OBD_MD_FLOBDMD &&
+            src->o_obdflags & OBD_FL_OBDMDEXISTS) {
                memcpy(dst->o_obdmd, src->o_obdmd, sizeof(src->o_obdmd));
+               dst->o_obdflags |= OBD_FL_OBDMDEXISTS;
+       }
 
        dst->o_valid |= src->o_valid;
 }
index 50d23d0..d76b90f 100644 (file)
@@ -15,7 +15,6 @@ extern struct file_operations *obd_fso;
 
 /* ext2_obd.c */
 extern struct obd_ops ext2_obd_ops;
-inline long ext2_block_map (struct inode * inode, long block);
 
 /* balloc.c */
 int ext2_new_block (const struct inode * inode, unsigned long goal,
@@ -32,28 +31,19 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
 unsigned long ext2_count_free(struct buffer_head * map, unsigned int numchars);
 
 /* fsync.c */
-extern int obd_sync_file(struct file * file, struct dentry *dentry);
+int ext2_sync_file(struct file * file, struct dentry *dentry);
 
 /* ialloc.c */
-extern void ext2_free_inode (struct inode * inode);
-extern struct inode * ext2_new_inode (const struct inode * dir, int mode,
+void ext2_free_inode (struct inode * inode);
+struct inode * ext2_new_inode (const struct inode * dir, int mode,
                                     int * err);
-extern unsigned long ext2_count_free_inodes (struct super_block * sb);
-extern void ext2_check_inodes_bitmap (struct super_block * sb);
-extern int load_inode_bitmap (struct super_block * sb,
+unsigned long ext2_count_free_inodes (struct super_block * sb);
+void ext2_check_inodes_bitmap (struct super_block * sb);
+int load_inode_bitmap (struct super_block * sb,
                              unsigned int block_group);
 
 /* inode.c */
-void obd_read_inode (struct inode * inode);
-void obd_write_inode (struct inode * inode);
-void obd_put_inode (struct inode * inode);
-void obd_delete_inode (struct inode * inode);
-void obd_discard_prealloc_blocks (struct inode * inode);
-int obd_sync_inode (struct inode *inode);
-struct buffer_head * obd_bread (struct inode * inode, int block, 
-                                int create, int *err);
-struct buffer_head * obd_getblk (struct inode * inode, long block,
-                                 int create, int * err);
+inline long ext2_block_map (struct inode * inode, long block);
 
 
 /* super.c */
index 1b921be..a369ea0 100644 (file)
@@ -103,10 +103,32 @@ static inline int obdfs_has_inline(struct inode *inode)
        return (OBDFS_INFO(inode)->oi_flags & OBD_FL_INLINEDATA);
 }
 
-static inline int obdfs_has_obdmd(struct inode *inode)
+static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
 {
-       return (OBDFS_INFO(inode)->oi_flags & OBD_FL_OBDMDEXISTS);
-}
+       struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
+
+       CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
+       obdo_from_inode(oa, inode);
+       if (obdfs_has_inline(inode)) {
+               CDEBUG(D_INODE, "inode has inline data\n");
+               memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
+               oa->o_obdflags |= OBD_FL_INLINEDATA;
+               oa->o_valid |= OBD_MD_FLINLINE;
+       }
+} /* obdfs_from_inode */
+
+static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
+{
+       struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
+
+       CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
+       obdo_to_inode(inode, oa);
+       if (obdo_has_inline(oa)) {
+               CDEBUG(D_INODE, "obdo has inline data\n");
+               memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
+               oinfo->oi_flags |= OBD_FL_INLINEDATA;
+       }
+} /* obdfs_to_inode */
 
 #define NOLOCK 0
 #define LOCKED 1
index 1d3e1c8..68d8465 100644 (file)
@@ -43,7 +43,7 @@ static int obdfs_brw(int rw, struct inode *inode, struct page *page, int create)
        int err;
 
        ENTRY;
-       obdo = obdo_fromid(IID(inode), inode->i_ino);
+       obdo = obdo_fromid(IID(inode), inode->i_ino, OBD_MD_FLNOTOBD);
        if ( IS_ERR(obdo) ) {
                EXIT;
                return PTR_ERR(obdo);
index f2c91e7..e8e94bd 100644 (file)
@@ -286,65 +286,17 @@ static void obdfs_put_super(struct super_block *sb)
        EXIT;
 } /* obdfs_put_super */
 
-void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
-{
-       struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
-
-       CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
-       obdo_from_inode(oa, inode);
-       if (obdfs_has_inline(inode)) {
-               CDEBUG(D_INODE, "inode has inline data\n");
-               memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
-               oa->o_obdflags |= OBD_FL_INLINEDATA;
-               oa->o_valid |= OBD_MD_FLINLINE;
-       }
-       if (obdfs_has_obdmd(inode)) {
-               CDEBUG(D_INODE, "inode %ld has obdmd data\n");
-               oa->o_obdflags |= OBD_FL_OBDMDEXISTS;
-       }
-} /* obdfs_from_inode */
-
-void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
-{
-       struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
-
-       CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
-       obdo_to_inode(inode, oa);
-       if (obdo_has_inline(oa)) {
-               CDEBUG(D_INODE, "obdo has inline data\n");
-               memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
-               oinfo->oi_flags |= OBD_FL_INLINEDATA;
-       }
-       if (obdo_has_obdmd(oa)) {
-               CDEBUG(D_INODE, "obdo has obdmd data\n");
-               oinfo->oi_flags |= OBD_FL_OBDMDEXISTS;
-       }
-} /* obdfs_to_inode */
-
 /* all filling in of inodes postponed until lookup */
 void obdfs_read_inode(struct inode *inode)
 {
        struct obdo *oa;
-       int err;
 
        ENTRY;
-       oa = obdo_alloc();
-       if (!oa) {
-               printk("obdfs_read_inode: obdo_alloc failed\n");
+       oa = obdo_fromid(IID(inode), inode->i_ino, OBD_MD_FLNOTOBD);
+       if ( IS_ERR(oa) ) {
+               printk("obdfs_read_inode: obdo_fromid failed\n");
                EXIT;
-               return;
-       }
-       oa->o_valid = ~OBD_MD_FLOBDMD;
-       oa->o_id = inode->i_ino;
-
-       INIT_LIST_HEAD(&OBDFS_INFO(inode)->oi_pages);
-       
-       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 /* PTR_ERR(oa) */;
        }
 
        ODEBUG(oa);
@@ -362,6 +314,7 @@ void obdfs_read_inode(struct inode *inode)
                inode->i_op = &obdfs_symlink_inode_operations;
        else
                init_special_inode(inode, inode->i_mode,
+                                  /* XXX need to fill in the ext2 side */
                                   ((long *)OBDFS_INFO(inode)->oi_inline)[0]);
 
        EXIT;
@@ -380,7 +333,7 @@ static void obdfs_write_inode(struct inode *inode)
                return;
        }
 
-       oa->o_valid = ~OBD_MD_FLOBDMD;
+       oa->o_valid = OBD_MD_FLNOTOBD;
        obdfs_from_inode(oa, inode);
        err = IOPS(inode, setattr)(IID(inode), oa);
 
@@ -407,7 +360,11 @@ static void obdfs_delete_inode(struct inode *inode)
         ENTRY;
 
        oa = obdo_alloc();
-       oa->o_valid = ~OBD_MD_FLOBDMD;
+       if ( !oa ) {
+               printk("obdfs_delete_inode: obdo_alloc failed\n");
+               return;
+       }
+       oa->o_valid = OBD_MD_FLNOTOBD;
        obdfs_from_inode(oa, inode);
 
        err = IOPS(inode, destroy)(IID(inode), oa);