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;
38 /* a _really_ horrible hack to avoid removing the data stored
39 in the block pointers; this data is the object id
40 this will go into an extended attribute at some point.
42 if (iattr->ia_valid & ATTR_SIZE) {
43 /* ATTR_SIZE would invoke truncate: clear it */
44 iattr->ia_valid &= ~ATTR_SIZE;
45 inode->i_size = iattr->ia_size;
47 /* make sure _something_ gets set - so new inode
48 goes to disk (probably won't work over XFS */
49 if (!iattr->ia_valid & ATTR_MODE) {
50 iattr->ia_valid |= ATTR_MODE;
51 iattr->ia_mode = inode->i_mode;
55 if (inode->i_op->setattr)
56 return inode->i_op->setattr(dentry, iattr);
58 return inode_setattr(inode, iattr);
62 * FIXME: nasty hack - store the object id in the first two
63 * direct block spots. This should be done with EAs...
65 static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id)
67 (__u64)(inode->u.ext2_i.i_data[0]) = cpu_to_le64(id);
71 static int mds_ext2_get_objid(struct inode *inode, obd_id *id)
73 *id = le64_to_cpu(inode->u.ext2_i.i_data[0]);
78 static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count,
81 if (S_ISREG(file->f_dentry->d_inode->i_mode))
82 return file->f_op->read(file, buf, count, offset);
84 return generic_file_read(file, buf, count, offset);
87 static struct mds_fs_operations mds_ext2_fs_ops;
89 static void mds_ext2_delete_inode(struct inode *inode)
91 if (S_ISREG(inode->i_mode))
92 mds_ext2_set_objid(inode, NULL, 0);
94 mds_ext2_fs_ops.cl_delete_inode(inode);
97 static int mds_ext2_set_last_rcvd(struct mds_obd *mds, void *handle)
99 /* Bail for ext2 - can't tell when it is on disk anyways, sync? */
100 mds->mds_last_committed = mds->mds_last_rcvd;
105 static int mds_ext2_journal_data(struct file *filp)
110 static struct mds_fs_operations mds_ext2_fs_ops = {
111 fs_owner: THIS_MODULE,
112 fs_start: mds_ext2_start,
113 fs_commit: mds_ext2_stop,
114 fs_setattr: mds_ext2_setattr,
115 fs_set_objid: mds_ext2_set_objid,
116 fs_get_objid: mds_ext2_get_objid,
117 fs_readpage: mds_ext2_readpage,
118 fs_delete_inode: mds_ext2_delete_inode,
119 cl_delete_inode: clear_inode,
120 fs_journal_data: mds_ext2_journal_data,
121 fs_set_last_rcvd: mds_ext2_set_last_rcvd,
124 static int __init mds_ext2_init(void)
126 return mds_register_fs_type(&mds_ext2_fs_ops, "ext2");
129 static void __exit mds_ext2_exit(void)
131 mds_unregister_fs_type("ext2");
134 MODULE_AUTHOR("Cluster File Systems, Inc. <adilger@clusterfs.com>");
135 MODULE_DESCRIPTION("Lustre MDS ext2 Filesystem Helper v0.1");
136 MODULE_LICENSE("GPL");
138 module_init(mds_ext2_init);
139 module_exit(mds_ext2_exit);