/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * * linux/mds/mds_null.c * * Lustre Metadata Server (mds) journal abstraction routines * * Copyright (C) 2002 Cluster File Systems, Inc. * author: Andreas Dilger * * This code is issued under the GNU General Public License. * See the file COPYING in this distribution * */ #define DEBUG_SUBSYSTEM S_MDS #include #include #include #include static void *mds_ext2_start(struct inode *inode, int nblocks) { return (void *)1; } static int mds_ext2_stop(struct inode *inode, void *handle) { return 0; } static int mds_ext2_setattr(struct dentry *dentry, void *handle, struct iattr *iattr) { struct inode *inode = dentry->d_inode; lock_kernel(); /* a _really_ horrible hack to avoid removing the data stored in the block pointers; this data is the object id this will go into an extended attribute at some point. */ if (iattr->ia_valid & ATTR_SIZE) { /* ATTR_SIZE would invoke truncate: clear it */ iattr->ia_valid &= ~ATTR_SIZE; inode->i_size = iattr->ia_size; /* make sure _something_ gets set - so new inode goes to disk (probably won't work over XFS */ if (!iattr->ia_valid & ATTR_MODE) { iattr->ia_valid |= ATTR_MODE; iattr->ia_mode = inode->i_mode; } } if (inode->i_op->setattr) rc = inode->i_op->setattr(dentry, iattr); else rc = inode_setattr(inode, iattr); unlock_kernel(); return rc; } /* * FIXME: nasty hack - store the object id in the first two * direct block spots. This should be done with EAs... */ static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id) { (__u64)(inode->u.ext2_i.i_data[0]) = cpu_to_le64(id); return 0; } static int mds_ext2_get_objid(struct inode *inode, obd_id *id) { *id = le64_to_cpu(inode->u.ext2_i.i_data[0]); return 0; } static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count, loff_t *offset) { if (S_ISREG(file->f_dentry->d_inode->i_mode)) return file->f_op->read(file, buf, count, offset); else return generic_file_read(file, buf, count, offset); } static struct mds_fs_operations mds_ext2_fs_ops; static void mds_ext2_delete_inode(struct inode *inode) { if (S_ISREG(inode->i_mode)) mds_ext2_set_objid(inode, NULL, 0); mds_ext2_fs_ops.cl_delete_inode(inode); } static int mds_ext2_set_last_rcvd(struct mds_obd *mds, void *handle) { /* Bail for ext2 - can't tell when it is on disk anyways, sync? */ mds->mds_last_committed = mds->mds_last_rcvd; return 0; } static int mds_ext2_journal_data(struct file *filp) { return 0; } static struct mds_fs_operations mds_ext2_fs_ops = { fs_owner: THIS_MODULE, fs_start: mds_ext2_start, fs_commit: mds_ext2_stop, fs_setattr: mds_ext2_setattr, fs_set_objid: mds_ext2_set_objid, fs_get_objid: mds_ext2_get_objid, fs_readpage: mds_ext2_readpage, fs_delete_inode: mds_ext2_delete_inode, cl_delete_inode: clear_inode, fs_journal_data: mds_ext2_journal_data, fs_set_last_rcvd: mds_ext2_set_last_rcvd, }; static int __init mds_ext2_init(void) { return mds_register_fs_type(&mds_ext2_fs_ops, "ext2"); } static void __exit mds_ext2_exit(void) { mds_unregister_fs_type("ext2"); } MODULE_AUTHOR("Cluster File Systems, Inc. "); MODULE_DESCRIPTION("Lustre MDS ext2 Filesystem Helper v0.1"); MODULE_LICENSE("GPL"); module_init(mds_ext2_init); module_exit(mds_ext2_exit);