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>
22 static void *mds_ext2_start(struct inode *inode, int nblocks)
27 static int mds_ext2_stop(struct inode *inode, void *handle)
32 static int mds_ext2_setattr(struct dentry *dentry, void *handle,
35 struct inode *inode = dentry->d_inode;
37 /* a _really_ horrible hack to avoid removing the data stored
38 in the block pointers; this data is the object id
39 this will go into an extended attribute at some point.
41 if (iattr->ia_valid & ATTR_SIZE) {
42 /* ATTR_SIZE would invoke truncate: clear it */
43 iattr->ia_valid &= ~ATTR_SIZE;
44 inode->i_size = iattr->ia_size;
46 /* make sure _something_ gets set - so new inode
47 goes to disk (probably won't work over XFS */
48 if (!iattr->ia_valid & ATTR_MODE) {
49 iattr->ia_valid |= ATTR_MODE;
50 iattr->ia_mode = inode->i_mode;
54 if (inode->i_op->setattr)
55 return inode->i_op->setattr(dentry, iattr);
57 return inode_setattr(inode, iattr);
61 * FIXME: nasty hack - store the object id in the first two
62 * direct block spots. This should be done with EAs...
64 static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id)
66 (__u64)(inode->u.ext2_i.i_data[0]) = cpu_to_le64(id);
70 static void mds_ext2_get_objid(struct inode *inode, obd_id *id)
72 *id = le64_to_cpu(inode->u.ext2_i.i_data[0]);
75 static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count,
78 if (S_ISREG(file->f_dentry->d_inode->i_mode))
79 return file->f_op->read(file, buf, count, offset);
81 return generic_file_read(file, buf, count, offset);
84 struct mds_fs_operations mds_ext2_fs_ops;
86 static void mds_ext2_delete_inode(struct inode *inode)
88 if (S_ISREG(inode->i_mode))
89 mds_ext2_set_objid(inode, NULL, 0);
91 mds_ext2_fs_ops.cl_delete_inode(inode);
94 static int mds_ext2_set_last_rcvd(struct mds_obd *mds, void *handle)
96 /* Bail for ext2 - can't tell when it is on disk anyways, sync? */
97 mds->mds_last_committed = mds->mds_last_rcvd;
102 static int mds_ext2_journal_data(struct file *filp)
107 struct mds_fs_operations mds_ext2_fs_ops = {
108 fs_start: mds_ext2_start,
109 fs_commit: mds_ext2_stop,
110 fs_setattr: mds_ext2_setattr,
111 fs_set_objid: mds_ext2_set_objid,
112 fs_get_objid: mds_ext2_get_objid,
113 fs_readpage: mds_ext2_readpage,
114 fs_delete_inode:mds_ext2_delete_inode,
115 cl_delete_inode:clear_inode,
116 fs_journal_data:mds_ext2_journal_data,
117 fs_set_last_rcvd:mds_ext2_set_last_rcvd,