From cd13061618014564deef6dd91480f8713b455f60 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 15 Jan 2008 17:03:57 -0800 Subject: [PATCH] some caps bits --- src/TODO | 3 +- src/kernel/client.c | 8 ++--- src/kernel/inode.c | 77 +++++++++++++++++++++-------------------- src/kernel/mds_client.c | 4 +++ src/kernel/super.h | 8 +++-- 5 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/TODO b/src/TODO index 74684f443a763..9857711ec7328 100644 --- a/src/TODO +++ b/src/TODO @@ -21,11 +21,10 @@ code cleanup kernel client - msg layer (patience) - mds client -/ - examine new mds maps to kick requests for failed nodes... + - pin inodes with caps (igrab/iput?) - mechanism to close out old caps - handle file caps, ack back to mds, etc. - actually flush dirty data, too -/ - integrate mds reply trace into cache ? - reconnect to recoverying mds - osd client - readpages (readahead) diff --git a/src/kernel/client.c b/src/kernel/client.c index c240af781f0d3..8985c484e28c4 100644 --- a/src/kernel/client.c +++ b/src/kernel/client.c @@ -46,8 +46,6 @@ static void put_client_counter(void) } - - int parse_open_reply(struct ceph_msg *reply, struct inode *inode) { struct ceph_mds_reply_head *head; @@ -140,6 +138,7 @@ static int open_root_inode(struct ceph_client *client, struct ceph_mount_args *a goto out; } client->sb->s_root = root; + dout(30, "open_root_inode success.\n"); return 0; @@ -161,7 +160,6 @@ int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args) char r; dout(10, "mount start\n"); - while (client->mounting < 7) { get_random_bytes(&r, 1); which = r % args->num_mon; @@ -176,7 +174,7 @@ int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args) dout(10, "mount from mon%d, %d attempts left\n", which, attempts); /* wait */ - dout(10, "mount sent moutn request, waiting for maps\n"); + dout(10, "mount sent mount request, waiting for maps\n"); err = wait_for_completion_timeout(&client->mount_completion, 6*HZ); if (err == -EINTR) return err; @@ -288,6 +286,8 @@ void ceph_destroy_client(struct ceph_client *cl) /* unmount */ /* ... */ + + ceph_messenger_destroy(cl->msgr); put_client_counter(); kfree(cl); diff --git a/src/kernel/inode.c b/src/kernel/inode.c index 375b91b26c826..a5f144a142c2d 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -12,8 +12,24 @@ int ceph_inode_debug = 50; #define DOUT_PREFIX "inode: " #include "super.h" -const struct inode_operations ceph_symlink_iops; +/* + * symlinks + */ +static void * ceph_sym_follow_link(struct dentry *dentry, struct nameidata *nd) +{ + struct ceph_inode_info *ci = ceph_inode(dentry->d_inode); + nd_set_link(nd, ci->i_symlink); + return NULL; +} + +const struct inode_operations ceph_symlink_iops = { + .readlink = generic_readlink, + .follow_link = ceph_sym_follow_link, +}; +/* + * populate an inode based on info from mds + */ int ceph_fill_inode(struct inode *inode, struct ceph_mds_reply_inode *info) { struct ceph_inode_info *ci = ceph_inode(inode); @@ -142,7 +158,7 @@ struct ceph_inode_cap *ceph_add_cap(struct inode *inode, int mds, u32 cap, u32 s { struct ceph_inode_info *ci = ceph_inode(inode); int i; - + for (i=0; ii_nr_caps; i++) if (ci->i_caps[i].mds == mds) break; if (i == ci->i_nr_caps) { @@ -172,6 +188,8 @@ struct ceph_inode_cap *ceph_add_cap(struct inode *inode, int mds, u32 cap, u32 s inode, inode->i_ino, i, cap, cap|ci->i_caps[i].caps, seq, mds); ci->i_caps[i].caps |= cap; ci->i_caps[i].seq = seq; + if (ci->i_nr_caps == 0) + igrab(inode); return &ci->i_caps[i]; } @@ -184,6 +202,18 @@ int ceph_get_caps(struct ceph_inode_info *ci) return have; } +void ceph_remove_caps(struct ceph_inode_info *ci) +{ + if (ci->i_nr_caps) { + iput(&ci->vfs_inode); + ci->i_nr_caps = 0; + if (ci->i_caps != ci->i_caps_static) { + kfree(ci->i_caps); + ci->i_caps = ci->i_caps_static; + ci->i_max_caps = STATIC_CAPS; + } + } +} /* * 0 - ok @@ -196,6 +226,7 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, int mds = session->s_mds; int seq = le32_to_cpu(grant->seq); int newcaps; + int used; dout(10, "handle_cap_grant inode %p ci %p mds%d seq %d\n", inode, ci, mds, seq); @@ -221,9 +252,12 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, newcaps = le32_to_cpu(grant->caps); dout(10, "4\n"); if (cap->caps & ~newcaps) { - dout(10, "revocation: %d -> %d\n", cap->caps, newcaps); - /* FIXME FIXME FIXME DO STUFF HERE */ - /* blindly ack for now: */ + used = ceph_caps_used(ci); + dout(10, "revocation: %d -> %d, used %d\n", cap->caps, newcaps, used); + if (newcaps & used) { + /* FIXME FIXME FIXME DO STUFF HERE */ + /* but blindly ack for now... */ + } cap->caps = newcaps; return 1; /* ack */ } @@ -239,36 +273,3 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, return 0; } - - -/* - * vfs methods - */ -int ceph_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, - struct kstat *stat) -{ - dout(5, "getattr on dentry %p\n", dentry); - return 0; -} - - - -/* - * symlinks - */ - -static void * ceph_sym_follow_link(struct dentry *dentry, struct nameidata *nd) -{ - struct ceph_inode_info *ci = ceph_inode(dentry->d_inode); - nd_set_link(nd, ci->i_symlink); - return NULL; -} - -const struct inode_operations ceph_symlink_iops = { - .readlink = generic_readlink, - .follow_link = ceph_sym_follow_link, -/* .put_link = ceph_vfs_put_link, - .getattr = ceph_vfs_getattr, - .setattr = ceph_vfs_setattr, -*/ -}; diff --git a/src/kernel/mds_client.c b/src/kernel/mds_client.c index 71862a39ea320..c0c5a818b5f6b 100644 --- a/src/kernel/mds_client.c +++ b/src/kernel/mds_client.c @@ -989,6 +989,10 @@ int ceph_mdsc_update_cap_wanted(struct ceph_inode_info *ci, int wanted) } ci->i_cap_wanted = wanted; + + if (wanted == 0) + ceph_remove_caps(ci); + return 0; } diff --git a/src/kernel/super.h b/src/kernel/super.h index 30e10debbde07..d268c11cf45fc 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -147,6 +147,11 @@ static inline int ceph_caps_wanted(struct ceph_inode_info *ci) { if (ci->i_nr_by_mode[3]) want |= CEPH_CAP_WR|CEPH_CAP_WRBUFFER; return want; } + +static inline int ceph_caps_used(struct ceph_inode_info *ci) { + return 0; /* FIXME */ +} + static inline int ceph_file_mode(int flags) { if ((flags & O_DIRECTORY) == O_DIRECTORY) @@ -211,8 +216,7 @@ extern int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args); extern int ceph_fill_inode(struct inode *inode, struct ceph_mds_reply_inode *info); extern struct ceph_inode_cap *ceph_find_cap(struct inode *inode, int want); extern struct ceph_inode_cap *ceph_add_cap(struct inode *inode, int mds, u32 cap, u32 seq); -extern int ceph_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, - struct kstat *stat); +extern void ceph_remove_caps(struct ceph_inode_info *ci); extern int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, struct ceph_mds_session *session); /* addr.c */ -- 2.39.5