1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * Lustre Metadata Server (mds) journal abstraction routines
8 * Copyright (C) 2002 Cluster File Systems, Inc.
9 * author: Andreas Dilger <adilger@clusterfs.com>
11 * This code is issued under the GNU General Public License.
12 * See the file COPYING in this distribution
16 #define DEBUG_SUBSYSTEM S_MDS
19 #include <linux/ext2_fs.h>
20 #include <linux/lustre_mds.h>
21 #include <linux/module.h>
23 static void *mds_ext2_start(struct inode *inode, int nblocks)
28 static int mds_ext2_stop(struct inode *inode, void *handle)
33 static int mds_ext2_setattr(struct dentry *dentry, void *handle,
36 struct inode *inode = dentry->d_inode;
40 /* a _really_ horrible hack to avoid removing the data stored
41 in the block pointers; this data is the object id
42 this will go into an extended attribute at some point.
44 if (iattr->ia_valid & ATTR_SIZE) {
45 /* ATTR_SIZE would invoke truncate: clear it */
46 iattr->ia_valid &= ~ATTR_SIZE;
47 inode->i_size = iattr->ia_size;
49 /* make sure _something_ gets set - so new inode
50 goes to disk (probably won't work over XFS */
51 if (!iattr->ia_valid & ATTR_MODE) {
52 iattr->ia_valid |= ATTR_MODE;
53 iattr->ia_mode = inode->i_mode;
57 if (inode->i_op->setattr)
58 rc = inode->i_op->setattr(dentry, iattr);
60 rc = inode_setattr(inode, iattr);
68 * FIXME: nasty hack - store the object id in the first two
69 * direct block spots. This should be done with EAs...
71 static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id)
73 (__u64)(inode->u.ext2_i.i_data[0]) = cpu_to_le64(id);
77 static int mds_ext2_get_objid(struct inode *inode, obd_id *id)
79 *id = le64_to_cpu(inode->u.ext2_i.i_data[0]);
84 static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count,
87 if (S_ISREG(file->f_dentry->d_inode->i_mode))
88 return file->f_op->read(file, buf, count, offset);
90 return generic_file_read(file, buf, count, offset);
93 static struct mds_fs_operations mds_ext2_fs_ops;
95 static void mds_ext2_delete_inode(struct inode *inode)
97 if (S_ISREG(inode->i_mode))
98 mds_ext2_set_objid(inode, NULL, 0);
100 mds_ext2_fs_ops.cl_delete_inode(inode);
103 static int mds_ext2_set_last_rcvd(struct mds_obd *mds, void *handle)
105 /* Bail for ext2 - can't tell when it is on disk anyways, sync? */
106 mds->mds_last_committed = mds->mds_last_rcvd;
111 static int mds_ext2_journal_data(struct file *filp)
116 static struct mds_fs_operations mds_ext2_fs_ops = {
117 fs_owner: THIS_MODULE,
118 fs_start: mds_ext2_start,
119 fs_commit: mds_ext2_stop,
120 fs_setattr: mds_ext2_setattr,
121 fs_set_objid: mds_ext2_set_objid,
122 fs_get_objid: mds_ext2_get_objid,
123 fs_readpage: mds_ext2_readpage,
124 fs_delete_inode: mds_ext2_delete_inode,
125 cl_delete_inode: clear_inode,
126 fs_journal_data: mds_ext2_journal_data,
127 fs_set_last_rcvd: mds_ext2_set_last_rcvd,
130 static int __init mds_ext2_init(void)
132 return mds_register_fs_type(&mds_ext2_fs_ops, "ext2");
135 static void __exit mds_ext2_exit(void)
137 mds_unregister_fs_type("ext2");
140 MODULE_AUTHOR("Cluster File Systems, Inc. <adilger@clusterfs.com>");
141 MODULE_DESCRIPTION("Lustre MDS ext2 Filesystem Helper v0.1");
142 MODULE_LICENSE("GPL");
144 module_init(mds_ext2_init);
145 module_exit(mds_ext2_exit);