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 inode *inode, void *handle,
35 /* a _really_ horrible hack to avoid removing the data stored
36 in the block pointers; this data is the object id
37 this will go into an extended attribute at some point.
39 if (iattr->ia_valid & ATTR_SIZE ) {
40 /* ATTR_SIZE would invoke truncate: clear it */
41 iattr->ia_valid &= ~ATTR_SIZE;
42 inode->i_size = iattr->ia_size;
44 /* make sure _something_ gets set - so new inode
45 goes to disk (probably won't work over XFS */
46 if (!iattr->ia_valid & ATTR_MODE) {
47 iattr->ia_valid |= ATTR_MODE;
48 iattr->ia_mode = inode->i_mode;
56 * FIXME: nasty hack - store the object id in the first two
57 * direct block spots. This should be done with EAs...
59 static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id)
61 memcpy(inode->u.ext2_i.i_data, &id, sizeof(id));
65 static void mds_ext2_get_objid(struct inode *inode, obd_id *id)
67 memcpy(id, &inode->u.ext2_i.i_data, sizeof(*id));
70 static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count,
73 if (S_ISREG(file->f_dentry->d_inode->i_mode))
74 return file->f_op->read(file, buf, count, offset);
76 return generic_file_read(file, buf, count, offset);
79 struct mds_fs_operations mds_ext2_fs_ops = {
80 fs_start: mds_ext2_start,
81 fs_commit: mds_ext2_stop,
82 fs_setattr: mds_ext2_setattr,
83 fs_set_objid: mds_ext2_set_objid,
84 fs_get_objid: mds_ext2_get_objid,
85 fs_readpage: mds_ext2_readpage,