#include <linux/fs.h>
#include <linux/ext2_fs.h>
#include <linux/lustre_mds.h>
+#include <linux/module.h>
static void *mds_ext2_start(struct inode *inode, int nblocks)
{
{
struct inode *inode = dentry->d_inode;
+ lock_kernel();
+
/* 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.
*/
- if (iattr->ia_valid & ATTR_SIZE ) {
+ if (iattr->ia_valid & ATTR_SIZE) {
/* ATTR_SIZE would invoke truncate: clear it */
iattr->ia_valid &= ~ATTR_SIZE;
inode->i_size = iattr->ia_size;
}
if (inode->i_op->setattr)
- return inode->i_op->setattr(dentry, iattr);
+ rc = inode->i_op->setattr(dentry, iattr);
else
- return inode_setattr(inode, iattr);
+ rc = inode_setattr(inode, iattr);
+
+ unlock_kernel();
+
+ return rc;
}
/*
* 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;
+ (__u64)(inode->u.ext2_i.i_data[0]) = cpu_to_le64(id);
return 0;
}
-static void mds_ext2_get_objid(struct inode *inode, obd_id *id)
+static int mds_ext2_get_objid(struct inode *inode, obd_id *id)
{
- memcpy(id, &inode->u.ext2_i.i_data, sizeof(*id));
+ *id = le64_to_cpu(inode->u.ext2_i.i_data[0]);
+
+ return 0;
}
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;
+static struct mds_fs_operations mds_ext2_fs_ops;
-void mds_ext2_delete_inode(struct inode *inode)
+static void mds_ext2_delete_inode(struct inode *inode)
{
- if (inode->u.ext2_i.i_flags & EXT2_OBJID_FL)
+ if (S_ISREG(inode->i_mode))
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,
- fs_setattr: mds_ext2_setattr,
- 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,
+static int mds_ext2_set_last_rcvd(struct mds_obd *mds, void *handle)
+{
+ /* Bail for ext2 - can't tell when it is on disk anyways, sync? */
+ mds->mds_last_committed = mds->mds_last_rcvd;
+
+ return 0;
+}
+
+static int mds_ext2_journal_data(struct file *filp)
+{
+ return 0;
+}
+
+static struct mds_fs_operations mds_ext2_fs_ops = {
+ fs_owner: THIS_MODULE,
+ fs_start: mds_ext2_start,
+ fs_commit: mds_ext2_stop,
+ fs_setattr: mds_ext2_setattr,
+ 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,
+ fs_journal_data: mds_ext2_journal_data,
+ fs_set_last_rcvd: mds_ext2_set_last_rcvd,
};
+
+static int __init mds_ext2_init(void)
+{
+ return mds_register_fs_type(&mds_ext2_fs_ops, "ext2");
+}
+
+static void __exit mds_ext2_exit(void)
+{
+ mds_unregister_fs_type("ext2");
+}
+
+MODULE_AUTHOR("Cluster File Systems, Inc. <adilger@clusterfs.com>");
+MODULE_DESCRIPTION("Lustre MDS ext2 Filesystem Helper v0.1");
+MODULE_LICENSE("GPL");
+
+module_init(mds_ext2_init);
+module_exit(mds_ext2_exit);