From: Sage Weil Date: Tue, 15 Apr 2008 20:26:48 +0000 (-0700) Subject: kclient: force dir open flags to O_DIRECTORY...hrm X-Git-Tag: v0.2~204^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c1d3efb14b9030023355fa6fc8ec1e7b27106010;p=ceph.git kclient: force dir open flags to O_DIRECTORY...hrm --- diff --git a/src/kernel/client.c b/src/kernel/client.c index ce8e8deadc223..2706d9e1a2cb1 100644 --- a/src/kernel/client.c +++ b/src/kernel/client.c @@ -45,7 +45,8 @@ static void put_client_counter(void) spin_unlock(&ceph_client_spinlock); } -static struct dentry *open_root_dentry(struct ceph_client *client, struct ceph_mount_args *args) +static struct dentry *open_root_dentry(struct ceph_client *client, + struct ceph_mount_args *args) { struct ceph_mds_client *mdsc = &client->mdsc; struct ceph_mds_request *req = 0; @@ -55,7 +56,8 @@ static struct dentry *open_root_dentry(struct ceph_client *client, struct ceph_m /* open dir */ dout(30, "open_root_inode opening '%s'\n", args->path); - req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_OPEN, 1, args->path, 0, 0); + req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_OPEN, + 1, args->path, 0, 0); if (IS_ERR(req)) return ERR_PTR(PTR_ERR(req)); req->r_expects_cap = 1; @@ -76,7 +78,8 @@ static struct dentry *open_root_dentry(struct ceph_client *client, struct ceph_m /* * mount: join the ceph cluster. */ -int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args, struct vfsmount *mnt) +int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args, + struct vfsmount *mnt) { struct ceph_msg *mount_msg; struct dentry *root; diff --git a/src/kernel/file.c b/src/kernel/file.c index 71a70b0c99c99..59411729d7a53 100644 --- a/src/kernel/file.c +++ b/src/kernel/file.c @@ -46,20 +46,19 @@ prepare_open_request(struct super_block *sb, struct dentry *dentry, } -static int ceph_init_file(struct inode *inode, struct file *file, - int flags) +static int ceph_init_file(struct inode *inode, struct file *file, int flags) { struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_file_info *cf; - int mode = ceph_file_mode(flags); + int fmode = ceph_file_mode(flags); cf = kzalloc(sizeof(*cf), GFP_KERNEL); if (cf == NULL) return -ENOMEM; file->private_data = cf; - cf->mode = mode; - ceph_get_mode(ci, mode); + cf->mode = fmode; + ceph_get_mode(ci, fmode); return 0; } @@ -73,10 +72,15 @@ int ceph_open(struct inode *inode, struct file *file) struct ceph_mds_request *req; struct ceph_file_info *cf = file->private_data; int err; + int fmode, wantcaps; /* filter out O_CREAT|O_EXCL; vfs did that already. yuck. */ int flags = file->f_flags & ~(O_CREAT|O_EXCL); - int mode = ceph_file_mode(flags); + if (S_ISDIR(inode->i_mode)) + flags = O_DIRECTORY; + + fmode = ceph_file_mode(flags); + wantcaps = ceph_caps_for_mode(fmode); dout(5, "open inode %p ino %llx file %p\n", inode, ceph_ino(inode), file); @@ -87,16 +91,16 @@ int ceph_open(struct inode *inode, struct file *file) /* can we re-use existing caps? */ spin_lock(&inode->i_lock); - if ((__ceph_caps_issued(ci) & mode) == mode) { - dout(10, "open mode %d using existing caps on %p\n", - mode, inode); + if ((__ceph_caps_issued(ci) & wantcaps) == wantcaps) { + dout(10, "open fmode %d caps %d using existing on %p\n", + fmode, wantcaps, inode); spin_unlock(&inode->i_lock); err = ceph_init_file(inode, file, flags); BUG_ON(err); /* fixme */ return 0; } spin_unlock(&inode->i_lock); - dout(10, "open mode %d, don't have caps\n", mode); + dout(10, "open mode %d, don't have caps %d\n", fmode, wantcaps); req = prepare_open_request(inode->i_sb, dentry, flags, 0); if (IS_ERR(req)) @@ -131,7 +135,7 @@ int ceph_lookup_open(struct inode *dir, struct dentry *dentry, int flags = nd->intent.open.flags; dout(5, "ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n", dentry, dentry->d_name.len, dentry->d_name.name, flags, mode); - + /* do the open */ req = prepare_open_request(dir->i_sb, dentry, flags, mode); if (IS_ERR(req)) diff --git a/src/kernel/super.c b/src/kernel/super.c index 84adfbe61236b..b2b651879a31b 100644 --- a/src/kernel/super.c +++ b/src/kernel/super.c @@ -163,12 +163,9 @@ static struct inode *ceph_alloc_inode(struct super_block *sb) static void ceph_destroy_inode(struct inode *inode) { struct ceph_inode_info *ci = ceph_inode(inode); - - dout(30, "destroy_inode %p ino %lu=%llx\n", inode, - inode->i_ino, ceph_ino(inode)); - + dout(30, "destroy_inode %p ino %llx\n", inode, ceph_ino(inode)); + cancel_delayed_work_sync(&ci->i_cap_dwork); kfree(ci->i_symlink); - kmem_cache_free(ceph_inode_cachep, ci); }