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 #define EXT2_OBJID_FL 0x40000000
60 static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id)
62 memcpy(inode->u.ext2_i.i_data, &id, sizeof(id));
63 inode->u.ext2_i.i_flags |= EXT2_OBJID_FL;
67 static void mds_ext2_get_objid(struct inode *inode, obd_id *id)
69 memcpy(id, &inode->u.ext2_i.i_data, sizeof(*id));
72 static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count,
75 if (S_ISREG(file->f_dentry->d_inode->i_mode))
76 return file->f_op->read(file, buf, count, offset);
78 return generic_file_read(file, buf, count, offset);
81 struct mds_fs_operations mds_ext2_fs_ops;
83 void mds_ext2_delete_inode(struct inode *inode)
85 if (inode->u.ext2_i.i_flags & EXT2_OBJID_FL)
86 mds_ext2_set_objid(inode, NULL, 0);
88 mds_ext2_fs_ops.cl_delete_inode(inode);
91 struct mds_fs_operations mds_ext2_fs_ops = {
92 fs_start: mds_ext2_start,
93 fs_commit: mds_ext2_stop,
94 fs_setattr: mds_ext2_setattr,
95 fs_set_objid: mds_ext2_set_objid,
96 fs_get_objid: mds_ext2_get_objid,
97 fs_readpage: mds_ext2_readpage,
98 fs_delete_inode:mds_ext2_delete_inode,
99 cl_delete_inode:clear_inode,