From 67a610c90d4f2197c2fc3bf48fa67c9635a9b2d3 Mon Sep 17 00:00:00 2001 From: patiencew Date: Thu, 11 Oct 2007 17:57:35 +0000 Subject: [PATCH] Initial version of kernel module git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1922 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/kernel/Makefile | 7 ++ trunk/ceph/kernel/ceph_fs.h | 42 +++++++++++ trunk/ceph/kernel/inode.c | 142 ++++++++++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 trunk/ceph/kernel/Makefile create mode 100644 trunk/ceph/kernel/ceph_fs.h create mode 100644 trunk/ceph/kernel/inode.c diff --git a/trunk/ceph/kernel/Makefile b/trunk/ceph/kernel/Makefile new file mode 100644 index 0000000000000..2ad658b5566c3 --- /dev/null +++ b/trunk/ceph/kernel/Makefile @@ -0,0 +1,7 @@ +# +# Makefile for CEPH filesystem. +# + +obj-$(CONFIG_CEPH_FS) += ceph.o + +ceph-objs := inode.o diff --git a/trunk/ceph/kernel/ceph_fs.h b/trunk/ceph/kernel/ceph_fs.h new file mode 100644 index 0000000000000..f9a381d41dc75 --- /dev/null +++ b/trunk/ceph/kernel/ceph_fs.h @@ -0,0 +1,42 @@ +#ifndef _FS_CEPH_CEPH_H +#define _FS_CEPH_CEPH_H + +/* #include */ + +/* + * CEPH file system in-core superblock info + * taken from OSDSuperblock from osd_types.h ?? check with sage + */ +struct ceph_sb_info { + uint64_t magic; + uint64_t fsid; + int32_t whoami; + uint32_t current_epoch; + uint32_t oldest_map; + uint32_t newest_map; +}; + +/* + * CEPH file system in-core inode info + */ +struct ceph_inode_info { + unsigned long val; /* inode from types.h is uint64_t */ + struct inode vfs_inode; +}; + +static inline struct ceph_inode_info *CEPH_I(struct inode *inode) +{ + return list_entry(inode, struct ceph_inode_info, vfs_inode); +} + + +/* file.c */ +extern const struct inode_operations ceph_file_inops; +extern const struct file_operations ceph_file_operations; +extern const struct address_space_operations ceph_aops; + +/* dir.c */ +extern const struct inode_operations ceph_dir_inops; +extern const struct file_operations ceph_dir_operations; + +#endif /* _FS_CEPH_CEPH_H */ diff --git a/trunk/ceph/kernel/inode.c b/trunk/ceph/kernel/inode.c new file mode 100644 index 0000000000000..db5e59d522fd8 --- /dev/null +++ b/trunk/ceph/kernel/inode.c @@ -0,0 +1,142 @@ +#include +#include +#include +#include +#include "ceph_fs.h" +/* #include +#include +#include +#include +#include +#include "ceph_fs.h" */ + +MODULE_AUTHOR("Patience Warnick "); +MODULE_DESCRIPTION("Ceph filesystem for Linux"); +MODULE_LICENSE("GPL"); + + +static void ceph_read_inode(struct inode * inode) +{ + return; +} + +static int ceph_write_inode(struct inode * inode, int unused) +{ + lock_kernel(); + unlock_kernel(); + return 0; +} + +static void ceph_delete_inode(struct inode * inode) +{ + return; +} + +static void ceph_put_super(struct super_block *s) +{ + return; +} + +static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf) +{ + return 0; +} + +static void ceph_write_super(struct super_block *s) +{ + lock_kernel(); + unlock_kernel(); + return; +} + +static struct kmem_cache *ceph_inode_cachep; + +static struct inode *ceph_alloc_inode(struct super_block *sb) +{ + struct ceph_inode_info *ci; + ci = kmem_cache_alloc(ceph_inode_cachep, GFP_KERNEL); + if (!ci) + return NULL; + return &ci->vfs_inode; +} + +static void ceph_destroy_inode(struct inode *inode) +{ + kmem_cache_free(ceph_inode_cachep, CEPH_I(inode)); +} + +static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags) +{ + struct ceph_inode_info *ci = (struct ceph_inode_info *) foo; + + if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == + SLAB_CTOR_CONSTRUCTOR) + inode_init_once(&ci->vfs_inode); +} + +static int init_inodecache(void) +{ + ceph_inode_cachep = kmem_cache_create("ceph_inode_cache", + sizeof(struct ceph_inode_info), + 0, (SLAB_RECLAIM_ACCOUNT| + SLAB_MEM_SPREAD), + init_once, NULL); + if (ceph_inode_cachep == NULL) + return -ENOMEM; + return 0; +} + +static void destroy_inodecache(void) +{ + kmem_cache_destroy(ceph_inode_cachep); +} + +static const struct super_operations ceph_sops = { + .alloc_inode = ceph_alloc_inode, + .destroy_inode = ceph_destroy_inode, + .read_inode = ceph_read_inode, + .write_inode = ceph_write_inode, + .delete_inode = ceph_delete_inode, + .put_super = ceph_put_super, + .write_super = ceph_write_super, + .statfs = ceph_statfs, +}; + +static int ceph_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data, struct vfsmount *mnt) +{ + printk(KERN_INFO "entered ceph_get_sb\n"); + return 0; +} + +static struct file_system_type ceph_fs_type = { + .owner = THIS_MODULE, + .name = "ceph", + .get_sb = ceph_get_sb, + .kill_sb = kill_block_super, +/* .fs_flags = */ +}; + +static int __init init_ceph(void) +{ + int ret = 0; + + printk(KERN_INFO "ceph init\n"); + if (!(ret = init_inodecache())) { + if ((ret = register_filesystem(&ceph_fs_type))) { + destroy_inodecache(); + } + } + return ret; +} + +static void __exit exit_ceph(void) +{ + printk(KERN_INFO "ceph exit\n"); + + unregister_filesystem(&ceph_fs_type); +} + + +module_init(init_ceph); +module_exit(exit_ceph); -- 2.39.5