]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: force dir open flags to O_DIRECTORY...hrm
authorSage Weil <sage@newdream.net>
Tue, 15 Apr 2008 20:26:48 +0000 (13:26 -0700)
committerSage Weil <sage@newdream.net>
Tue, 15 Apr 2008 20:26:48 +0000 (13:26 -0700)
src/kernel/client.c
src/kernel/file.c
src/kernel/super.c

index ce8e8deadc2235fa5144158d95e31196a6027e00..2706d9e1a2cb18654bb06a56921d886628577e94 100644 (file)
@@ -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;
index 71a70b0c99c997a2118900e56b28e611eb3b6b19..59411729d7a53aa85021c2d90f3071c72d4cd9e1 100644 (file)
@@ -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))
index 84adfbe61236be27afdf60f9adc47fab97563820..b2b651879a31b7f1d38f2592e4774f8cbf56cda8 100644 (file)
@@ -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);
 }