diff options
Diffstat (limited to 'fs/ceph/super.c')
-rw-r--r-- | fs/ceph/super.c | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/fs/ceph/super.c b/fs/ceph/super.c index fa87f51e38e1..9922628532b2 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "ceph_debug.h" | 2 | #include "ceph_debug.h" |
3 | 3 | ||
4 | #include <linux/backing-dev.h> | 4 | #include <linux/backing-dev.h> |
5 | #include <linux/ctype.h> | ||
5 | #include <linux/fs.h> | 6 | #include <linux/fs.h> |
6 | #include <linux/inet.h> | 7 | #include <linux/inet.h> |
7 | #include <linux/in6.h> | 8 | #include <linux/in6.h> |
@@ -101,12 +102,21 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
101 | } | 102 | } |
102 | 103 | ||
103 | 104 | ||
104 | static int ceph_syncfs(struct super_block *sb, int wait) | 105 | static int ceph_sync_fs(struct super_block *sb, int wait) |
105 | { | 106 | { |
106 | dout("sync_fs %d\n", wait); | 107 | struct ceph_client *client = ceph_sb_to_client(sb); |
108 | |||
109 | if (!wait) { | ||
110 | dout("sync_fs (non-blocking)\n"); | ||
111 | ceph_flush_dirty_caps(&client->mdsc); | ||
112 | dout("sync_fs (non-blocking) done\n"); | ||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | dout("sync_fs (blocking)\n"); | ||
107 | ceph_osdc_sync(&ceph_sb_to_client(sb)->osdc); | 117 | ceph_osdc_sync(&ceph_sb_to_client(sb)->osdc); |
108 | ceph_mdsc_sync(&ceph_sb_to_client(sb)->mdsc); | 118 | ceph_mdsc_sync(&ceph_sb_to_client(sb)->mdsc); |
109 | dout("sync_fs %d done\n", wait); | 119 | dout("sync_fs (blocking) done\n"); |
110 | return 0; | 120 | return 0; |
111 | } | 121 | } |
112 | 122 | ||
@@ -150,9 +160,7 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
150 | struct ceph_mount_args *args = client->mount_args; | 160 | struct ceph_mount_args *args = client->mount_args; |
151 | 161 | ||
152 | if (args->flags & CEPH_OPT_FSID) | 162 | if (args->flags & CEPH_OPT_FSID) |
153 | seq_printf(m, ",fsidmajor=%llu,fsidminor%llu", | 163 | seq_printf(m, ",fsid=%pU", &args->fsid); |
154 | le64_to_cpu(*(__le64 *)&args->fsid.fsid[0]), | ||
155 | le64_to_cpu(*(__le64 *)&args->fsid.fsid[8])); | ||
156 | if (args->flags & CEPH_OPT_NOSHARE) | 164 | if (args->flags & CEPH_OPT_NOSHARE) |
157 | seq_puts(m, ",noshare"); | 165 | seq_puts(m, ",noshare"); |
158 | if (args->flags & CEPH_OPT_DIRSTAT) | 166 | if (args->flags & CEPH_OPT_DIRSTAT) |
@@ -279,7 +287,7 @@ static const struct super_operations ceph_super_ops = { | |||
279 | .alloc_inode = ceph_alloc_inode, | 287 | .alloc_inode = ceph_alloc_inode, |
280 | .destroy_inode = ceph_destroy_inode, | 288 | .destroy_inode = ceph_destroy_inode, |
281 | .write_inode = ceph_write_inode, | 289 | .write_inode = ceph_write_inode, |
282 | .sync_fs = ceph_syncfs, | 290 | .sync_fs = ceph_sync_fs, |
283 | .put_super = ceph_put_super, | 291 | .put_super = ceph_put_super, |
284 | .show_options = ceph_show_options, | 292 | .show_options = ceph_show_options, |
285 | .statfs = ceph_statfs, | 293 | .statfs = ceph_statfs, |
@@ -322,9 +330,6 @@ const char *ceph_msg_type_name(int type) | |||
322 | * mount options | 330 | * mount options |
323 | */ | 331 | */ |
324 | enum { | 332 | enum { |
325 | Opt_fsidmajor, | ||
326 | Opt_fsidminor, | ||
327 | Opt_monport, | ||
328 | Opt_wsize, | 333 | Opt_wsize, |
329 | Opt_rsize, | 334 | Opt_rsize, |
330 | Opt_osdtimeout, | 335 | Opt_osdtimeout, |
@@ -339,6 +344,7 @@ enum { | |||
339 | Opt_congestion_kb, | 344 | Opt_congestion_kb, |
340 | Opt_last_int, | 345 | Opt_last_int, |
341 | /* int args above */ | 346 | /* int args above */ |
347 | Opt_fsid, | ||
342 | Opt_snapdirname, | 348 | Opt_snapdirname, |
343 | Opt_name, | 349 | Opt_name, |
344 | Opt_secret, | 350 | Opt_secret, |
@@ -355,9 +361,6 @@ enum { | |||
355 | }; | 361 | }; |
356 | 362 | ||
357 | static match_table_t arg_tokens = { | 363 | static match_table_t arg_tokens = { |
358 | {Opt_fsidmajor, "fsidmajor=%ld"}, | ||
359 | {Opt_fsidminor, "fsidminor=%ld"}, | ||
360 | {Opt_monport, "monport=%d"}, | ||
361 | {Opt_wsize, "wsize=%d"}, | 364 | {Opt_wsize, "wsize=%d"}, |
362 | {Opt_rsize, "rsize=%d"}, | 365 | {Opt_rsize, "rsize=%d"}, |
363 | {Opt_osdtimeout, "osdtimeout=%d"}, | 366 | {Opt_osdtimeout, "osdtimeout=%d"}, |
@@ -371,6 +374,7 @@ static match_table_t arg_tokens = { | |||
371 | {Opt_readdir_max_bytes, "readdir_max_bytes=%d"}, | 374 | {Opt_readdir_max_bytes, "readdir_max_bytes=%d"}, |
372 | {Opt_congestion_kb, "write_congestion_kb=%d"}, | 375 | {Opt_congestion_kb, "write_congestion_kb=%d"}, |
373 | /* int args above */ | 376 | /* int args above */ |
377 | {Opt_fsid, "fsid=%s"}, | ||
374 | {Opt_snapdirname, "snapdirname=%s"}, | 378 | {Opt_snapdirname, "snapdirname=%s"}, |
375 | {Opt_name, "name=%s"}, | 379 | {Opt_name, "name=%s"}, |
376 | {Opt_secret, "secret=%s"}, | 380 | {Opt_secret, "secret=%s"}, |
@@ -386,6 +390,36 @@ static match_table_t arg_tokens = { | |||
386 | {-1, NULL} | 390 | {-1, NULL} |
387 | }; | 391 | }; |
388 | 392 | ||
393 | static int parse_fsid(const char *str, struct ceph_fsid *fsid) | ||
394 | { | ||
395 | int i = 0; | ||
396 | char tmp[3]; | ||
397 | int err = -EINVAL; | ||
398 | int d; | ||
399 | |||
400 | dout("parse_fsid '%s'\n", str); | ||
401 | tmp[2] = 0; | ||
402 | while (*str && i < 16) { | ||
403 | if (ispunct(*str)) { | ||
404 | str++; | ||
405 | continue; | ||
406 | } | ||
407 | if (!isxdigit(str[0]) || !isxdigit(str[1])) | ||
408 | break; | ||
409 | tmp[0] = str[0]; | ||
410 | tmp[1] = str[1]; | ||
411 | if (sscanf(tmp, "%x", &d) < 1) | ||
412 | break; | ||
413 | fsid->fsid[i] = d & 0xff; | ||
414 | i++; | ||
415 | str += 2; | ||
416 | } | ||
417 | |||
418 | if (i == 16) | ||
419 | err = 0; | ||
420 | dout("parse_fsid ret %d got fsid %pU", err, fsid); | ||
421 | return err; | ||
422 | } | ||
389 | 423 | ||
390 | static struct ceph_mount_args *parse_mount_args(int flags, char *options, | 424 | static struct ceph_mount_args *parse_mount_args(int flags, char *options, |
391 | const char *dev_name, | 425 | const char *dev_name, |
@@ -469,12 +503,6 @@ static struct ceph_mount_args *parse_mount_args(int flags, char *options, | |||
469 | dout("got token %d\n", token); | 503 | dout("got token %d\n", token); |
470 | } | 504 | } |
471 | switch (token) { | 505 | switch (token) { |
472 | case Opt_fsidmajor: | ||
473 | *(__le64 *)&args->fsid.fsid[0] = cpu_to_le64(intval); | ||
474 | break; | ||
475 | case Opt_fsidminor: | ||
476 | *(__le64 *)&args->fsid.fsid[8] = cpu_to_le64(intval); | ||
477 | break; | ||
478 | case Opt_ip: | 506 | case Opt_ip: |
479 | err = ceph_parse_ips(argstr[0].from, | 507 | err = ceph_parse_ips(argstr[0].from, |
480 | argstr[0].to, | 508 | argstr[0].to, |
@@ -485,6 +513,11 @@ static struct ceph_mount_args *parse_mount_args(int flags, char *options, | |||
485 | args->flags |= CEPH_OPT_MYIP; | 513 | args->flags |= CEPH_OPT_MYIP; |
486 | break; | 514 | break; |
487 | 515 | ||
516 | case Opt_fsid: | ||
517 | err = parse_fsid(argstr[0].from, &args->fsid); | ||
518 | if (err == 0) | ||
519 | args->flags |= CEPH_OPT_FSID; | ||
520 | break; | ||
488 | case Opt_snapdirname: | 521 | case Opt_snapdirname: |
489 | kfree(args->snapdir_name); | 522 | kfree(args->snapdir_name); |
490 | args->snapdir_name = kstrndup(argstr[0].from, | 523 | args->snapdir_name = kstrndup(argstr[0].from, |
@@ -515,6 +548,9 @@ static struct ceph_mount_args *parse_mount_args(int flags, char *options, | |||
515 | case Opt_osdkeepalivetimeout: | 548 | case Opt_osdkeepalivetimeout: |
516 | args->osd_keepalive_timeout = intval; | 549 | args->osd_keepalive_timeout = intval; |
517 | break; | 550 | break; |
551 | case Opt_osd_idle_ttl: | ||
552 | args->osd_idle_ttl = intval; | ||
553 | break; | ||
518 | case Opt_mount_timeout: | 554 | case Opt_mount_timeout: |
519 | args->mount_timeout = intval; | 555 | args->mount_timeout = intval; |
520 | break; | 556 | break; |
@@ -630,7 +666,6 @@ static struct ceph_client *ceph_create_client(struct ceph_mount_args *args) | |||
630 | 666 | ||
631 | /* caps */ | 667 | /* caps */ |
632 | client->min_caps = args->max_readdir; | 668 | client->min_caps = args->max_readdir; |
633 | ceph_adjust_min_caps(client->min_caps); | ||
634 | 669 | ||
635 | /* subsystems */ | 670 | /* subsystems */ |
636 | err = ceph_monc_init(&client->monc, client); | 671 | err = ceph_monc_init(&client->monc, client); |
@@ -680,8 +715,6 @@ static void ceph_destroy_client(struct ceph_client *client) | |||
680 | 715 | ||
681 | ceph_monc_stop(&client->monc); | 716 | ceph_monc_stop(&client->monc); |
682 | 717 | ||
683 | ceph_adjust_min_caps(-client->min_caps); | ||
684 | |||
685 | ceph_debugfs_client_cleanup(client); | 718 | ceph_debugfs_client_cleanup(client); |
686 | destroy_workqueue(client->wb_wq); | 719 | destroy_workqueue(client->wb_wq); |
687 | destroy_workqueue(client->pg_inv_wq); | 720 | destroy_workqueue(client->pg_inv_wq); |
@@ -706,13 +739,13 @@ int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid) | |||
706 | { | 739 | { |
707 | if (client->have_fsid) { | 740 | if (client->have_fsid) { |
708 | if (ceph_fsid_compare(&client->fsid, fsid)) { | 741 | if (ceph_fsid_compare(&client->fsid, fsid)) { |
709 | pr_err("bad fsid, had " FSID_FORMAT " got " FSID_FORMAT, | 742 | pr_err("bad fsid, had %pU got %pU", |
710 | PR_FSID(&client->fsid), PR_FSID(fsid)); | 743 | &client->fsid, fsid); |
711 | return -1; | 744 | return -1; |
712 | } | 745 | } |
713 | } else { | 746 | } else { |
714 | pr_info("client%lld fsid " FSID_FORMAT "\n", | 747 | pr_info("client%lld fsid %pU\n", client->monc.auth->global_id, |
715 | client->monc.auth->global_id, PR_FSID(fsid)); | 748 | fsid); |
716 | memcpy(&client->fsid, fsid, sizeof(*fsid)); | 749 | memcpy(&client->fsid, fsid, sizeof(*fsid)); |
717 | ceph_debugfs_client_init(client); | 750 | ceph_debugfs_client_init(client); |
718 | client->have_fsid = true; | 751 | client->have_fsid = true; |
@@ -1043,8 +1076,6 @@ static int __init init_ceph(void) | |||
1043 | if (ret) | 1076 | if (ret) |
1044 | goto out_msgr; | 1077 | goto out_msgr; |
1045 | 1078 | ||
1046 | ceph_caps_init(); | ||
1047 | |||
1048 | ret = register_filesystem(&ceph_fs_type); | 1079 | ret = register_filesystem(&ceph_fs_type); |
1049 | if (ret) | 1080 | if (ret) |
1050 | goto out_icache; | 1081 | goto out_icache; |
@@ -1069,7 +1100,6 @@ static void __exit exit_ceph(void) | |||
1069 | { | 1100 | { |
1070 | dout("exit_ceph\n"); | 1101 | dout("exit_ceph\n"); |
1071 | unregister_filesystem(&ceph_fs_type); | 1102 | unregister_filesystem(&ceph_fs_type); |
1072 | ceph_caps_finalize(); | ||
1073 | destroy_caches(); | 1103 | destroy_caches(); |
1074 | ceph_msgr_exit(); | 1104 | ceph_msgr_exit(); |
1075 | ceph_debugfs_cleanup(); | 1105 | ceph_debugfs_cleanup(); |