Whamcloud - gitweb
Ensure we undo everything in ll_read_super() on error.
[fs/lustre-release.git] / lustre / mds / mds_ext2.c
index 4649322..c03e867 100644 (file)
@@ -21,7 +21,7 @@
 
 static void *mds_ext2_start(struct inode *inode, int nblocks)
 {
-        return 0;
+        return (void *)1;
 }
 
 static int mds_ext2_stop(struct inode *inode, void *handle)
@@ -29,9 +29,11 @@ static int mds_ext2_stop(struct inode *inode, void *handle)
         return 0;
 }
 
-static int mds_ext2_setattr(struct inode *inode, void *handle,
+static int mds_ext2_setattr(struct dentry *dentry, void *handle,
                             struct iattr *iattr)
 {
+        struct inode *inode = dentry->d_inode;
+
         /* a _really_ horrible hack to avoid removing the data stored
            in the block pointers; this data is the object id
            this will go into an extended attribute at some point.
@@ -49,16 +51,21 @@ static int mds_ext2_setattr(struct inode *inode, void *handle,
                 }
         }
 
-        return 0;
+        if (inode->i_op->setattr)
+                return inode->i_op->setattr(dentry, iattr);
+        else
+                return inode_setattr(inode, iattr);
 }
 
 /*
  * FIXME: nasty hack - store the object id in the first two
  *        direct block spots.  This should be done with EAs...
  */
+#define EXT2_OBJID_FL   0x40000000
 static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id)
 {
         memcpy(inode->u.ext2_i.i_data, &id, sizeof(id));
+        inode->u.ext2_i.i_flags |= EXT2_OBJID_FL;
         return 0;
 }
 
@@ -76,6 +83,16 @@ static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count,
                 return generic_file_read(file, buf, count, offset);
 }
 
+struct mds_fs_operations mds_ext2_fs_ops;
+
+void mds_ext2_delete_inode(struct inode *inode)
+{
+        if (inode->u.ext2_i.i_flags & EXT2_OBJID_FL)
+                mds_ext2_set_objid(inode, NULL, 0);
+
+        mds_ext2_fs_ops.cl_delete_inode(inode);
+}
+
 struct mds_fs_operations mds_ext2_fs_ops = {
         fs_start:       mds_ext2_start,
         fs_commit:      mds_ext2_stop,
@@ -83,4 +100,6 @@ struct mds_fs_operations mds_ext2_fs_ops = {
         fs_set_objid:   mds_ext2_set_objid,
         fs_get_objid:   mds_ext2_get_objid,
         fs_readpage:    mds_ext2_readpage,
+        fs_delete_inode:mds_ext2_delete_inode,
+        cl_delete_inode:clear_inode,
 };