summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ceph/caps.c26
-rw-r--r--fs/ceph/dir.c28
-rw-r--r--fs/ceph/super.c27
-rw-r--r--fs/ceph/super.h2
-rw-r--r--net/ceph/ceph_common.c7
5 files changed, 52 insertions, 38 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 6582c4507e6c..0e5bd3e3344e 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3965,6 +3965,32 @@ void ceph_put_fmode(struct ceph_inode_info *ci, int fmode)
3965} 3965}
3966 3966
3967/* 3967/*
3968 * For a soon-to-be unlinked file, drop the AUTH_RDCACHE caps. If it
3969 * looks like the link count will hit 0, drop any other caps (other
3970 * than PIN) we don't specifically want (due to the file still being
3971 * open).
3972 */
3973int ceph_drop_caps_for_unlink(struct inode *inode)
3974{
3975 struct ceph_inode_info *ci = ceph_inode(inode);
3976 int drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
3977
3978 spin_lock(&ci->i_ceph_lock);
3979 if (inode->i_nlink == 1) {
3980 drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN);
3981
3982 ci->i_ceph_flags |= CEPH_I_NODELAY;
3983 if (__ceph_caps_dirty(ci)) {
3984 struct ceph_mds_client *mdsc =
3985 ceph_inode_to_client(inode)->mdsc;
3986 __cap_delay_requeue_front(mdsc, ci);
3987 }
3988 }
3989 spin_unlock(&ci->i_ceph_lock);
3990 return drop;
3991}
3992
3993/*
3968 * Helpers for embedding cap and dentry lease releases into mds 3994 * Helpers for embedding cap and dentry lease releases into mds
3969 * requests. 3995 * requests.
3970 * 3996 *
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 0c4346806e17..f1d9c6cc0491 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1003,26 +1003,6 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir,
1003} 1003}
1004 1004
1005/* 1005/*
1006 * For a soon-to-be unlinked file, drop the AUTH_RDCACHE caps. If it
1007 * looks like the link count will hit 0, drop any other caps (other
1008 * than PIN) we don't specifically want (due to the file still being
1009 * open).
1010 */
1011static int drop_caps_for_unlink(struct inode *inode)
1012{
1013 struct ceph_inode_info *ci = ceph_inode(inode);
1014 int drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
1015
1016 spin_lock(&ci->i_ceph_lock);
1017 if (inode->i_nlink == 1) {
1018 drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN);
1019 ci->i_ceph_flags |= CEPH_I_NODELAY;
1020 }
1021 spin_unlock(&ci->i_ceph_lock);
1022 return drop;
1023}
1024
1025/*
1026 * rmdir and unlink are differ only by the metadata op code 1006 * rmdir and unlink are differ only by the metadata op code
1027 */ 1007 */
1028static int ceph_unlink(struct inode *dir, struct dentry *dentry) 1008static int ceph_unlink(struct inode *dir, struct dentry *dentry)
@@ -1056,7 +1036,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry)
1056 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); 1036 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);
1057 req->r_dentry_drop = CEPH_CAP_FILE_SHARED; 1037 req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
1058 req->r_dentry_unless = CEPH_CAP_FILE_EXCL; 1038 req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
1059 req->r_inode_drop = drop_caps_for_unlink(inode); 1039 req->r_inode_drop = ceph_drop_caps_for_unlink(inode);
1060 err = ceph_mdsc_do_request(mdsc, dir, req); 1040 err = ceph_mdsc_do_request(mdsc, dir, req);
1061 if (!err && !req->r_reply_info.head->is_dentry) 1041 if (!err && !req->r_reply_info.head->is_dentry)
1062 d_delete(dentry); 1042 d_delete(dentry);
@@ -1104,8 +1084,10 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
1104 req->r_dentry_unless = CEPH_CAP_FILE_EXCL; 1084 req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
1105 /* release LINK_RDCACHE on source inode (mds will lock it) */ 1085 /* release LINK_RDCACHE on source inode (mds will lock it) */
1106 req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; 1086 req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
1107 if (d_really_is_positive(new_dentry)) 1087 if (d_really_is_positive(new_dentry)) {
1108 req->r_inode_drop = drop_caps_for_unlink(d_inode(new_dentry)); 1088 req->r_inode_drop =
1089 ceph_drop_caps_for_unlink(d_inode(new_dentry));
1090 }
1109 err = ceph_mdsc_do_request(mdsc, old_dir, req); 1091 err = ceph_mdsc_do_request(mdsc, old_dir, req);
1110 if (!err && !req->r_reply_info.head->is_dentry) { 1092 if (!err && !req->r_reply_info.head->is_dentry) {
1111 /* 1093 /*
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index a62d2a9841dc..fb2bc9c15a23 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -225,6 +225,7 @@ static int parse_fsopt_token(char *c, void *private)
225 return -ENOMEM; 225 return -ENOMEM;
226 break; 226 break;
227 case Opt_mds_namespace: 227 case Opt_mds_namespace:
228 kfree(fsopt->mds_namespace);
228 fsopt->mds_namespace = kstrndup(argstr[0].from, 229 fsopt->mds_namespace = kstrndup(argstr[0].from,
229 argstr[0].to-argstr[0].from, 230 argstr[0].to-argstr[0].from,
230 GFP_KERNEL); 231 GFP_KERNEL);
@@ -232,6 +233,7 @@ static int parse_fsopt_token(char *c, void *private)
232 return -ENOMEM; 233 return -ENOMEM;
233 break; 234 break;
234 case Opt_fscache_uniq: 235 case Opt_fscache_uniq:
236 kfree(fsopt->fscache_uniq);
235 fsopt->fscache_uniq = kstrndup(argstr[0].from, 237 fsopt->fscache_uniq = kstrndup(argstr[0].from,
236 argstr[0].to-argstr[0].from, 238 argstr[0].to-argstr[0].from,
237 GFP_KERNEL); 239 GFP_KERNEL);
@@ -711,14 +713,17 @@ static int __init init_caches(void)
711 goto bad_dentry; 713 goto bad_dentry;
712 714
713 ceph_file_cachep = KMEM_CACHE(ceph_file_info, SLAB_MEM_SPREAD); 715 ceph_file_cachep = KMEM_CACHE(ceph_file_info, SLAB_MEM_SPREAD);
714
715 if (!ceph_file_cachep) 716 if (!ceph_file_cachep)
716 goto bad_file; 717 goto bad_file;
717 718
718 if ((error = ceph_fscache_register())) 719 error = ceph_fscache_register();
719 goto bad_file; 720 if (error)
721 goto bad_fscache;
720 722
721 return 0; 723 return 0;
724
725bad_fscache:
726 kmem_cache_destroy(ceph_file_cachep);
722bad_file: 727bad_file:
723 kmem_cache_destroy(ceph_dentry_cachep); 728 kmem_cache_destroy(ceph_dentry_cachep);
724bad_dentry: 729bad_dentry:
@@ -836,7 +841,6 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)
836 int err; 841 int err;
837 unsigned long started = jiffies; /* note the start time */ 842 unsigned long started = jiffies; /* note the start time */
838 struct dentry *root; 843 struct dentry *root;
839 int first = 0; /* first vfsmount for this super_block */
840 844
841 dout("mount start %p\n", fsc); 845 dout("mount start %p\n", fsc);
842 mutex_lock(&fsc->client->mount_mutex); 846 mutex_lock(&fsc->client->mount_mutex);
@@ -861,17 +865,17 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)
861 path = fsc->mount_options->server_path + 1; 865 path = fsc->mount_options->server_path + 1;
862 dout("mount opening path %s\n", path); 866 dout("mount opening path %s\n", path);
863 } 867 }
868
869 err = ceph_fs_debugfs_init(fsc);
870 if (err < 0)
871 goto out;
872
864 root = open_root_dentry(fsc, path, started); 873 root = open_root_dentry(fsc, path, started);
865 if (IS_ERR(root)) { 874 if (IS_ERR(root)) {
866 err = PTR_ERR(root); 875 err = PTR_ERR(root);
867 goto out; 876 goto out;
868 } 877 }
869 fsc->sb->s_root = dget(root); 878 fsc->sb->s_root = dget(root);
870 first = 1;
871
872 err = ceph_fs_debugfs_init(fsc);
873 if (err < 0)
874 goto fail;
875 } else { 879 } else {
876 root = dget(fsc->sb->s_root); 880 root = dget(fsc->sb->s_root);
877 } 881 }
@@ -881,11 +885,6 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)
881 mutex_unlock(&fsc->client->mount_mutex); 885 mutex_unlock(&fsc->client->mount_mutex);
882 return root; 886 return root;
883 887
884fail:
885 if (first) {
886 dput(fsc->sb->s_root);
887 fsc->sb->s_root = NULL;
888 }
889out: 888out:
890 mutex_unlock(&fsc->client->mount_mutex); 889 mutex_unlock(&fsc->client->mount_mutex);
891 return ERR_PTR(err); 890 return ERR_PTR(err);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 21b2e5b004eb..1c2086e0fec2 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -987,7 +987,7 @@ extern void ceph_check_caps(struct ceph_inode_info *ci, int flags,
987 struct ceph_mds_session *session); 987 struct ceph_mds_session *session);
988extern void ceph_check_delayed_caps(struct ceph_mds_client *mdsc); 988extern void ceph_check_delayed_caps(struct ceph_mds_client *mdsc);
989extern void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc); 989extern void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc);
990 990extern int ceph_drop_caps_for_unlink(struct inode *inode);
991extern int ceph_encode_inode_release(void **p, struct inode *inode, 991extern int ceph_encode_inode_release(void **p, struct inode *inode,
992 int mds, int drop, int unless, int force); 992 int mds, int drop, int unless, int force);
993extern int ceph_encode_dentry_release(void **p, struct dentry *dn, 993extern int ceph_encode_dentry_release(void **p, struct dentry *dn,
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index 1e492ef2a33d..4d4c82229e9e 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -418,6 +418,7 @@ ceph_parse_options(char *options, const char *dev_name,
418 opt->flags |= CEPH_OPT_FSID; 418 opt->flags |= CEPH_OPT_FSID;
419 break; 419 break;
420 case Opt_name: 420 case Opt_name:
421 kfree(opt->name);
421 opt->name = kstrndup(argstr[0].from, 422 opt->name = kstrndup(argstr[0].from,
422 argstr[0].to-argstr[0].from, 423 argstr[0].to-argstr[0].from,
423 GFP_KERNEL); 424 GFP_KERNEL);
@@ -427,6 +428,9 @@ ceph_parse_options(char *options, const char *dev_name,
427 } 428 }
428 break; 429 break;
429 case Opt_secret: 430 case Opt_secret:
431 ceph_crypto_key_destroy(opt->key);
432 kfree(opt->key);
433
430 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL); 434 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
431 if (!opt->key) { 435 if (!opt->key) {
432 err = -ENOMEM; 436 err = -ENOMEM;
@@ -437,6 +441,9 @@ ceph_parse_options(char *options, const char *dev_name,
437 goto out; 441 goto out;
438 break; 442 break;
439 case Opt_key: 443 case Opt_key:
444 ceph_crypto_key_destroy(opt->key);
445 kfree(opt->key);
446
440 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL); 447 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
441 if (!opt->key) { 448 if (!opt->key) {
442 err = -ENOMEM; 449 err = -ENOMEM;