From 7eedbc55ba3cedf16dd66866b4a36f9c494be2cf Mon Sep 17 00:00:00 2001 From: sageweil Date: Thu, 6 Dec 2007 17:10:46 +0000 Subject: [PATCH] mounts and unmounts. vfs ops stubs git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2186 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/kernel/Makefile | 4 +- trunk/ceph/kernel/addr.c | 13 +++ trunk/ceph/kernel/bufferlist.h | 52 ----------- trunk/ceph/kernel/dir.c | 36 ++++++++ trunk/ceph/kernel/file.c | 44 +++++++++ trunk/ceph/kernel/inode.c | 160 +++++++++++++++++++++++++++++++++ trunk/ceph/kernel/mds_client.c | 49 ---------- trunk/ceph/kernel/super.c | 5 +- trunk/ceph/kernel/super.h | 19 ++-- 9 files changed, 269 insertions(+), 113 deletions(-) create mode 100644 trunk/ceph/kernel/addr.c delete mode 100644 trunk/ceph/kernel/bufferlist.h create mode 100644 trunk/ceph/kernel/dir.c create mode 100644 trunk/ceph/kernel/file.c diff --git a/trunk/ceph/kernel/Makefile b/trunk/ceph/kernel/Makefile index 3f62291a3c1d3..25a456ee8a52e 100644 --- a/trunk/ceph/kernel/Makefile +++ b/trunk/ceph/kernel/Makefile @@ -4,8 +4,8 @@ obj-$(CONFIG_CEPH_FS) += ceph.o -ceph-objs := super.o inode.o \ - bufferlist.o ktcp.o messenger.o \ +ceph-objs := super.o inode.o dir.o file.o addr.o \ + ktcp.o messenger.o \ client.o \ mds_client.o mdsmap.o \ mon_client.o \ diff --git a/trunk/ceph/kernel/addr.c b/trunk/ceph/kernel/addr.c new file mode 100644 index 0000000000000..beae8cdbb65bd --- /dev/null +++ b/trunk/ceph/kernel/addr.c @@ -0,0 +1,13 @@ + +#include "super.h" + +/* +static int ceph_vfs_readpage(struct file *filp, struct page *page) +{ + +} +*/ + +const struct address_space_operations ceph_aops = { +// .readpage = ceph_vfs_readpage, +}; diff --git a/trunk/ceph/kernel/bufferlist.h b/trunk/ceph/kernel/bufferlist.h deleted file mode 100644 index e154321d6c9a3..0000000000000 --- a/trunk/ceph/kernel/bufferlist.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _FS_CEPH_BUFFERLIST_H -#define _FS_CEPH_BUFFERLIST_H - -#include - -/* - * quick and dirty bufferlist struct. - * - * preallocates memory in large chunks, allowing you to append small bits at a - * time in a reasonably efficient fashion... - */ - -#define CEPH_BUFFERLIST_START_KVLEN 8 /* embed some statically, for fast normal case */ - -struct ceph_bufferlist { - struct kvec *b_kv; /* data payload */ - struct kvec b_kv_array[CEPH_BUFFERLIST_START_KVLEN]; - size_t b_kvlen; /* used/defined elements in b_kv */ - size_t b_kvmax; /* allocated size of b_kv array */ - size_t b_len; /* size in bytes of _entire_ bufferlist */ - struct kvec b_append; /* preallocated memory for appending data to this bufferlist */ -}; - -struct ceph_bufferlist_iterator { - int i_kv; /* which kv */ - int i_off; /* offset in that kv */ -}; - -extern void ceph_bl_init(struct ceph_bufferlist *bl); -extern void ceph_bl_clear(struct ceph_bufferlist *bl); -extern void ceph_bl_append_ref(struct ceph_bufferlist *bl, void *dp, int len); -extern void ceph_bl_append_copy(struct ceph_bufferlist *bl, void *p, size_t len); -extern void ceph_bl_append_copied(struct ceph_bufferlist *bl, size_t len); -extern void ceph_bl_prepare_append(struct ceph_bufferlist *bl, int len); - -extern void ceph_bl_iterator_init(struct ceph_bufferlist_iterator *bli); - -extern int ceph_bl_copy(struct ceph_bufferlist *bl, struct ceph_bufferlist_iterator *bli, void *p, int len); - -extern void ceph_bl_iterator_advance(struct ceph_bufferlist *bl, - struct ceph_bufferlist_iterator *bli, - int off); -extern int ceph_bl_decode_have(struct ceph_bufferlist *bl, struct ceph_bufferlist_iterator *bli, int s); - -extern int ceph_bl_decode_64(struct ceph_bufferlist *bl, struct ceph_bufferlist_iterator *bli, __u64 *v); -extern int ceph_bl_decode_32(struct ceph_bufferlist *bl, struct ceph_bufferlist_iterator *bli, __u32 *v); -extern int ceph_bl_decode_16(struct ceph_bufferlist *bl, struct ceph_bufferlist_iterator *bli, __u16 *v); -extern int ceph_bl_decode_8(struct ceph_bufferlist *bl, struct ceph_bufferlist_iterator *bli, __u8 *v); - - - -#endif diff --git a/trunk/ceph/kernel/dir.c b/trunk/ceph/kernel/dir.c new file mode 100644 index 0000000000000..67d40903f13e9 --- /dev/null +++ b/trunk/ceph/kernel/dir.c @@ -0,0 +1,36 @@ + +#include "super.h" + +const struct inode_operations ceph_dir_iops; +const struct file_operations ceph_dir_fops; + +/* +static int ceph_dir_readdir(struct file *filp, void *dirent, filldir_t filldir) +{ +} + +int ceph_dir_release(struct inode *inode, struct file *filp) +{ +} +*/ + +const struct inode_operations ceph_dir_iops = { +/* .create = ceph_vfs_create, + .lookup = ceph_vfs_lookup, + .unlink = ceph_vfs_unlink, + .mkdir = ceph_vfs_mkdir, + .rmdir = ceph_vfs_rmdir, + .mknod = ceph_vfs_mknod, + .rename = ceph_vfs_rename, + .getattr = ceph_vfs_getattr, + .setattr = ceph_vfs_setattr, +*/ +}; + +const struct file_operations ceph_dir_fops = { +/* .read = generic_read_dir, + .readdir = ceph_dir_readdir, +// .open = ceph_file_open, + .release = ceph_dir_release, +*/ +}; diff --git a/trunk/ceph/kernel/file.c b/trunk/ceph/kernel/file.c new file mode 100644 index 0000000000000..31f44c54ca6c2 --- /dev/null +++ b/trunk/ceph/kernel/file.c @@ -0,0 +1,44 @@ + +#include "super.h" + +/* +static ssize_t +ceph_file_read(struct file *filp, char __user * data, size_t count, + loff_t * offset) +{ +} + + +static ssize_t +ceph_file_write(struct file *filp, const char __user * data, + size_t count, loff_t * offset) +{ +} + + +int ceph_file_open(struct inode *inode, struct file *file) +{ +} + + +static int ceph_file_lock(struct file *filp, int cmd, struct file_lock *fl) +{ +} +*/ + +const struct inode_operations ceph_file_iops = { +/* .getattr = ceph_vfs_getattr, + .setattr = ceph_vfs_setattr, +*/ +}; + +const struct file_operations ceph_file_fops = { +/* .llseek = generic_file_llseek, + .read = ceph_file_read, + .write = ceph_file_write, + .open = ceph_file_open, +// .release = ceph_dir_release, + .lock = ceph_file_lock, + .mmap = generic_file_mmap, +*/ +}; diff --git a/trunk/ceph/kernel/inode.c b/trunk/ceph/kernel/inode.c index 946c9e28ac23c..8f9a951d61ffd 100644 --- a/trunk/ceph/kernel/inode.c +++ b/trunk/ceph/kernel/inode.c @@ -7,3 +7,163 @@ #include "super.h" +const struct inode_operations ceph_symlink_iops; + +struct inode *ceph_new_inode(struct super_block *sb, + struct ceph_mds_reply_inode *info) { + struct inode *inode; + + inode = new_inode(sb); + if (inode == NULL) + return ERR_PTR(-ENOMEM); + + inode->i_ino = le64_to_cpu(info->ino); + inode->i_mode = le32_to_cpu(info->mode) | S_IFDIR; + inode->i_uid = le32_to_cpu(info->uid); + inode->i_gid = le32_to_cpu(info->gid); + inode->i_nlink = le32_to_cpu(info->nlink); + inode->i_size = le64_to_cpu(info->size); + inode->i_rdev = le32_to_cpu(info->rdev); + inode->i_blocks = 0; + inode->i_rdev = 0; + dout(30, "new_inode ino=%lx by %d.%d sz=%llu\n", inode->i_ino, + inode->i_uid, inode->i_gid, inode->i_size); + + ceph_decode_timespec(&inode->i_atime, &info->atime); + ceph_decode_timespec(&inode->i_mtime, &info->mtime); + ceph_decode_timespec(&inode->i_ctime, &info->ctime); + +#if 0 + /* ceph inode */ + ci->i_layout = info->layout; /* swab? */ + + if (le32_to_cpu(info->fragtree.nsplits) == 0) { + ci->i_fragtree = ci->i_fragtree_static; + } else { + //ci->i_fragtree = kmalloc(...); + BUG_ON(1); // write me + } + ci->i_fragtree->nsplits = le32_to_cpu(info->fragtree.nsplits); + for (i=0; ii_fragtree->nsplits; i++) + ci->i_fragtree->splits[i] = le32_to_cpu(info->fragtree.splits[i]); + + ci->i_frag_map_nr = 1; + ci->i_frag_map = ci->i_frag_map_static; + ci->i_frag_map[0].frag = 0; + ci->i_frag_map[0].mds = 0; /* fixme */ + + ci->i_nr_caps = 0; + ci->i_caps = ci->i_caps_static; + ci->i_wr_size = 0; + ci->i_wr_mtime.tv_sec = 0; + ci->i_wr_mtime.tv_usec = 0; +#endif + + inode->i_mapping->a_ops = &ceph_aops; + + switch (inode->i_mode & S_IFMT) { + case S_IFIFO: + case S_IFBLK: + case S_IFCHR: + case S_IFSOCK: + init_special_inode(inode, inode->i_mode, inode->i_rdev); + break; + case S_IFREG: + inode->i_op = &ceph_file_iops; + inode->i_fop = &ceph_file_fops; + break; + case S_IFLNK: + inode->i_op = &ceph_symlink_iops; + break; + case S_IFDIR: + inc_nlink(inode); + inode->i_op = &ceph_dir_iops; + inode->i_fop = &ceph_dir_fops; + break; + default: + derr(0, "BAD mode 0x%x S_IFMT 0x%x\n", + inode->i_mode, inode->i_mode & S_IFMT); + return ERR_PTR(-EINVAL); + } + + return inode; +} + +/* +static int +ceph_vfs_create(struct inode *dir, struct dentry *dentry, int mode, + struct nameidata *nd) +{ +} + +static int ceph_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +{ +} + +static struct dentry *ceph_vfs_lookup(struct inode *dir, struct dentry *dentry, + struct nameidata *nameidata) +{ +} + +static int ceph_vfs_unlink(struct inode *i, struct dentry *d) +{ +} + +static int ceph_vfs_rmdir(struct inode *i, struct dentry *d) +{ +} + +static int +ceph_vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry) +{ +} + +static int +ceph_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat) +{ +} + +static int ceph_vfs_setattr(struct dentry *dentry, struct iattr *iattr) +{ +} + +static int ceph_vfs_readlink(struct dentry *dentry, char __user * buffer, + int buflen) +{ +} + +static void *ceph_vfs_follow_link(struct dentry *dentry, struct nameidata *nd) +{ +} + +static void ceph_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) +{ +} + +static int +ceph_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) +{ +} + +static int +ceph_vfs_link(struct dentry *old_dentry, struct inode *dir, + struct dentry *dentry) +{ +} + +static int +ceph_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) +{ +} +*/ + +const struct inode_operations ceph_symlink_iops = { +/* .readlink = ceph_vfs_readlink, + .follow_link = ceph_vfs_follow_link, + .put_link = ceph_vfs_put_link, + .getattr = ceph_vfs_getattr, + .setattr = ceph_vfs_setattr, +*/ +}; diff --git a/trunk/ceph/kernel/mds_client.c b/trunk/ceph/kernel/mds_client.c index 36f63feac85ac..1e0a68b2df96f 100644 --- a/trunk/ceph/kernel/mds_client.c +++ b/trunk/ceph/kernel/mds_client.c @@ -570,55 +570,6 @@ void ceph_mdsc_destroy_reply_info(struct ceph_mds_reply_info *info) } -void ceph_mdsc_fill_inode(struct inode *inode, struct ceph_mds_reply_inode *info) -{ - struct ceph_inode_info *ci = CEPH_I(inode); - int mask = le32_to_cpu(info->mask); - int i; - - /* vfs inode */ - inode->i_ino = le64_to_cpu(info->ino); - inode->i_mode = le32_to_cpu(info->mode) | S_IFDIR; - inode->i_uid = le32_to_cpu(info->uid); - inode->i_gid = le32_to_cpu(info->gid); - inode->i_nlink = le32_to_cpu(info->nlink); - inode->i_size = le64_to_cpu(info->size); - inode->i_rdev = le32_to_cpu(info->rdev); - - dout(30, "mdsc fill_inode ino=%lx by %d.%d sz=%llu\n", inode->i_ino, - inode->i_uid, inode->i_gid, inode->i_size); - - ceph_decode_timespec(&inode->i_atime, &info->atime); - ceph_decode_timespec(&inode->i_mtime, &info->mtime); - ceph_decode_timespec(&inode->i_ctime, &info->ctime); - - /* ceph inode */ - ci->i_layout = info->layout; /* swab? */ - - if (le32_to_cpu(info->fragtree.nsplits) == 0) { - ci->i_fragtree = ci->i_fragtree_static; - } else { - //ci->i_fragtree = kmalloc(...); - BUG_ON(1); // write me - } - ci->i_fragtree->nsplits = le32_to_cpu(info->fragtree.nsplits); - for (i=0; ii_fragtree->nsplits; i++) - ci->i_fragtree->splits[i] = le32_to_cpu(info->fragtree.splits[i]); - - ci->i_frag_map_nr = 1; - ci->i_frag_map = ci->i_frag_map_static; - ci->i_frag_map[0].frag = 0; - ci->i_frag_map[0].mds = 0; /* fixme */ - - ci->i_nr_caps = 0; - ci->i_caps = ci->i_caps_static; - ci->i_wr_size = 0; - ci->i_wr_mtime.tv_sec = 0; - ci->i_wr_mtime.tv_usec = 0; -} - - - void ceph_mdsc_handle_forward(struct ceph_mds_client *mdsc, struct ceph_msg *msg) { struct ceph_mds_request *req; diff --git a/trunk/ceph/kernel/super.c b/trunk/ceph/kernel/super.c index b5477214f3457..7cd83ba8934bc 100644 --- a/trunk/ceph/kernel/super.c +++ b/trunk/ceph/kernel/super.c @@ -363,13 +363,12 @@ static int open_root_inode(struct super_block *sb, struct ceph_mount_args *args) rootinfo = &rinfo.trace_in[rinfo.trace_nr-1]; /* construct root inode */ - inode = new_inode(sb); + inode = ceph_new_inode(sb, rootinfo->in); if (!inode) { err = -ENOMEM; goto out; } - dout(30, "open_root_inode filling inode\n"); - ceph_mdsc_fill_inode(inode, rootinfo->in); + root = d_alloc_root(inode); if (!root) { err = -ENOMEM; diff --git a/trunk/ceph/kernel/super.h b/trunk/ceph/kernel/super.h index 7940296e5428d..a05eaac026af6 100644 --- a/trunk/ceph/kernel/super.h +++ b/trunk/ceph/kernel/super.h @@ -1,5 +1,5 @@ -#ifndef _FS_CEPH_CEPH_H -#define _FS_CEPH_CEPH_H +#ifndef _FS_CEPH_SUPER_H +#define _FS_CEPH_SUPER_H #include #include @@ -67,7 +67,7 @@ struct ceph_inode_info { off_t i_wr_size; struct ceph_timeval i_wr_mtime; - struct inode vfs_inode; + struct inode vfs_inode; /* at end */ }; static inline struct ceph_inode_info *CEPH_I(struct inode *inode) @@ -75,15 +75,20 @@ static inline struct ceph_inode_info *CEPH_I(struct inode *inode) return list_entry(inode, struct ceph_inode_info, vfs_inode); } +/* inode.c */ +extern struct inode *ceph_new_inode(struct super_block *sb, + struct ceph_mds_reply_inode *info); +/* addr.c */ +extern const struct address_space_operations ceph_aops; /* file.c */ -extern const struct inode_operations ceph_file_inops; -extern const struct file_operations ceph_file_operations; +extern const struct inode_operations ceph_file_iops; +extern const struct file_operations ceph_file_fops; 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; +extern const struct inode_operations ceph_dir_iops; +extern const struct file_operations ceph_dir_fops; #endif /* _FS_CEPH_CEPH_H */ -- 2.39.5