OSDN Git Service

Merge tag 'docs-5.6-2' of git://git.lwn.net/linux
[tomoyo/tomoyo-test1.git] / fs / ceph / super.c
1 // SPDX-License-Identifier: GPL-2.0-only
2
3 #include <linux/ceph/ceph_debug.h>
4
5 #include <linux/backing-dev.h>
6 #include <linux/ctype.h>
7 #include <linux/fs.h>
8 #include <linux/inet.h>
9 #include <linux/in6.h>
10 #include <linux/module.h>
11 #include <linux/mount.h>
12 #include <linux/fs_context.h>
13 #include <linux/fs_parser.h>
14 #include <linux/sched.h>
15 #include <linux/seq_file.h>
16 #include <linux/slab.h>
17 #include <linux/statfs.h>
18 #include <linux/string.h>
19
20 #include "super.h"
21 #include "mds_client.h"
22 #include "cache.h"
23
24 #include <linux/ceph/ceph_features.h>
25 #include <linux/ceph/decode.h>
26 #include <linux/ceph/mon_client.h>
27 #include <linux/ceph/auth.h>
28 #include <linux/ceph/debugfs.h>
29
30 /*
31  * Ceph superblock operations
32  *
33  * Handle the basics of mounting, unmounting.
34  */
35
36 /*
37  * super ops
38  */
39 static void ceph_put_super(struct super_block *s)
40 {
41         struct ceph_fs_client *fsc = ceph_sb_to_client(s);
42
43         dout("put_super\n");
44         ceph_mdsc_close_sessions(fsc->mdsc);
45 }
46
47 static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
48 {
49         struct ceph_fs_client *fsc = ceph_inode_to_client(d_inode(dentry));
50         struct ceph_mon_client *monc = &fsc->client->monc;
51         struct ceph_statfs st;
52         u64 fsid;
53         int err;
54         u64 data_pool;
55
56         if (fsc->mdsc->mdsmap->m_num_data_pg_pools == 1) {
57                 data_pool = fsc->mdsc->mdsmap->m_data_pg_pools[0];
58         } else {
59                 data_pool = CEPH_NOPOOL;
60         }
61
62         dout("statfs\n");
63         err = ceph_monc_do_statfs(monc, data_pool, &st);
64         if (err < 0)
65                 return err;
66
67         /* fill in kstatfs */
68         buf->f_type = CEPH_SUPER_MAGIC;  /* ?? */
69
70         /*
71          * express utilization in terms of large blocks to avoid
72          * overflow on 32-bit machines.
73          *
74          * NOTE: for the time being, we make bsize == frsize to humor
75          * not-yet-ancient versions of glibc that are broken.
76          * Someday, we will probably want to report a real block
77          * size...  whatever that may mean for a network file system!
78          */
79         buf->f_bsize = 1 << CEPH_BLOCK_SHIFT;
80         buf->f_frsize = 1 << CEPH_BLOCK_SHIFT;
81
82         /*
83          * By default use root quota for stats; fallback to overall filesystem
84          * usage if using 'noquotadf' mount option or if the root dir doesn't
85          * have max_bytes quota set.
86          */
87         if (ceph_test_mount_opt(fsc, NOQUOTADF) ||
88             !ceph_quota_update_statfs(fsc, buf)) {
89                 buf->f_blocks = le64_to_cpu(st.kb) >> (CEPH_BLOCK_SHIFT-10);
90                 buf->f_bfree = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
91                 buf->f_bavail = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
92         }
93
94         buf->f_files = le64_to_cpu(st.num_objects);
95         buf->f_ffree = -1;
96         buf->f_namelen = NAME_MAX;
97
98         /* Must convert the fsid, for consistent values across arches */
99         mutex_lock(&monc->mutex);
100         fsid = le64_to_cpu(*(__le64 *)(&monc->monmap->fsid)) ^
101                le64_to_cpu(*((__le64 *)&monc->monmap->fsid + 1));
102         mutex_unlock(&monc->mutex);
103
104         buf->f_fsid.val[0] = fsid & 0xffffffff;
105         buf->f_fsid.val[1] = fsid >> 32;
106
107         return 0;
108 }
109
110 static int ceph_sync_fs(struct super_block *sb, int wait)
111 {
112         struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
113
114         if (!wait) {
115                 dout("sync_fs (non-blocking)\n");
116                 ceph_flush_dirty_caps(fsc->mdsc);
117                 dout("sync_fs (non-blocking) done\n");
118                 return 0;
119         }
120
121         dout("sync_fs (blocking)\n");
122         ceph_osdc_sync(&fsc->client->osdc);
123         ceph_mdsc_sync(fsc->mdsc);
124         dout("sync_fs (blocking) done\n");
125         return 0;
126 }
127
128 /*
129  * mount options
130  */
131 enum {
132         Opt_wsize,
133         Opt_rsize,
134         Opt_rasize,
135         Opt_caps_wanted_delay_min,
136         Opt_caps_wanted_delay_max,
137         Opt_caps_max,
138         Opt_readdir_max_entries,
139         Opt_readdir_max_bytes,
140         Opt_congestion_kb,
141         /* int args above */
142         Opt_snapdirname,
143         Opt_mds_namespace,
144         Opt_recover_session,
145         Opt_source,
146         /* string args above */
147         Opt_dirstat,
148         Opt_rbytes,
149         Opt_asyncreaddir,
150         Opt_dcache,
151         Opt_ino32,
152         Opt_fscache,
153         Opt_poolperm,
154         Opt_require_active_mds,
155         Opt_acl,
156         Opt_quotadf,
157         Opt_copyfrom,
158 };
159
160 enum ceph_recover_session_mode {
161         ceph_recover_session_no,
162         ceph_recover_session_clean
163 };
164
165 static const struct fs_parameter_enum ceph_mount_param_enums[] = {
166         { Opt_recover_session,  "no",           ceph_recover_session_no },
167         { Opt_recover_session,  "clean",        ceph_recover_session_clean },
168         {}
169 };
170
171 static const struct fs_parameter_spec ceph_mount_param_specs[] = {
172         fsparam_flag_no ("acl",                         Opt_acl),
173         fsparam_flag_no ("asyncreaddir",                Opt_asyncreaddir),
174         fsparam_s32     ("caps_max",                    Opt_caps_max),
175         fsparam_u32     ("caps_wanted_delay_max",       Opt_caps_wanted_delay_max),
176         fsparam_u32     ("caps_wanted_delay_min",       Opt_caps_wanted_delay_min),
177         fsparam_u32     ("write_congestion_kb",         Opt_congestion_kb),
178         fsparam_flag_no ("copyfrom",                    Opt_copyfrom),
179         fsparam_flag_no ("dcache",                      Opt_dcache),
180         fsparam_flag_no ("dirstat",                     Opt_dirstat),
181         __fsparam       (fs_param_is_string, "fsc",     Opt_fscache,
182                          fs_param_neg_with_no | fs_param_v_optional),
183         fsparam_flag_no ("ino32",                       Opt_ino32),
184         fsparam_string  ("mds_namespace",               Opt_mds_namespace),
185         fsparam_flag_no ("poolperm",                    Opt_poolperm),
186         fsparam_flag_no ("quotadf",                     Opt_quotadf),
187         fsparam_u32     ("rasize",                      Opt_rasize),
188         fsparam_flag_no ("rbytes",                      Opt_rbytes),
189         fsparam_u32     ("readdir_max_bytes",           Opt_readdir_max_bytes),
190         fsparam_u32     ("readdir_max_entries",         Opt_readdir_max_entries),
191         fsparam_enum    ("recover_session",             Opt_recover_session),
192         fsparam_flag_no ("require_active_mds",          Opt_require_active_mds),
193         fsparam_u32     ("rsize",                       Opt_rsize),
194         fsparam_string  ("snapdirname",                 Opt_snapdirname),
195         fsparam_string  ("source",                      Opt_source),
196         fsparam_u32     ("wsize",                       Opt_wsize),
197         {}
198 };
199
200 static const struct fs_parameter_description ceph_mount_parameters = {
201         .name           = "ceph",
202         .specs          = ceph_mount_param_specs,
203         .enums          = ceph_mount_param_enums,
204 };
205
206 struct ceph_parse_opts_ctx {
207         struct ceph_options             *copts;
208         struct ceph_mount_options       *opts;
209 };
210
211 /*
212  * Parse the source parameter.  Distinguish the server list from the path.
213  *
214  * The source will look like:
215  *     <server_spec>[,<server_spec>...]:[<path>]
216  * where
217  *     <server_spec> is <ip>[:<port>]
218  *     <path> is optional, but if present must begin with '/'
219  */
220 static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc)
221 {
222         struct ceph_parse_opts_ctx *pctx = fc->fs_private;
223         struct ceph_mount_options *fsopt = pctx->opts;
224         char *dev_name = param->string, *dev_name_end;
225         int ret;
226
227         dout("%s '%s'\n", __func__, dev_name);
228         if (!dev_name || !*dev_name)
229                 return invalf(fc, "ceph: Empty source");
230
231         dev_name_end = strchr(dev_name, '/');
232         if (dev_name_end) {
233                 kfree(fsopt->server_path);
234
235                 /*
236                  * The server_path will include the whole chars from userland
237                  * including the leading '/'.
238                  */
239                 fsopt->server_path = kstrdup(dev_name_end, GFP_KERNEL);
240                 if (!fsopt->server_path)
241                         return -ENOMEM;
242         } else {
243                 dev_name_end = dev_name + strlen(dev_name);
244         }
245
246         dev_name_end--;         /* back up to ':' separator */
247         if (dev_name_end < dev_name || *dev_name_end != ':')
248                 return invalf(fc, "ceph: No path or : separator in source");
249
250         dout("device name '%.*s'\n", (int)(dev_name_end - dev_name), dev_name);
251         if (fsopt->server_path)
252                 dout("server path '%s'\n", fsopt->server_path);
253
254         ret = ceph_parse_mon_ips(param->string, dev_name_end - dev_name,
255                                  pctx->copts, fc);
256         if (ret)
257                 return ret;
258
259         fc->source = param->string;
260         param->string = NULL;
261         return 0;
262 }
263
264 static int ceph_parse_mount_param(struct fs_context *fc,
265                                   struct fs_parameter *param)
266 {
267         struct ceph_parse_opts_ctx *pctx = fc->fs_private;
268         struct ceph_mount_options *fsopt = pctx->opts;
269         struct fs_parse_result result;
270         unsigned int mode;
271         int token, ret;
272
273         ret = ceph_parse_param(param, pctx->copts, fc);
274         if (ret != -ENOPARAM)
275                 return ret;
276
277         token = fs_parse(fc, &ceph_mount_parameters, param, &result);
278         dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
279         if (token < 0)
280                 return token;
281
282         switch (token) {
283         case Opt_snapdirname:
284                 kfree(fsopt->snapdir_name);
285                 fsopt->snapdir_name = param->string;
286                 param->string = NULL;
287                 break;
288         case Opt_mds_namespace:
289                 kfree(fsopt->mds_namespace);
290                 fsopt->mds_namespace = param->string;
291                 param->string = NULL;
292                 break;
293         case Opt_recover_session:
294                 mode = result.uint_32;
295                 if (mode == ceph_recover_session_no)
296                         fsopt->flags &= ~CEPH_MOUNT_OPT_CLEANRECOVER;
297                 else if (mode == ceph_recover_session_clean)
298                         fsopt->flags |= CEPH_MOUNT_OPT_CLEANRECOVER;
299                 else
300                         BUG();
301                 break;
302         case Opt_source:
303                 if (fc->source)
304                         return invalf(fc, "ceph: Multiple sources specified");
305                 return ceph_parse_source(param, fc);
306         case Opt_wsize:
307                 if (result.uint_32 < PAGE_SIZE ||
308                     result.uint_32 > CEPH_MAX_WRITE_SIZE)
309                         goto out_of_range;
310                 fsopt->wsize = ALIGN(result.uint_32, PAGE_SIZE);
311                 break;
312         case Opt_rsize:
313                 if (result.uint_32 < PAGE_SIZE ||
314                     result.uint_32 > CEPH_MAX_READ_SIZE)
315                         goto out_of_range;
316                 fsopt->rsize = ALIGN(result.uint_32, PAGE_SIZE);
317                 break;
318         case Opt_rasize:
319                 fsopt->rasize = ALIGN(result.uint_32, PAGE_SIZE);
320                 break;
321         case Opt_caps_wanted_delay_min:
322                 if (result.uint_32 < 1)
323                         goto out_of_range;
324                 fsopt->caps_wanted_delay_min = result.uint_32;
325                 break;
326         case Opt_caps_wanted_delay_max:
327                 if (result.uint_32 < 1)
328                         goto out_of_range;
329                 fsopt->caps_wanted_delay_max = result.uint_32;
330                 break;
331         case Opt_caps_max:
332                 if (result.int_32 < 0)
333                         goto out_of_range;
334                 fsopt->caps_max = result.int_32;
335                 break;
336         case Opt_readdir_max_entries:
337                 if (result.uint_32 < 1)
338                         goto out_of_range;
339                 fsopt->max_readdir = result.uint_32;
340                 break;
341         case Opt_readdir_max_bytes:
342                 if (result.uint_32 < PAGE_SIZE && result.uint_32 != 0)
343                         goto out_of_range;
344                 fsopt->max_readdir_bytes = result.uint_32;
345                 break;
346         case Opt_congestion_kb:
347                 if (result.uint_32 < 1024) /* at least 1M */
348                         goto out_of_range;
349                 fsopt->congestion_kb = result.uint_32;
350                 break;
351         case Opt_dirstat:
352                 if (!result.negated)
353                         fsopt->flags |= CEPH_MOUNT_OPT_DIRSTAT;
354                 else
355                         fsopt->flags &= ~CEPH_MOUNT_OPT_DIRSTAT;
356                 break;
357         case Opt_rbytes:
358                 if (!result.negated)
359                         fsopt->flags |= CEPH_MOUNT_OPT_RBYTES;
360                 else
361                         fsopt->flags &= ~CEPH_MOUNT_OPT_RBYTES;
362                 break;
363         case Opt_asyncreaddir:
364                 if (!result.negated)
365                         fsopt->flags &= ~CEPH_MOUNT_OPT_NOASYNCREADDIR;
366                 else
367                         fsopt->flags |= CEPH_MOUNT_OPT_NOASYNCREADDIR;
368                 break;
369         case Opt_dcache:
370                 if (!result.negated)
371                         fsopt->flags |= CEPH_MOUNT_OPT_DCACHE;
372                 else
373                         fsopt->flags &= ~CEPH_MOUNT_OPT_DCACHE;
374                 break;
375         case Opt_ino32:
376                 if (!result.negated)
377                         fsopt->flags |= CEPH_MOUNT_OPT_INO32;
378                 else
379                         fsopt->flags &= ~CEPH_MOUNT_OPT_INO32;
380                 break;
381
382         case Opt_fscache:
383 #ifdef CONFIG_CEPH_FSCACHE
384                 kfree(fsopt->fscache_uniq);
385                 fsopt->fscache_uniq = NULL;
386                 if (result.negated) {
387                         fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE;
388                 } else {
389                         fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
390                         fsopt->fscache_uniq = param->string;
391                         param->string = NULL;
392                 }
393                 break;
394 #else
395                 return invalf(fc, "ceph: fscache support is disabled");
396 #endif
397         case Opt_poolperm:
398                 if (!result.negated)
399                         fsopt->flags &= ~CEPH_MOUNT_OPT_NOPOOLPERM;
400                 else
401                         fsopt->flags |= CEPH_MOUNT_OPT_NOPOOLPERM;
402                 break;
403         case Opt_require_active_mds:
404                 if (!result.negated)
405                         fsopt->flags &= ~CEPH_MOUNT_OPT_MOUNTWAIT;
406                 else
407                         fsopt->flags |= CEPH_MOUNT_OPT_MOUNTWAIT;
408                 break;
409         case Opt_quotadf:
410                 if (!result.negated)
411                         fsopt->flags &= ~CEPH_MOUNT_OPT_NOQUOTADF;
412                 else
413                         fsopt->flags |= CEPH_MOUNT_OPT_NOQUOTADF;
414                 break;
415         case Opt_copyfrom:
416                 if (!result.negated)
417                         fsopt->flags &= ~CEPH_MOUNT_OPT_NOCOPYFROM;
418                 else
419                         fsopt->flags |= CEPH_MOUNT_OPT_NOCOPYFROM;
420                 break;
421         case Opt_acl:
422                 if (!result.negated) {
423 #ifdef CONFIG_CEPH_FS_POSIX_ACL
424                         fc->sb_flags |= SB_POSIXACL;
425 #else
426                         return invalf(fc, "ceph: POSIX ACL support is disabled");
427 #endif
428                 } else {
429                         fc->sb_flags &= ~SB_POSIXACL;
430                 }
431                 break;
432         default:
433                 BUG();
434         }
435         return 0;
436
437 out_of_range:
438         return invalf(fc, "ceph: %s out of range", param->key);
439 }
440
441 static void destroy_mount_options(struct ceph_mount_options *args)
442 {
443         dout("destroy_mount_options %p\n", args);
444         if (!args)
445                 return;
446
447         kfree(args->snapdir_name);
448         kfree(args->mds_namespace);
449         kfree(args->server_path);
450         kfree(args->fscache_uniq);
451         kfree(args);
452 }
453
454 static int strcmp_null(const char *s1, const char *s2)
455 {
456         if (!s1 && !s2)
457                 return 0;
458         if (s1 && !s2)
459                 return -1;
460         if (!s1 && s2)
461                 return 1;
462         return strcmp(s1, s2);
463 }
464
465 /**
466  * path_remove_extra_slash - Remove the extra slashes in the server path
467  * @server_path: the server path and could be NULL
468  *
469  * Return NULL if the path is NULL or only consists of "/", or a string
470  * without any extra slashes including the leading slash(es) and the
471  * slash(es) at the end of the server path, such as:
472  * "//dir1////dir2///" --> "dir1/dir2"
473  */
474 static char *path_remove_extra_slash(const char *server_path)
475 {
476         const char *path = server_path;
477         const char *cur, *end;
478         char *buf, *p;
479         int len;
480
481         /* if the server path is omitted */
482         if (!path)
483                 return NULL;
484
485         /* remove all the leading slashes */
486         while (*path == '/')
487                 path++;
488
489         /* if the server path only consists of slashes */
490         if (*path == '\0')
491                 return NULL;
492
493         len = strlen(path);
494
495         buf = kmalloc(len + 1, GFP_KERNEL);
496         if (!buf)
497                 return ERR_PTR(-ENOMEM);
498
499         end = path + len;
500         p = buf;
501         do {
502                 cur = strchr(path, '/');
503                 if (!cur)
504                         cur = end;
505
506                 len = cur - path;
507
508                 /* including one '/' */
509                 if (cur != end)
510                         len += 1;
511
512                 memcpy(p, path, len);
513                 p += len;
514
515                 while (cur <= end && *cur == '/')
516                         cur++;
517                 path = cur;
518         } while (path < end);
519
520         *p = '\0';
521
522         /*
523          * remove the last slash if there has and just to make sure that
524          * we will get something like "dir1/dir2"
525          */
526         if (*(--p) == '/')
527                 *p = '\0';
528
529         return buf;
530 }
531
532 static int compare_mount_options(struct ceph_mount_options *new_fsopt,
533                                  struct ceph_options *new_opt,
534                                  struct ceph_fs_client *fsc)
535 {
536         struct ceph_mount_options *fsopt1 = new_fsopt;
537         struct ceph_mount_options *fsopt2 = fsc->mount_options;
538         int ofs = offsetof(struct ceph_mount_options, snapdir_name);
539         char *p1, *p2;
540         int ret;
541
542         ret = memcmp(fsopt1, fsopt2, ofs);
543         if (ret)
544                 return ret;
545
546         ret = strcmp_null(fsopt1->snapdir_name, fsopt2->snapdir_name);
547         if (ret)
548                 return ret;
549         ret = strcmp_null(fsopt1->mds_namespace, fsopt2->mds_namespace);
550         if (ret)
551                 return ret;
552
553         p1 = path_remove_extra_slash(fsopt1->server_path);
554         if (IS_ERR(p1))
555                 return PTR_ERR(p1);
556         p2 = path_remove_extra_slash(fsopt2->server_path);
557         if (IS_ERR(p2)) {
558                 kfree(p1);
559                 return PTR_ERR(p2);
560         }
561         ret = strcmp_null(p1, p2);
562         kfree(p1);
563         kfree(p2);
564         if (ret)
565                 return ret;
566
567         ret = strcmp_null(fsopt1->fscache_uniq, fsopt2->fscache_uniq);
568         if (ret)
569                 return ret;
570
571         return ceph_compare_options(new_opt, fsc->client);
572 }
573
574 /**
575  * ceph_show_options - Show mount options in /proc/mounts
576  * @m: seq_file to write to
577  * @root: root of that (sub)tree
578  */
579 static int ceph_show_options(struct seq_file *m, struct dentry *root)
580 {
581         struct ceph_fs_client *fsc = ceph_sb_to_client(root->d_sb);
582         struct ceph_mount_options *fsopt = fsc->mount_options;
583         size_t pos;
584         int ret;
585
586         /* a comma between MNT/MS and client options */
587         seq_putc(m, ',');
588         pos = m->count;
589
590         ret = ceph_print_client_options(m, fsc->client, false);
591         if (ret)
592                 return ret;
593
594         /* retract our comma if no client options */
595         if (m->count == pos)
596                 m->count--;
597
598         if (fsopt->flags & CEPH_MOUNT_OPT_DIRSTAT)
599                 seq_puts(m, ",dirstat");
600         if ((fsopt->flags & CEPH_MOUNT_OPT_RBYTES))
601                 seq_puts(m, ",rbytes");
602         if (fsopt->flags & CEPH_MOUNT_OPT_NOASYNCREADDIR)
603                 seq_puts(m, ",noasyncreaddir");
604         if ((fsopt->flags & CEPH_MOUNT_OPT_DCACHE) == 0)
605                 seq_puts(m, ",nodcache");
606         if (fsopt->flags & CEPH_MOUNT_OPT_INO32)
607                 seq_puts(m, ",ino32");
608         if (fsopt->flags & CEPH_MOUNT_OPT_FSCACHE) {
609                 seq_show_option(m, "fsc", fsopt->fscache_uniq);
610         }
611         if (fsopt->flags & CEPH_MOUNT_OPT_NOPOOLPERM)
612                 seq_puts(m, ",nopoolperm");
613         if (fsopt->flags & CEPH_MOUNT_OPT_NOQUOTADF)
614                 seq_puts(m, ",noquotadf");
615
616 #ifdef CONFIG_CEPH_FS_POSIX_ACL
617         if (root->d_sb->s_flags & SB_POSIXACL)
618                 seq_puts(m, ",acl");
619         else
620                 seq_puts(m, ",noacl");
621 #endif
622
623         if ((fsopt->flags & CEPH_MOUNT_OPT_NOCOPYFROM) == 0)
624                 seq_puts(m, ",copyfrom");
625
626         if (fsopt->mds_namespace)
627                 seq_show_option(m, "mds_namespace", fsopt->mds_namespace);
628
629         if (fsopt->flags & CEPH_MOUNT_OPT_CLEANRECOVER)
630                 seq_show_option(m, "recover_session", "clean");
631
632         if (fsopt->wsize != CEPH_MAX_WRITE_SIZE)
633                 seq_printf(m, ",wsize=%u", fsopt->wsize);
634         if (fsopt->rsize != CEPH_MAX_READ_SIZE)
635                 seq_printf(m, ",rsize=%u", fsopt->rsize);
636         if (fsopt->rasize != CEPH_RASIZE_DEFAULT)
637                 seq_printf(m, ",rasize=%u", fsopt->rasize);
638         if (fsopt->congestion_kb != default_congestion_kb())
639                 seq_printf(m, ",write_congestion_kb=%u", fsopt->congestion_kb);
640         if (fsopt->caps_max)
641                 seq_printf(m, ",caps_max=%d", fsopt->caps_max);
642         if (fsopt->caps_wanted_delay_min != CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT)
643                 seq_printf(m, ",caps_wanted_delay_min=%u",
644                          fsopt->caps_wanted_delay_min);
645         if (fsopt->caps_wanted_delay_max != CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT)
646                 seq_printf(m, ",caps_wanted_delay_max=%u",
647                            fsopt->caps_wanted_delay_max);
648         if (fsopt->max_readdir != CEPH_MAX_READDIR_DEFAULT)
649                 seq_printf(m, ",readdir_max_entries=%u", fsopt->max_readdir);
650         if (fsopt->max_readdir_bytes != CEPH_MAX_READDIR_BYTES_DEFAULT)
651                 seq_printf(m, ",readdir_max_bytes=%u", fsopt->max_readdir_bytes);
652         if (strcmp(fsopt->snapdir_name, CEPH_SNAPDIRNAME_DEFAULT))
653                 seq_show_option(m, "snapdirname", fsopt->snapdir_name);
654
655         return 0;
656 }
657
658 /*
659  * handle any mon messages the standard library doesn't understand.
660  * return error if we don't either.
661  */
662 static int extra_mon_dispatch(struct ceph_client *client, struct ceph_msg *msg)
663 {
664         struct ceph_fs_client *fsc = client->private;
665         int type = le16_to_cpu(msg->hdr.type);
666
667         switch (type) {
668         case CEPH_MSG_MDS_MAP:
669                 ceph_mdsc_handle_mdsmap(fsc->mdsc, msg);
670                 return 0;
671         case CEPH_MSG_FS_MAP_USER:
672                 ceph_mdsc_handle_fsmap(fsc->mdsc, msg);
673                 return 0;
674         default:
675                 return -1;
676         }
677 }
678
679 /*
680  * create a new fs client
681  *
682  * Success or not, this function consumes @fsopt and @opt.
683  */
684 static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
685                                         struct ceph_options *opt)
686 {
687         struct ceph_fs_client *fsc;
688         int page_count;
689         size_t size;
690         int err;
691
692         fsc = kzalloc(sizeof(*fsc), GFP_KERNEL);
693         if (!fsc) {
694                 err = -ENOMEM;
695                 goto fail;
696         }
697
698         fsc->client = ceph_create_client(opt, fsc);
699         if (IS_ERR(fsc->client)) {
700                 err = PTR_ERR(fsc->client);
701                 goto fail;
702         }
703         opt = NULL; /* fsc->client now owns this */
704
705         fsc->client->extra_mon_dispatch = extra_mon_dispatch;
706         ceph_set_opt(fsc->client, ABORT_ON_FULL);
707
708         if (!fsopt->mds_namespace) {
709                 ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
710                                    0, true);
711         } else {
712                 ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_FSMAP,
713                                    0, false);
714         }
715
716         fsc->mount_options = fsopt;
717
718         fsc->sb = NULL;
719         fsc->mount_state = CEPH_MOUNT_MOUNTING;
720         fsc->filp_gen = 1;
721         fsc->have_copy_from2 = true;
722
723         atomic_long_set(&fsc->writeback_count, 0);
724
725         err = -ENOMEM;
726         /*
727          * The number of concurrent works can be high but they don't need
728          * to be processed in parallel, limit concurrency.
729          */
730         fsc->inode_wq = alloc_workqueue("ceph-inode", WQ_UNBOUND, 0);
731         if (!fsc->inode_wq)
732                 goto fail_client;
733         fsc->cap_wq = alloc_workqueue("ceph-cap", 0, 1);
734         if (!fsc->cap_wq)
735                 goto fail_inode_wq;
736
737         /* set up mempools */
738         err = -ENOMEM;
739         page_count = fsc->mount_options->wsize >> PAGE_SHIFT;
740         size = sizeof (struct page *) * (page_count ? page_count : 1);
741         fsc->wb_pagevec_pool = mempool_create_kmalloc_pool(10, size);
742         if (!fsc->wb_pagevec_pool)
743                 goto fail_cap_wq;
744
745         return fsc;
746
747 fail_cap_wq:
748         destroy_workqueue(fsc->cap_wq);
749 fail_inode_wq:
750         destroy_workqueue(fsc->inode_wq);
751 fail_client:
752         ceph_destroy_client(fsc->client);
753 fail:
754         kfree(fsc);
755         if (opt)
756                 ceph_destroy_options(opt);
757         destroy_mount_options(fsopt);
758         return ERR_PTR(err);
759 }
760
761 static void flush_fs_workqueues(struct ceph_fs_client *fsc)
762 {
763         flush_workqueue(fsc->inode_wq);
764         flush_workqueue(fsc->cap_wq);
765 }
766
767 static void destroy_fs_client(struct ceph_fs_client *fsc)
768 {
769         dout("destroy_fs_client %p\n", fsc);
770
771         ceph_mdsc_destroy(fsc);
772         destroy_workqueue(fsc->inode_wq);
773         destroy_workqueue(fsc->cap_wq);
774
775         mempool_destroy(fsc->wb_pagevec_pool);
776
777         destroy_mount_options(fsc->mount_options);
778
779         ceph_destroy_client(fsc->client);
780
781         kfree(fsc);
782         dout("destroy_fs_client %p done\n", fsc);
783 }
784
785 /*
786  * caches
787  */
788 struct kmem_cache *ceph_inode_cachep;
789 struct kmem_cache *ceph_cap_cachep;
790 struct kmem_cache *ceph_cap_flush_cachep;
791 struct kmem_cache *ceph_dentry_cachep;
792 struct kmem_cache *ceph_file_cachep;
793 struct kmem_cache *ceph_dir_file_cachep;
794
795 static void ceph_inode_init_once(void *foo)
796 {
797         struct ceph_inode_info *ci = foo;
798         inode_init_once(&ci->vfs_inode);
799 }
800
801 static int __init init_caches(void)
802 {
803         int error = -ENOMEM;
804
805         ceph_inode_cachep = kmem_cache_create("ceph_inode_info",
806                                       sizeof(struct ceph_inode_info),
807                                       __alignof__(struct ceph_inode_info),
808                                       SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
809                                       SLAB_ACCOUNT, ceph_inode_init_once);
810         if (!ceph_inode_cachep)
811                 return -ENOMEM;
812
813         ceph_cap_cachep = KMEM_CACHE(ceph_cap, SLAB_MEM_SPREAD);
814         if (!ceph_cap_cachep)
815                 goto bad_cap;
816         ceph_cap_flush_cachep = KMEM_CACHE(ceph_cap_flush,
817                                            SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD);
818         if (!ceph_cap_flush_cachep)
819                 goto bad_cap_flush;
820
821         ceph_dentry_cachep = KMEM_CACHE(ceph_dentry_info,
822                                         SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD);
823         if (!ceph_dentry_cachep)
824                 goto bad_dentry;
825
826         ceph_file_cachep = KMEM_CACHE(ceph_file_info, SLAB_MEM_SPREAD);
827         if (!ceph_file_cachep)
828                 goto bad_file;
829
830         ceph_dir_file_cachep = KMEM_CACHE(ceph_dir_file_info, SLAB_MEM_SPREAD);
831         if (!ceph_dir_file_cachep)
832                 goto bad_dir_file;
833
834         error = ceph_fscache_register();
835         if (error)
836                 goto bad_fscache;
837
838         return 0;
839
840 bad_fscache:
841         kmem_cache_destroy(ceph_dir_file_cachep);
842 bad_dir_file:
843         kmem_cache_destroy(ceph_file_cachep);
844 bad_file:
845         kmem_cache_destroy(ceph_dentry_cachep);
846 bad_dentry:
847         kmem_cache_destroy(ceph_cap_flush_cachep);
848 bad_cap_flush:
849         kmem_cache_destroy(ceph_cap_cachep);
850 bad_cap:
851         kmem_cache_destroy(ceph_inode_cachep);
852         return error;
853 }
854
855 static void destroy_caches(void)
856 {
857         /*
858          * Make sure all delayed rcu free inodes are flushed before we
859          * destroy cache.
860          */
861         rcu_barrier();
862
863         kmem_cache_destroy(ceph_inode_cachep);
864         kmem_cache_destroy(ceph_cap_cachep);
865         kmem_cache_destroy(ceph_cap_flush_cachep);
866         kmem_cache_destroy(ceph_dentry_cachep);
867         kmem_cache_destroy(ceph_file_cachep);
868         kmem_cache_destroy(ceph_dir_file_cachep);
869
870         ceph_fscache_unregister();
871 }
872
873 /*
874  * ceph_umount_begin - initiate forced umount.  Tear down down the
875  * mount, skipping steps that may hang while waiting for server(s).
876  */
877 static void ceph_umount_begin(struct super_block *sb)
878 {
879         struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
880
881         dout("ceph_umount_begin - starting forced umount\n");
882         if (!fsc)
883                 return;
884         fsc->mount_state = CEPH_MOUNT_SHUTDOWN;
885         ceph_osdc_abort_requests(&fsc->client->osdc, -EIO);
886         ceph_mdsc_force_umount(fsc->mdsc);
887         fsc->filp_gen++; // invalidate open files
888 }
889
890 static const struct super_operations ceph_super_ops = {
891         .alloc_inode    = ceph_alloc_inode,
892         .free_inode     = ceph_free_inode,
893         .write_inode    = ceph_write_inode,
894         .drop_inode     = generic_delete_inode,
895         .evict_inode    = ceph_evict_inode,
896         .sync_fs        = ceph_sync_fs,
897         .put_super      = ceph_put_super,
898         .show_options   = ceph_show_options,
899         .statfs         = ceph_statfs,
900         .umount_begin   = ceph_umount_begin,
901 };
902
903 /*
904  * Bootstrap mount by opening the root directory.  Note the mount
905  * @started time from caller, and time out if this takes too long.
906  */
907 static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,
908                                        const char *path,
909                                        unsigned long started)
910 {
911         struct ceph_mds_client *mdsc = fsc->mdsc;
912         struct ceph_mds_request *req = NULL;
913         int err;
914         struct dentry *root;
915
916         /* open dir */
917         dout("open_root_inode opening '%s'\n", path);
918         req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS);
919         if (IS_ERR(req))
920                 return ERR_CAST(req);
921         req->r_path1 = kstrdup(path, GFP_NOFS);
922         if (!req->r_path1) {
923                 root = ERR_PTR(-ENOMEM);
924                 goto out;
925         }
926
927         req->r_ino1.ino = CEPH_INO_ROOT;
928         req->r_ino1.snap = CEPH_NOSNAP;
929         req->r_started = started;
930         req->r_timeout = fsc->client->options->mount_timeout;
931         req->r_args.getattr.mask = cpu_to_le32(CEPH_STAT_CAP_INODE);
932         req->r_num_caps = 2;
933         err = ceph_mdsc_do_request(mdsc, NULL, req);
934         if (err == 0) {
935                 struct inode *inode = req->r_target_inode;
936                 req->r_target_inode = NULL;
937                 dout("open_root_inode success\n");
938                 root = d_make_root(inode);
939                 if (!root) {
940                         root = ERR_PTR(-ENOMEM);
941                         goto out;
942                 }
943                 dout("open_root_inode success, root dentry is %p\n", root);
944         } else {
945                 root = ERR_PTR(err);
946         }
947 out:
948         ceph_mdsc_put_request(req);
949         return root;
950 }
951
952 /*
953  * mount: join the ceph cluster, and open root directory.
954  */
955 static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
956                                       struct fs_context *fc)
957 {
958         int err;
959         unsigned long started = jiffies;  /* note the start time */
960         struct dentry *root;
961
962         dout("mount start %p\n", fsc);
963         mutex_lock(&fsc->client->mount_mutex);
964
965         if (!fsc->sb->s_root) {
966                 const char *path, *p;
967                 err = __ceph_open_session(fsc->client, started);
968                 if (err < 0)
969                         goto out;
970
971                 /* setup fscache */
972                 if (fsc->mount_options->flags & CEPH_MOUNT_OPT_FSCACHE) {
973                         err = ceph_fscache_register_fs(fsc, fc);
974                         if (err < 0)
975                                 goto out;
976                 }
977
978                 p = path_remove_extra_slash(fsc->mount_options->server_path);
979                 if (IS_ERR(p)) {
980                         err = PTR_ERR(p);
981                         goto out;
982                 }
983                 /* if the server path is omitted or just consists of '/' */
984                 if (!p)
985                         path = "";
986                 else
987                         path = p;
988                 dout("mount opening path '%s'\n", path);
989
990                 ceph_fs_debugfs_init(fsc);
991
992                 root = open_root_dentry(fsc, path, started);
993                 kfree(p);
994                 if (IS_ERR(root)) {
995                         err = PTR_ERR(root);
996                         goto out;
997                 }
998                 fsc->sb->s_root = dget(root);
999         } else {
1000                 root = dget(fsc->sb->s_root);
1001         }
1002
1003         fsc->mount_state = CEPH_MOUNT_MOUNTED;
1004         dout("mount success\n");
1005         mutex_unlock(&fsc->client->mount_mutex);
1006         return root;
1007
1008 out:
1009         mutex_unlock(&fsc->client->mount_mutex);
1010         return ERR_PTR(err);
1011 }
1012
1013 static int ceph_set_super(struct super_block *s, struct fs_context *fc)
1014 {
1015         struct ceph_fs_client *fsc = s->s_fs_info;
1016         int ret;
1017
1018         dout("set_super %p\n", s);
1019
1020         s->s_maxbytes = MAX_LFS_FILESIZE;
1021
1022         s->s_xattr = ceph_xattr_handlers;
1023         fsc->sb = s;
1024         fsc->max_file_size = 1ULL << 40; /* temp value until we get mdsmap */
1025
1026         s->s_op = &ceph_super_ops;
1027         s->s_d_op = &ceph_dentry_ops;
1028         s->s_export_op = &ceph_export_ops;
1029
1030         s->s_time_gran = 1;
1031         s->s_time_min = 0;
1032         s->s_time_max = U32_MAX;
1033
1034         ret = set_anon_super_fc(s, fc);
1035         if (ret != 0)
1036                 fsc->sb = NULL;
1037         return ret;
1038 }
1039
1040 /*
1041  * share superblock if same fs AND options
1042  */
1043 static int ceph_compare_super(struct super_block *sb, struct fs_context *fc)
1044 {
1045         struct ceph_fs_client *new = fc->s_fs_info;
1046         struct ceph_mount_options *fsopt = new->mount_options;
1047         struct ceph_options *opt = new->client->options;
1048         struct ceph_fs_client *other = ceph_sb_to_client(sb);
1049
1050         dout("ceph_compare_super %p\n", sb);
1051
1052         if (compare_mount_options(fsopt, opt, other)) {
1053                 dout("monitor(s)/mount options don't match\n");
1054                 return 0;
1055         }
1056         if ((opt->flags & CEPH_OPT_FSID) &&
1057             ceph_fsid_compare(&opt->fsid, &other->client->fsid)) {
1058                 dout("fsid doesn't match\n");
1059                 return 0;
1060         }
1061         if (fc->sb_flags != (sb->s_flags & ~SB_BORN)) {
1062                 dout("flags differ\n");
1063                 return 0;
1064         }
1065         return 1;
1066 }
1067
1068 /*
1069  * construct our own bdi so we can control readahead, etc.
1070  */
1071 static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
1072
1073 static int ceph_setup_bdi(struct super_block *sb, struct ceph_fs_client *fsc)
1074 {
1075         int err;
1076
1077         err = super_setup_bdi_name(sb, "ceph-%ld",
1078                                    atomic_long_inc_return(&bdi_seq));
1079         if (err)
1080                 return err;
1081
1082         /* set ra_pages based on rasize mount option? */
1083         sb->s_bdi->ra_pages = fsc->mount_options->rasize >> PAGE_SHIFT;
1084
1085         /* set io_pages based on max osd read size */
1086         sb->s_bdi->io_pages = fsc->mount_options->rsize >> PAGE_SHIFT;
1087
1088         return 0;
1089 }
1090
1091 static int ceph_get_tree(struct fs_context *fc)
1092 {
1093         struct ceph_parse_opts_ctx *pctx = fc->fs_private;
1094         struct super_block *sb;
1095         struct ceph_fs_client *fsc;
1096         struct dentry *res;
1097         int (*compare_super)(struct super_block *, struct fs_context *) =
1098                 ceph_compare_super;
1099         int err;
1100
1101         dout("ceph_get_tree\n");
1102
1103         if (!fc->source)
1104                 return invalf(fc, "ceph: No source");
1105
1106 #ifdef CONFIG_CEPH_FS_POSIX_ACL
1107         fc->sb_flags |= SB_POSIXACL;
1108 #endif
1109
1110         /* create client (which we may/may not use) */
1111         fsc = create_fs_client(pctx->opts, pctx->copts);
1112         pctx->opts = NULL;
1113         pctx->copts = NULL;
1114         if (IS_ERR(fsc)) {
1115                 err = PTR_ERR(fsc);
1116                 goto out_final;
1117         }
1118
1119         err = ceph_mdsc_init(fsc);
1120         if (err < 0)
1121                 goto out;
1122
1123         if (ceph_test_opt(fsc->client, NOSHARE))
1124                 compare_super = NULL;
1125
1126         fc->s_fs_info = fsc;
1127         sb = sget_fc(fc, compare_super, ceph_set_super);
1128         fc->s_fs_info = NULL;
1129         if (IS_ERR(sb)) {
1130                 err = PTR_ERR(sb);
1131                 goto out;
1132         }
1133
1134         if (ceph_sb_to_client(sb) != fsc) {
1135                 destroy_fs_client(fsc);
1136                 fsc = ceph_sb_to_client(sb);
1137                 dout("get_sb got existing client %p\n", fsc);
1138         } else {
1139                 dout("get_sb using new client %p\n", fsc);
1140                 err = ceph_setup_bdi(sb, fsc);
1141                 if (err < 0)
1142                         goto out_splat;
1143         }
1144
1145         res = ceph_real_mount(fsc, fc);
1146         if (IS_ERR(res)) {
1147                 err = PTR_ERR(res);
1148                 goto out_splat;
1149         }
1150         dout("root %p inode %p ino %llx.%llx\n", res,
1151              d_inode(res), ceph_vinop(d_inode(res)));
1152         fc->root = fsc->sb->s_root;
1153         return 0;
1154
1155 out_splat:
1156         if (!ceph_mdsmap_is_cluster_available(fsc->mdsc->mdsmap)) {
1157                 pr_info("No mds server is up or the cluster is laggy\n");
1158                 err = -EHOSTUNREACH;
1159         }
1160
1161         ceph_mdsc_close_sessions(fsc->mdsc);
1162         deactivate_locked_super(sb);
1163         goto out_final;
1164
1165 out:
1166         destroy_fs_client(fsc);
1167 out_final:
1168         dout("ceph_get_tree fail %d\n", err);
1169         return err;
1170 }
1171
1172 static void ceph_free_fc(struct fs_context *fc)
1173 {
1174         struct ceph_parse_opts_ctx *pctx = fc->fs_private;
1175
1176         if (pctx) {
1177                 destroy_mount_options(pctx->opts);
1178                 ceph_destroy_options(pctx->copts);
1179                 kfree(pctx);
1180         }
1181 }
1182
1183 static int ceph_reconfigure_fc(struct fs_context *fc)
1184 {
1185         sync_filesystem(fc->root->d_sb);
1186         return 0;
1187 }
1188
1189 static const struct fs_context_operations ceph_context_ops = {
1190         .free           = ceph_free_fc,
1191         .parse_param    = ceph_parse_mount_param,
1192         .get_tree       = ceph_get_tree,
1193         .reconfigure    = ceph_reconfigure_fc,
1194 };
1195
1196 /*
1197  * Set up the filesystem mount context.
1198  */
1199 static int ceph_init_fs_context(struct fs_context *fc)
1200 {
1201         struct ceph_parse_opts_ctx *pctx;
1202         struct ceph_mount_options *fsopt;
1203
1204         pctx = kzalloc(sizeof(*pctx), GFP_KERNEL);
1205         if (!pctx)
1206                 return -ENOMEM;
1207
1208         pctx->copts = ceph_alloc_options();
1209         if (!pctx->copts)
1210                 goto nomem;
1211
1212         pctx->opts = kzalloc(sizeof(*pctx->opts), GFP_KERNEL);
1213         if (!pctx->opts)
1214                 goto nomem;
1215
1216         fsopt = pctx->opts;
1217         fsopt->flags = CEPH_MOUNT_OPT_DEFAULT;
1218
1219         fsopt->wsize = CEPH_MAX_WRITE_SIZE;
1220         fsopt->rsize = CEPH_MAX_READ_SIZE;
1221         fsopt->rasize = CEPH_RASIZE_DEFAULT;
1222         fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL);
1223         if (!fsopt->snapdir_name)
1224                 goto nomem;
1225
1226         fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT;
1227         fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT;
1228         fsopt->max_readdir = CEPH_MAX_READDIR_DEFAULT;
1229         fsopt->max_readdir_bytes = CEPH_MAX_READDIR_BYTES_DEFAULT;
1230         fsopt->congestion_kb = default_congestion_kb();
1231
1232         fc->fs_private = pctx;
1233         fc->ops = &ceph_context_ops;
1234         return 0;
1235
1236 nomem:
1237         destroy_mount_options(pctx->opts);
1238         ceph_destroy_options(pctx->copts);
1239         kfree(pctx);
1240         return -ENOMEM;
1241 }
1242
1243 static void ceph_kill_sb(struct super_block *s)
1244 {
1245         struct ceph_fs_client *fsc = ceph_sb_to_client(s);
1246         dev_t dev = s->s_dev;
1247
1248         dout("kill_sb %p\n", s);
1249
1250         ceph_mdsc_pre_umount(fsc->mdsc);
1251         flush_fs_workqueues(fsc);
1252
1253         generic_shutdown_super(s);
1254
1255         fsc->client->extra_mon_dispatch = NULL;
1256         ceph_fs_debugfs_cleanup(fsc);
1257
1258         ceph_fscache_unregister_fs(fsc);
1259
1260         destroy_fs_client(fsc);
1261         free_anon_bdev(dev);
1262 }
1263
1264 static struct file_system_type ceph_fs_type = {
1265         .owner          = THIS_MODULE,
1266         .name           = "ceph",
1267         .init_fs_context = ceph_init_fs_context,
1268         .kill_sb        = ceph_kill_sb,
1269         .fs_flags       = FS_RENAME_DOES_D_MOVE,
1270 };
1271 MODULE_ALIAS_FS("ceph");
1272
1273 int ceph_force_reconnect(struct super_block *sb)
1274 {
1275         struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
1276         int err = 0;
1277
1278         ceph_umount_begin(sb);
1279
1280         /* Make sure all page caches get invalidated.
1281          * see remove_session_caps_cb() */
1282         flush_workqueue(fsc->inode_wq);
1283
1284         /* In case that we were blacklisted. This also reset
1285          * all mon/osd connections */
1286         ceph_reset_client_addr(fsc->client);
1287
1288         ceph_osdc_clear_abort_err(&fsc->client->osdc);
1289
1290         fsc->blacklisted = false;
1291         fsc->mount_state = CEPH_MOUNT_MOUNTED;
1292
1293         if (sb->s_root) {
1294                 err = __ceph_do_getattr(d_inode(sb->s_root), NULL,
1295                                         CEPH_STAT_CAP_INODE, true);
1296         }
1297         return err;
1298 }
1299
1300 static int __init init_ceph(void)
1301 {
1302         int ret = init_caches();
1303         if (ret)
1304                 goto out;
1305
1306         ceph_flock_init();
1307         ret = register_filesystem(&ceph_fs_type);
1308         if (ret)
1309                 goto out_caches;
1310
1311         pr_info("loaded (mds proto %d)\n", CEPH_MDSC_PROTOCOL);
1312
1313         return 0;
1314
1315 out_caches:
1316         destroy_caches();
1317 out:
1318         return ret;
1319 }
1320
1321 static void __exit exit_ceph(void)
1322 {
1323         dout("exit_ceph\n");
1324         unregister_filesystem(&ceph_fs_type);
1325         destroy_caches();
1326 }
1327
1328 module_init(init_ceph);
1329 module_exit(exit_ceph);
1330
1331 MODULE_AUTHOR("Sage Weil <sage@newdream.net>");
1332 MODULE_AUTHOR("Yehuda Sadeh <yehuda@hq.newdream.net>");
1333 MODULE_AUTHOR("Patience Warnick <patience@newdream.net>");
1334 MODULE_DESCRIPTION("Ceph filesystem for Linux");
1335 MODULE_LICENSE("GPL");