5 #include <linux/ctype.h>
9 #include <linux/module.h>
12 #include <linux/sched.h>
14 #include <linux/slab.h>
16 #include <linux/string.h>
99 dout(
"sync_fs (non-blocking)\n");
101 dout(
"sync_fs (non-blocking) done\n");
105 dout(
"sync_fs (blocking)\n");
108 dout(
"sync_fs (blocking) done\n");
168 static int parse_fsopt_token(
char *
c,
void *
private)
174 token =
match_token((
char *)c, fsopt_tokens, argstr);
181 pr_err(
"bad mount option arg (not int) "
185 dout(
"got int token %d val %d\n", token, intval);
187 dout(
"got string token %d val %s\n", token,
190 dout(
"got token %d\n", token);
197 argstr[0].to-argstr[0].from,
205 fsopt->
wsize = intval;
208 fsopt->
rsize = intval;
266 dout(
"destroy_mount_options %p\n", args);
271 static int strcmp_null(
const char *
s1,
const char *
s2)
291 ret =
memcmp(fsopt1, fsopt2, ofs);
305 const char *dev_name,
309 const char *dev_name_end;
312 if (!dev_name || !*dev_name)
319 dout(
"parse_mount_options %p, dev_name '%s'\n", fsopt, dev_name);
344 dev_name_end =
strchr(dev_name,
'/');
347 *path = dev_name_end + 1;
350 dev_name_end = dev_name +
strlen(dev_name);
351 *path = dev_name_end;
355 if (*dev_name_end !=
':') {
356 pr_err(
"device name is missing path (no : separator in %s)\n",
360 dout(
"device name '%.*s'\n", (
int)(dev_name_end - dev_name), dev_name);
361 dout(
"server path '%s'\n", *path);
364 parse_fsopt_token, (
void *)fsopt);
366 err = PTR_ERR(*popt);
375 destroy_mount_options(fsopt);
384 static int ceph_show_options(
struct seq_file *
m,
struct dentry *root)
475 const unsigned supported_features =
478 const unsigned required_features = 0;
487 if (IS_ERR(fsc->
client)) {
488 err = PTR_ERR(fsc->
client);
491 fsc->
client->extra_mon_dispatch = extra_mon_dispatch;
492 fsc->
client->monc.want_mdsmap = 1;
549 dout(
"destroy_fs_client %p\n", fsc);
566 dout(
"destroy_fs_client %p done\n", fsc);
577 static void ceph_inode_init_once(
void *
foo)
583 static int __init init_caches(
void)
589 ceph_inode_init_once);
590 if (ceph_inode_cachep ==
NULL)
595 if (ceph_cap_cachep ==
NULL)
600 if (ceph_dentry_cachep ==
NULL)
605 if (ceph_file_cachep ==
NULL)
619 static void destroy_caches(
void)
637 static void ceph_umount_begin(
struct super_block *sb)
641 dout(
"ceph_umount_begin - starting forced umount\n");
652 .sync_fs = ceph_sync_fs,
653 .put_super = ceph_put_super,
654 .show_options = ceph_show_options,
656 .umount_begin = ceph_umount_begin,
663 static struct dentry *open_root_dentry(
struct ceph_fs_client *fsc,
673 dout(
"open_root_inode opening '%s'\n", path);
676 return ERR_CAST(req);
688 dout(
"open_root_inode success\n");
690 fsc->
sb->s_root ==
NULL) {
700 dout(
"open_root_inode success, root dentry is %p\n", root);
705 ceph_mdsc_put_request(req);
719 unsigned long started =
jiffies;
723 dout(
"mount start\n");
730 dout(
"mount opening root\n");
731 root = open_root_dentry(fsc,
"", started);
736 if (fsc->
sb->s_root) {
739 fsc->
sb->s_root = root;
750 dout(
"mount opening base mountpoint\n");
751 root = open_root_dentry(fsc, path, started);
759 dout(
"mount success\n");
780 dout(
"set_super %p data %p\n", s, data);
788 s->
s_op = &ceph_super_ops;
808 static int ceph_compare_super(
struct super_block *sb,
void *data)
815 dout(
"ceph_compare_super %p\n", sb);
817 if (compare_mount_options(fsopt, opt, other)) {
818 dout(
"monitor(s)/mount options don't match\n");
822 ceph_fsid_compare(&opt->
fsid, &other->
client->fsid)) {
823 dout(
"fsid doesn't match\n");
827 dout(
"flags differ\n");
838 static int ceph_register_bdi(
struct super_block *sb,
853 atomic_long_inc_return(&bdi_seq));
860 int flags,
const char *dev_name,
void *data)
866 int (*compare_super)(
struct super_block *,
void *) = ceph_compare_super;
867 const char *path =
NULL;
871 dout(
"ceph_mount\n");
872 err = parse_mount_options(&fsopt, &opt, flags, data, dev_name, &path);
879 fsc = create_fs_client(fsopt, opt);
882 destroy_mount_options(fsopt);
894 compare_super =
NULL;
895 sb =
sget(fs_type, compare_super, ceph_set_super, flags, fsc);
901 if (ceph_sb_to_client(sb) != fsc) {
903 destroy_fs_client(fsc);
904 fsc = ceph_sb_to_client(sb);
905 dout(
"get_sb got existing client %p\n", fsc);
907 dout(
"get_sb using new client %p\n", fsc);
908 err = ceph_register_bdi(sb, fsc);
915 res = ceph_real_mount(fsc, path);
918 dout(
"root %p inode %p ino %llx.%llx\n", res,
929 destroy_fs_client(fsc);
931 dout(
"ceph_mount fail %ld\n", PTR_ERR(res));
938 dout(
"kill_sb %p\n", s);
942 destroy_fs_client(fsc);
949 .kill_sb = ceph_kill_sb,
953 #define _STRINGIFY(x) #x
954 #define STRINGIFY(x) _STRINGIFY(x)
956 static int __init init_ceph(
void)
958 int ret = init_caches();
978 static void __exit exit_ceph(
void)