Whamcloud - gitweb
Pass inline data from filesystem through obdo to VFS.
[fs/lustre-release.git] / lustre / obdfs / super.c
index 293f265..6e571f5 100644 (file)
@@ -292,19 +292,63 @@ static void obdfs_put_super(struct super_block *sb)
        EXIT;
 }
 
+inline int obdfs_has_inline(struct inode *inode)
+{
+       struct obdfs_inode_info *oinfo = inode->u.generic_ip;
+       
+       return (oinfo->oi_flags & OBD_FL_INLINEDATA);
+}
+
+void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
+{
+       struct obdfs_inode_info *oinfo = inode->u.generic_ip;
+
+       obdo_from_inode(oa, inode);
+       if (obdfs_has_inline(inode)) {
+               memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
+               oa->o_flags |= OBD_FL_INLINEDATA;
+       }
+}
+
+void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
+{
+       struct obdfs_inode_info *oinfo = inode->u.generic_ip;
+
+       obdo_to_inode(inode, oa);
+       if (obdo_has_inline(oa)) {
+               memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
+               oinfo->oi_flags |= OBD_FL_INLINEDATA;
+       }
+}
+
 /* 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_FLOBDMD;
+       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;
        }
-       CDEBUG(D_INODE, "ino %ld, mode: %o\n", inode->i_ino, inode->i_mode);
+
+       ODEBUG(oa);
+       obdfs_to_inode(inode, oa);
+       obdo_free(oa);
        IDEBUG(inode);
+
        if (S_ISREG(inode->i_mode))
                inode->i_op = &obdfs_file_inode_operations;
        else if (S_ISDIR(inode->i_mode))
@@ -319,11 +363,18 @@ void obdfs_read_inode(struct inode *inode)
 
 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;
+       obdfs_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;
        }
        
@@ -332,38 +383,54 @@ static void obdfs_write_inode(struct inode *inode)
 
 static void obdfs_delete_inode(struct inode *inode)
 {
-       int error;
+       struct obdo *oa;
+       int err;
         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;
 }
 
-static int  obdfs_notify_change(struct dentry *de, struct iattr *iattr)
+
+
+
+static int obdfs_notify_change(struct dentry *de, struct iattr *attr)
 {
        struct inode *inode = de->d_inode;
-       struct iattr saved_copy;
-       int error;
+       struct obdo *oa;
+       int err;
 
        ENTRY;
-       inode_to_iattr(inode, &saved_copy);
+       oa = obdo_alloc();
+       if (!oa) {
+               printk("obdfs_notify_change: obdo_alloc fails\n");
+               return -ENOMEM;
+       }
 
-       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->o_id = inode->i_ino;
+       obdo_from_iattr(oa, attr);
+        err = IOPS(inode, setattr)(IID(inode), oa);
+       obdo_free(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;
-        return error;
+        return err;
 }
 
 
@@ -371,20 +438,20 @@ static int obdfs_statfs(struct super_block *sb, struct statfs *buf,
                       int bufsize)
 {
        struct statfs tmp;
-       int error;
+       int err;
 
        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;
 
-       return error
+       return err; 
 }
 
 struct file_system_type obdfs_fs_type = {
@@ -404,7 +471,9 @@ int init_obdfs(void)
        if (err)
                return err;
 
+       /* XXX
        flushd_init();
+       */
 
        return register_filesystem(&obdfs_fs_type);
 }
@@ -421,6 +490,7 @@ void cleanup_module(void)
         ENTRY;
 
        obdfs_sysctl_clean();
+       obdfs_cleanup_wreqcache();
        unregister_filesystem(&obdfs_fs_type);
 }