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 \
--- /dev/null
+
+#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,
+};
+++ /dev/null
-#ifndef _FS_CEPH_BUFFERLIST_H
-#define _FS_CEPH_BUFFERLIST_H
-
-#include <linux/uio.h>
-
-/*
- * 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
--- /dev/null
+
+#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,
+*/
+};
--- /dev/null
+
+#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,
+*/
+};
#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; i<ci->i_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,
+*/
+};
}
-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; i<ci->i_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;
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;
-#ifndef _FS_CEPH_CEPH_H
-#define _FS_CEPH_CEPH_H
+#ifndef _FS_CEPH_SUPER_H
+#define _FS_CEPH_SUPER_H
#include <linux/ceph_fs.h>
#include <linux/fs.h>
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)
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 */