Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1 | |
| 2 | #include "ceph_debug.h" |
| 3 | |
| 4 | #include <linux/backing-dev.h> |
Sage Weil | c309f0a | 2010-06-30 21:34:01 -0700 | [diff] [blame] | 5 | #include <linux/ctype.h> |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 6 | #include <linux/fs.h> |
| 7 | #include <linux/inet.h> |
| 8 | #include <linux/in6.h> |
| 9 | #include <linux/module.h> |
| 10 | #include <linux/mount.h> |
| 11 | #include <linux/parser.h> |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 12 | #include <linux/sched.h> |
| 13 | #include <linux/seq_file.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 14 | #include <linux/slab.h> |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 15 | #include <linux/statfs.h> |
| 16 | #include <linux/string.h> |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 17 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 18 | #include "decode.h" |
| 19 | #include "super.h" |
| 20 | #include "mon_client.h" |
Sage Weil | 0743304 | 2009-11-18 16:50:41 -0800 | [diff] [blame] | 21 | #include "auth.h" |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 22 | |
| 23 | /* |
| 24 | * Ceph superblock operations |
| 25 | * |
| 26 | * Handle the basics of mounting, unmounting. |
| 27 | */ |
| 28 | |
| 29 | |
| 30 | /* |
| 31 | * find filename portion of a path (/foo/bar/baz -> baz) |
| 32 | */ |
| 33 | const char *ceph_file_part(const char *s, int len) |
| 34 | { |
| 35 | const char *e = s + len; |
| 36 | |
| 37 | while (e != s && *(e-1) != '/') |
| 38 | e--; |
| 39 | return e; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | /* |
| 44 | * super ops |
| 45 | */ |
| 46 | static void ceph_put_super(struct super_block *s) |
| 47 | { |
Sage Weil | 5dfc589 | 2010-05-04 16:14:46 -0700 | [diff] [blame] | 48 | struct ceph_client *client = ceph_sb_to_client(s); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 49 | |
| 50 | dout("put_super\n"); |
Sage Weil | 5dfc589 | 2010-05-04 16:14:46 -0700 | [diff] [blame] | 51 | ceph_mdsc_close_sessions(&client->mdsc); |
| 52 | |
| 53 | /* |
| 54 | * ensure we release the bdi before put_anon_super releases |
| 55 | * the device name. |
| 56 | */ |
| 57 | if (s->s_bdi == &client->backing_dev_info) { |
| 58 | bdi_unregister(&client->backing_dev_info); |
| 59 | s->s_bdi = NULL; |
| 60 | } |
| 61 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 62 | return; |
| 63 | } |
| 64 | |
| 65 | static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf) |
| 66 | { |
| 67 | struct ceph_client *client = ceph_inode_to_client(dentry->d_inode); |
| 68 | struct ceph_monmap *monmap = client->monc.monmap; |
| 69 | struct ceph_statfs st; |
| 70 | u64 fsid; |
| 71 | int err; |
| 72 | |
| 73 | dout("statfs\n"); |
| 74 | err = ceph_monc_do_statfs(&client->monc, &st); |
| 75 | if (err < 0) |
| 76 | return err; |
| 77 | |
| 78 | /* fill in kstatfs */ |
| 79 | buf->f_type = CEPH_SUPER_MAGIC; /* ?? */ |
| 80 | |
| 81 | /* |
| 82 | * express utilization in terms of large blocks to avoid |
| 83 | * overflow on 32-bit machines. |
| 84 | */ |
| 85 | buf->f_bsize = 1 << CEPH_BLOCK_SHIFT; |
| 86 | buf->f_blocks = le64_to_cpu(st.kb) >> (CEPH_BLOCK_SHIFT-10); |
| 87 | buf->f_bfree = (le64_to_cpu(st.kb) - le64_to_cpu(st.kb_used)) >> |
| 88 | (CEPH_BLOCK_SHIFT-10); |
| 89 | buf->f_bavail = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10); |
| 90 | |
| 91 | buf->f_files = le64_to_cpu(st.num_objects); |
| 92 | buf->f_ffree = -1; |
Sage Weil | 558d349 | 2010-06-01 12:51:12 -0700 | [diff] [blame] | 93 | buf->f_namelen = NAME_MAX; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 94 | buf->f_frsize = PAGE_CACHE_SIZE; |
| 95 | |
| 96 | /* leave fsid little-endian, regardless of host endianness */ |
| 97 | fsid = *(u64 *)(&monmap->fsid) ^ *((u64 *)&monmap->fsid + 1); |
| 98 | buf->f_fsid.val[0] = fsid & 0xffffffff; |
| 99 | buf->f_fsid.val[1] = fsid >> 32; |
| 100 | |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | |
Sage Weil | 2d9c98a | 2010-07-30 09:38:13 -0700 | [diff] [blame^] | 105 | static int ceph_sync_fs(struct super_block *sb, int wait) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 106 | { |
Sage Weil | 2d9c98a | 2010-07-30 09:38:13 -0700 | [diff] [blame^] | 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"); |
Cheng Renquan | 640ef79 | 2010-03-26 17:40:33 +0800 | [diff] [blame] | 117 | ceph_osdc_sync(&ceph_sb_to_client(sb)->osdc); |
| 118 | ceph_mdsc_sync(&ceph_sb_to_client(sb)->mdsc); |
Sage Weil | 2d9c98a | 2010-07-30 09:38:13 -0700 | [diff] [blame^] | 119 | dout("sync_fs (blocking) done\n"); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 120 | return 0; |
| 121 | } |
| 122 | |
Yehuda Sadeh | 2baba25 | 2009-12-18 13:51:57 -0800 | [diff] [blame] | 123 | static int default_congestion_kb(void) |
| 124 | { |
| 125 | int congestion_kb; |
| 126 | |
| 127 | /* |
| 128 | * Copied from NFS |
| 129 | * |
| 130 | * congestion size, scale with available memory. |
| 131 | * |
| 132 | * 64MB: 8192k |
| 133 | * 128MB: 11585k |
| 134 | * 256MB: 16384k |
| 135 | * 512MB: 23170k |
| 136 | * 1GB: 32768k |
| 137 | * 2GB: 46340k |
| 138 | * 4GB: 65536k |
| 139 | * 8GB: 92681k |
| 140 | * 16GB: 131072k |
| 141 | * |
| 142 | * This allows larger machines to have larger/more transfers. |
| 143 | * Limit the default to 256M |
| 144 | */ |
| 145 | congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10); |
| 146 | if (congestion_kb > 256*1024) |
| 147 | congestion_kb = 256*1024; |
| 148 | |
| 149 | return congestion_kb; |
| 150 | } |
| 151 | |
Sage Weil | 6e19a16 | 2010-04-29 16:38:32 -0700 | [diff] [blame] | 152 | /** |
| 153 | * ceph_show_options - Show mount options in /proc/mounts |
| 154 | * @m: seq_file to write to |
| 155 | * @mnt: mount descriptor |
| 156 | */ |
| 157 | static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt) |
| 158 | { |
| 159 | struct ceph_client *client = ceph_sb_to_client(mnt->mnt_sb); |
| 160 | struct ceph_mount_args *args = client->mount_args; |
| 161 | |
| 162 | if (args->flags & CEPH_OPT_FSID) |
Sage Weil | a8b763a | 2010-07-08 13:00:18 -0700 | [diff] [blame] | 163 | seq_printf(m, ",fsid=%pU", &args->fsid); |
Sage Weil | 6e19a16 | 2010-04-29 16:38:32 -0700 | [diff] [blame] | 164 | if (args->flags & CEPH_OPT_NOSHARE) |
| 165 | seq_puts(m, ",noshare"); |
| 166 | if (args->flags & CEPH_OPT_DIRSTAT) |
| 167 | seq_puts(m, ",dirstat"); |
| 168 | if ((args->flags & CEPH_OPT_RBYTES) == 0) |
| 169 | seq_puts(m, ",norbytes"); |
| 170 | if (args->flags & CEPH_OPT_NOCRC) |
| 171 | seq_puts(m, ",nocrc"); |
| 172 | if (args->flags & CEPH_OPT_NOASYNCREADDIR) |
| 173 | seq_puts(m, ",noasyncreaddir"); |
| 174 | |
| 175 | if (args->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT) |
| 176 | seq_printf(m, ",mount_timeout=%d", args->mount_timeout); |
| 177 | if (args->osd_idle_ttl != CEPH_OSD_IDLE_TTL_DEFAULT) |
| 178 | seq_printf(m, ",osd_idle_ttl=%d", args->osd_idle_ttl); |
| 179 | if (args->osd_timeout != CEPH_OSD_TIMEOUT_DEFAULT) |
| 180 | seq_printf(m, ",osdtimeout=%d", args->osd_timeout); |
| 181 | if (args->osd_keepalive_timeout != CEPH_OSD_KEEPALIVE_DEFAULT) |
| 182 | seq_printf(m, ",osdkeepalivetimeout=%d", |
| 183 | args->osd_keepalive_timeout); |
| 184 | if (args->wsize) |
| 185 | seq_printf(m, ",wsize=%d", args->wsize); |
| 186 | if (args->rsize != CEPH_MOUNT_RSIZE_DEFAULT) |
| 187 | seq_printf(m, ",rsize=%d", args->rsize); |
| 188 | if (args->congestion_kb != default_congestion_kb()) |
| 189 | seq_printf(m, ",write_congestion_kb=%d", args->congestion_kb); |
| 190 | if (args->caps_wanted_delay_min != CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT) |
| 191 | seq_printf(m, ",caps_wanted_delay_min=%d", |
| 192 | args->caps_wanted_delay_min); |
| 193 | if (args->caps_wanted_delay_max != CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT) |
| 194 | seq_printf(m, ",caps_wanted_delay_max=%d", |
| 195 | args->caps_wanted_delay_max); |
| 196 | if (args->cap_release_safety != CEPH_CAP_RELEASE_SAFETY_DEFAULT) |
| 197 | seq_printf(m, ",cap_release_safety=%d", |
| 198 | args->cap_release_safety); |
| 199 | if (args->max_readdir != CEPH_MAX_READDIR_DEFAULT) |
| 200 | seq_printf(m, ",readdir_max_entries=%d", args->max_readdir); |
Sage Weil | 23804d9 | 2010-05-14 13:06:30 -0700 | [diff] [blame] | 201 | if (args->max_readdir_bytes != CEPH_MAX_READDIR_BYTES_DEFAULT) |
| 202 | seq_printf(m, ",readdir_max_bytes=%d", args->max_readdir_bytes); |
Sage Weil | 6e19a16 | 2010-04-29 16:38:32 -0700 | [diff] [blame] | 203 | if (strcmp(args->snapdir_name, CEPH_SNAPDIRNAME_DEFAULT)) |
| 204 | seq_printf(m, ",snapdirname=%s", args->snapdir_name); |
| 205 | if (args->name) |
| 206 | seq_printf(m, ",name=%s", args->name); |
| 207 | if (args->secret) |
| 208 | seq_puts(m, ",secret=<hidden>"); |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | /* |
| 213 | * caches |
| 214 | */ |
| 215 | struct kmem_cache *ceph_inode_cachep; |
| 216 | struct kmem_cache *ceph_cap_cachep; |
| 217 | struct kmem_cache *ceph_dentry_cachep; |
| 218 | struct kmem_cache *ceph_file_cachep; |
| 219 | |
| 220 | static void ceph_inode_init_once(void *foo) |
| 221 | { |
| 222 | struct ceph_inode_info *ci = foo; |
| 223 | inode_init_once(&ci->vfs_inode); |
| 224 | } |
| 225 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 226 | static int __init init_caches(void) |
| 227 | { |
| 228 | ceph_inode_cachep = kmem_cache_create("ceph_inode_info", |
| 229 | sizeof(struct ceph_inode_info), |
| 230 | __alignof__(struct ceph_inode_info), |
| 231 | (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD), |
| 232 | ceph_inode_init_once); |
| 233 | if (ceph_inode_cachep == NULL) |
| 234 | return -ENOMEM; |
| 235 | |
| 236 | ceph_cap_cachep = KMEM_CACHE(ceph_cap, |
| 237 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD); |
| 238 | if (ceph_cap_cachep == NULL) |
| 239 | goto bad_cap; |
| 240 | |
| 241 | ceph_dentry_cachep = KMEM_CACHE(ceph_dentry_info, |
| 242 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD); |
| 243 | if (ceph_dentry_cachep == NULL) |
| 244 | goto bad_dentry; |
| 245 | |
| 246 | ceph_file_cachep = KMEM_CACHE(ceph_file_info, |
| 247 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD); |
| 248 | if (ceph_file_cachep == NULL) |
| 249 | goto bad_file; |
| 250 | |
| 251 | return 0; |
| 252 | |
| 253 | bad_file: |
| 254 | kmem_cache_destroy(ceph_dentry_cachep); |
| 255 | bad_dentry: |
| 256 | kmem_cache_destroy(ceph_cap_cachep); |
| 257 | bad_cap: |
| 258 | kmem_cache_destroy(ceph_inode_cachep); |
| 259 | return -ENOMEM; |
| 260 | } |
| 261 | |
| 262 | static void destroy_caches(void) |
| 263 | { |
| 264 | kmem_cache_destroy(ceph_inode_cachep); |
| 265 | kmem_cache_destroy(ceph_cap_cachep); |
| 266 | kmem_cache_destroy(ceph_dentry_cachep); |
| 267 | kmem_cache_destroy(ceph_file_cachep); |
| 268 | } |
| 269 | |
| 270 | |
| 271 | /* |
| 272 | * ceph_umount_begin - initiate forced umount. Tear down down the |
| 273 | * mount, skipping steps that may hang while waiting for server(s). |
| 274 | */ |
| 275 | static void ceph_umount_begin(struct super_block *sb) |
| 276 | { |
| 277 | struct ceph_client *client = ceph_sb_to_client(sb); |
| 278 | |
| 279 | dout("ceph_umount_begin - starting forced umount\n"); |
| 280 | if (!client) |
| 281 | return; |
| 282 | client->mount_state = CEPH_MOUNT_SHUTDOWN; |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | static const struct super_operations ceph_super_ops = { |
| 287 | .alloc_inode = ceph_alloc_inode, |
| 288 | .destroy_inode = ceph_destroy_inode, |
| 289 | .write_inode = ceph_write_inode, |
Sage Weil | 2d9c98a | 2010-07-30 09:38:13 -0700 | [diff] [blame^] | 290 | .sync_fs = ceph_sync_fs, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 291 | .put_super = ceph_put_super, |
| 292 | .show_options = ceph_show_options, |
| 293 | .statfs = ceph_statfs, |
| 294 | .umount_begin = ceph_umount_begin, |
| 295 | }; |
| 296 | |
| 297 | |
| 298 | const char *ceph_msg_type_name(int type) |
| 299 | { |
| 300 | switch (type) { |
| 301 | case CEPH_MSG_SHUTDOWN: return "shutdown"; |
| 302 | case CEPH_MSG_PING: return "ping"; |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 303 | case CEPH_MSG_AUTH: return "auth"; |
| 304 | case CEPH_MSG_AUTH_REPLY: return "auth_reply"; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 305 | case CEPH_MSG_MON_MAP: return "mon_map"; |
| 306 | case CEPH_MSG_MON_GET_MAP: return "mon_get_map"; |
| 307 | case CEPH_MSG_MON_SUBSCRIBE: return "mon_subscribe"; |
| 308 | case CEPH_MSG_MON_SUBSCRIBE_ACK: return "mon_subscribe_ack"; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 309 | case CEPH_MSG_STATFS: return "statfs"; |
| 310 | case CEPH_MSG_STATFS_REPLY: return "statfs_reply"; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 311 | case CEPH_MSG_MDS_MAP: return "mds_map"; |
| 312 | case CEPH_MSG_CLIENT_SESSION: return "client_session"; |
| 313 | case CEPH_MSG_CLIENT_RECONNECT: return "client_reconnect"; |
| 314 | case CEPH_MSG_CLIENT_REQUEST: return "client_request"; |
| 315 | case CEPH_MSG_CLIENT_REQUEST_FORWARD: return "client_request_forward"; |
| 316 | case CEPH_MSG_CLIENT_REPLY: return "client_reply"; |
| 317 | case CEPH_MSG_CLIENT_CAPS: return "client_caps"; |
| 318 | case CEPH_MSG_CLIENT_CAPRELEASE: return "client_cap_release"; |
| 319 | case CEPH_MSG_CLIENT_SNAP: return "client_snap"; |
| 320 | case CEPH_MSG_CLIENT_LEASE: return "client_lease"; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 321 | case CEPH_MSG_OSD_MAP: return "osd_map"; |
| 322 | case CEPH_MSG_OSD_OP: return "osd_op"; |
| 323 | case CEPH_MSG_OSD_OPREPLY: return "osd_opreply"; |
| 324 | default: return "unknown"; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | |
| 329 | /* |
| 330 | * mount options |
| 331 | */ |
| 332 | enum { |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 333 | Opt_wsize, |
| 334 | Opt_rsize, |
| 335 | Opt_osdtimeout, |
Yehuda Sadeh | 422d2cb | 2010-02-26 15:32:31 -0800 | [diff] [blame] | 336 | Opt_osdkeepalivetimeout, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 337 | Opt_mount_timeout, |
Yehuda Sadeh | f5a2041 | 2010-02-03 11:00:26 -0800 | [diff] [blame] | 338 | Opt_osd_idle_ttl, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 339 | Opt_caps_wanted_delay_min, |
| 340 | Opt_caps_wanted_delay_max, |
Sage Weil | 6e19a16 | 2010-04-29 16:38:32 -0700 | [diff] [blame] | 341 | Opt_cap_release_safety, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 342 | Opt_readdir_max_entries, |
Sage Weil | 23804d9 | 2010-05-14 13:06:30 -0700 | [diff] [blame] | 343 | Opt_readdir_max_bytes, |
Yehuda Sadeh | 2baba25 | 2009-12-18 13:51:57 -0800 | [diff] [blame] | 344 | Opt_congestion_kb, |
Sage Weil | e53c2fe | 2009-10-27 10:19:28 -0700 | [diff] [blame] | 345 | Opt_last_int, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 346 | /* int args above */ |
Sage Weil | c309f0a | 2010-06-30 21:34:01 -0700 | [diff] [blame] | 347 | Opt_fsid, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 348 | Opt_snapdirname, |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 349 | Opt_name, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 350 | Opt_secret, |
Sage Weil | e53c2fe | 2009-10-27 10:19:28 -0700 | [diff] [blame] | 351 | Opt_last_string, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 352 | /* string args above */ |
| 353 | Opt_ip, |
| 354 | Opt_noshare, |
| 355 | Opt_dirstat, |
| 356 | Opt_nodirstat, |
| 357 | Opt_rbytes, |
| 358 | Opt_norbytes, |
| 359 | Opt_nocrc, |
| 360 | Opt_noasyncreaddir, |
| 361 | }; |
| 362 | |
| 363 | static match_table_t arg_tokens = { |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 364 | {Opt_wsize, "wsize=%d"}, |
| 365 | {Opt_rsize, "rsize=%d"}, |
| 366 | {Opt_osdtimeout, "osdtimeout=%d"}, |
Yehuda Sadeh | 422d2cb | 2010-02-26 15:32:31 -0800 | [diff] [blame] | 367 | {Opt_osdkeepalivetimeout, "osdkeepalive=%d"}, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 368 | {Opt_mount_timeout, "mount_timeout=%d"}, |
Yehuda Sadeh | f5a2041 | 2010-02-03 11:00:26 -0800 | [diff] [blame] | 369 | {Opt_osd_idle_ttl, "osd_idle_ttl=%d"}, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 370 | {Opt_caps_wanted_delay_min, "caps_wanted_delay_min=%d"}, |
| 371 | {Opt_caps_wanted_delay_max, "caps_wanted_delay_max=%d"}, |
Sage Weil | 6e19a16 | 2010-04-29 16:38:32 -0700 | [diff] [blame] | 372 | {Opt_cap_release_safety, "cap_release_safety=%d"}, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 373 | {Opt_readdir_max_entries, "readdir_max_entries=%d"}, |
Sage Weil | 23804d9 | 2010-05-14 13:06:30 -0700 | [diff] [blame] | 374 | {Opt_readdir_max_bytes, "readdir_max_bytes=%d"}, |
Yehuda Sadeh | 2baba25 | 2009-12-18 13:51:57 -0800 | [diff] [blame] | 375 | {Opt_congestion_kb, "write_congestion_kb=%d"}, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 376 | /* int args above */ |
Sage Weil | c309f0a | 2010-06-30 21:34:01 -0700 | [diff] [blame] | 377 | {Opt_fsid, "fsid=%s"}, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 378 | {Opt_snapdirname, "snapdirname=%s"}, |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 379 | {Opt_name, "name=%s"}, |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 380 | {Opt_secret, "secret=%s"}, |
| 381 | /* string args above */ |
| 382 | {Opt_ip, "ip=%s"}, |
| 383 | {Opt_noshare, "noshare"}, |
| 384 | {Opt_dirstat, "dirstat"}, |
| 385 | {Opt_nodirstat, "nodirstat"}, |
| 386 | {Opt_rbytes, "rbytes"}, |
| 387 | {Opt_norbytes, "norbytes"}, |
| 388 | {Opt_nocrc, "nocrc"}, |
| 389 | {Opt_noasyncreaddir, "noasyncreaddir"}, |
| 390 | {-1, NULL} |
| 391 | }; |
| 392 | |
Sage Weil | c309f0a | 2010-06-30 21:34:01 -0700 | [diff] [blame] | 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; |
Sage Weil | a8b763a | 2010-07-08 13:00:18 -0700 | [diff] [blame] | 420 | dout("parse_fsid ret %d got fsid %pU", err, fsid); |
Sage Weil | c309f0a | 2010-06-30 21:34:01 -0700 | [diff] [blame] | 421 | return err; |
| 422 | } |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 423 | |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 424 | static struct ceph_mount_args *parse_mount_args(int flags, char *options, |
| 425 | const char *dev_name, |
| 426 | const char **path) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 427 | { |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 428 | struct ceph_mount_args *args; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 429 | const char *c; |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 430 | int err = -ENOMEM; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 431 | substring_t argstr[MAX_OPT_ARGS]; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 432 | |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 433 | args = kzalloc(sizeof(*args), GFP_KERNEL); |
| 434 | if (!args) |
| 435 | return ERR_PTR(-ENOMEM); |
| 436 | args->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*args->mon_addr), |
| 437 | GFP_KERNEL); |
| 438 | if (!args->mon_addr) |
| 439 | goto out; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 440 | |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 441 | dout("parse_mount_args %p, dev_name '%s'\n", args, dev_name); |
Sage Weil | 7b813c46 | 2009-10-26 22:07:53 -0700 | [diff] [blame] | 442 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 443 | /* start with defaults */ |
| 444 | args->sb_flags = flags; |
| 445 | args->flags = CEPH_OPT_DEFAULT; |
Yehuda Sadeh | 422d2cb | 2010-02-26 15:32:31 -0800 | [diff] [blame] | 446 | args->osd_timeout = CEPH_OSD_TIMEOUT_DEFAULT; |
| 447 | args->osd_keepalive_timeout = CEPH_OSD_KEEPALIVE_DEFAULT; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 448 | args->mount_timeout = CEPH_MOUNT_TIMEOUT_DEFAULT; /* seconds */ |
Yehuda Sadeh | f5a2041 | 2010-02-03 11:00:26 -0800 | [diff] [blame] | 449 | args->osd_idle_ttl = CEPH_OSD_IDLE_TTL_DEFAULT; /* seconds */ |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 450 | args->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT; |
| 451 | args->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT; |
Sage Weil | 8fa9765 | 2009-10-16 14:44:35 -0700 | [diff] [blame] | 452 | args->rsize = CEPH_MOUNT_RSIZE_DEFAULT; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 453 | args->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL); |
Sage Weil | 6e19a16 | 2010-04-29 16:38:32 -0700 | [diff] [blame] | 454 | args->cap_release_safety = CEPH_CAP_RELEASE_SAFETY_DEFAULT; |
| 455 | args->max_readdir = CEPH_MAX_READDIR_DEFAULT; |
Sage Weil | 23804d9 | 2010-05-14 13:06:30 -0700 | [diff] [blame] | 456 | args->max_readdir_bytes = CEPH_MAX_READDIR_BYTES_DEFAULT; |
Yehuda Sadeh | 2baba25 | 2009-12-18 13:51:57 -0800 | [diff] [blame] | 457 | args->congestion_kb = default_congestion_kb(); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 458 | |
| 459 | /* ip1[:port1][,ip2[:port2]...]:/subdir/in/fs */ |
Sage Weil | 7b813c46 | 2009-10-26 22:07:53 -0700 | [diff] [blame] | 460 | err = -EINVAL; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 461 | if (!dev_name) |
Sage Weil | 7b813c46 | 2009-10-26 22:07:53 -0700 | [diff] [blame] | 462 | goto out; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 463 | *path = strstr(dev_name, ":/"); |
| 464 | if (*path == NULL) { |
| 465 | pr_err("device name is missing path (no :/ in %s)\n", |
| 466 | dev_name); |
Sage Weil | 7b813c46 | 2009-10-26 22:07:53 -0700 | [diff] [blame] | 467 | goto out; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | /* get mon ip(s) */ |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 471 | err = ceph_parse_ips(dev_name, *path, args->mon_addr, |
| 472 | CEPH_MAX_MON, &args->num_mon); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 473 | if (err < 0) |
Sage Weil | 7b813c46 | 2009-10-26 22:07:53 -0700 | [diff] [blame] | 474 | goto out; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 475 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 476 | /* path on server */ |
| 477 | *path += 2; |
| 478 | dout("server path '%s'\n", *path); |
| 479 | |
| 480 | /* parse mount options */ |
| 481 | while ((c = strsep(&options, ",")) != NULL) { |
| 482 | int token, intval, ret; |
| 483 | if (!*c) |
| 484 | continue; |
Sage Weil | 7b813c46 | 2009-10-26 22:07:53 -0700 | [diff] [blame] | 485 | err = -EINVAL; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 486 | token = match_token((char *)c, arg_tokens, argstr); |
| 487 | if (token < 0) { |
| 488 | pr_err("bad mount option at '%s'\n", c); |
Sage Weil | 7b813c46 | 2009-10-26 22:07:53 -0700 | [diff] [blame] | 489 | goto out; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 490 | } |
Sage Weil | e53c2fe | 2009-10-27 10:19:28 -0700 | [diff] [blame] | 491 | if (token < Opt_last_int) { |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 492 | ret = match_int(&argstr[0], &intval); |
| 493 | if (ret < 0) { |
| 494 | pr_err("bad mount option arg (not int) " |
| 495 | "at '%s'\n", c); |
| 496 | continue; |
| 497 | } |
Sage Weil | e53c2fe | 2009-10-27 10:19:28 -0700 | [diff] [blame] | 498 | dout("got int token %d val %d\n", token, intval); |
| 499 | } else if (token > Opt_last_int && token < Opt_last_string) { |
| 500 | dout("got string token %d val %s\n", token, |
| 501 | argstr[0].from); |
| 502 | } else { |
| 503 | dout("got token %d\n", token); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 504 | } |
| 505 | switch (token) { |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 506 | case Opt_ip: |
| 507 | err = ceph_parse_ips(argstr[0].from, |
| 508 | argstr[0].to, |
| 509 | &args->my_addr, |
| 510 | 1, NULL); |
| 511 | if (err < 0) |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 512 | goto out; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 513 | args->flags |= CEPH_OPT_MYIP; |
| 514 | break; |
| 515 | |
Sage Weil | c309f0a | 2010-06-30 21:34:01 -0700 | [diff] [blame] | 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; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 521 | case Opt_snapdirname: |
| 522 | kfree(args->snapdir_name); |
| 523 | args->snapdir_name = kstrndup(argstr[0].from, |
| 524 | argstr[0].to-argstr[0].from, |
| 525 | GFP_KERNEL); |
| 526 | break; |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 527 | case Opt_name: |
| 528 | args->name = kstrndup(argstr[0].from, |
| 529 | argstr[0].to-argstr[0].from, |
| 530 | GFP_KERNEL); |
| 531 | break; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 532 | case Opt_secret: |
| 533 | args->secret = kstrndup(argstr[0].from, |
| 534 | argstr[0].to-argstr[0].from, |
| 535 | GFP_KERNEL); |
| 536 | break; |
| 537 | |
| 538 | /* misc */ |
| 539 | case Opt_wsize: |
| 540 | args->wsize = intval; |
| 541 | break; |
| 542 | case Opt_rsize: |
| 543 | args->rsize = intval; |
| 544 | break; |
| 545 | case Opt_osdtimeout: |
| 546 | args->osd_timeout = intval; |
| 547 | break; |
Yehuda Sadeh | 422d2cb | 2010-02-26 15:32:31 -0800 | [diff] [blame] | 548 | case Opt_osdkeepalivetimeout: |
| 549 | args->osd_keepalive_timeout = intval; |
| 550 | break; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 551 | case Opt_mount_timeout: |
| 552 | args->mount_timeout = intval; |
| 553 | break; |
| 554 | case Opt_caps_wanted_delay_min: |
| 555 | args->caps_wanted_delay_min = intval; |
| 556 | break; |
| 557 | case Opt_caps_wanted_delay_max: |
| 558 | args->caps_wanted_delay_max = intval; |
| 559 | break; |
| 560 | case Opt_readdir_max_entries: |
| 561 | args->max_readdir = intval; |
| 562 | break; |
Sage Weil | 23804d9 | 2010-05-14 13:06:30 -0700 | [diff] [blame] | 563 | case Opt_readdir_max_bytes: |
| 564 | args->max_readdir_bytes = intval; |
| 565 | break; |
Yehuda Sadeh | 2baba25 | 2009-12-18 13:51:57 -0800 | [diff] [blame] | 566 | case Opt_congestion_kb: |
| 567 | args->congestion_kb = intval; |
| 568 | break; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 569 | |
| 570 | case Opt_noshare: |
| 571 | args->flags |= CEPH_OPT_NOSHARE; |
| 572 | break; |
| 573 | |
| 574 | case Opt_dirstat: |
| 575 | args->flags |= CEPH_OPT_DIRSTAT; |
| 576 | break; |
| 577 | case Opt_nodirstat: |
| 578 | args->flags &= ~CEPH_OPT_DIRSTAT; |
| 579 | break; |
| 580 | case Opt_rbytes: |
| 581 | args->flags |= CEPH_OPT_RBYTES; |
| 582 | break; |
| 583 | case Opt_norbytes: |
| 584 | args->flags &= ~CEPH_OPT_RBYTES; |
| 585 | break; |
| 586 | case Opt_nocrc: |
| 587 | args->flags |= CEPH_OPT_NOCRC; |
| 588 | break; |
| 589 | case Opt_noasyncreaddir: |
| 590 | args->flags |= CEPH_OPT_NOASYNCREADDIR; |
| 591 | break; |
| 592 | |
| 593 | default: |
| 594 | BUG_ON(token); |
| 595 | } |
| 596 | } |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 597 | return args; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 598 | |
Sage Weil | 7b813c46 | 2009-10-26 22:07:53 -0700 | [diff] [blame] | 599 | out: |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 600 | kfree(args->mon_addr); |
| 601 | kfree(args); |
| 602 | return ERR_PTR(err); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 603 | } |
| 604 | |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 605 | static void destroy_mount_args(struct ceph_mount_args *args) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 606 | { |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 607 | dout("destroy_mount_args %p\n", args); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 608 | kfree(args->snapdir_name); |
| 609 | args->snapdir_name = NULL; |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 610 | kfree(args->name); |
| 611 | args->name = NULL; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 612 | kfree(args->secret); |
| 613 | args->secret = NULL; |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 614 | kfree(args); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | /* |
| 618 | * create a fresh client instance |
| 619 | */ |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 620 | static struct ceph_client *ceph_create_client(struct ceph_mount_args *args) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 621 | { |
| 622 | struct ceph_client *client; |
| 623 | int err = -ENOMEM; |
| 624 | |
| 625 | client = kzalloc(sizeof(*client), GFP_KERNEL); |
| 626 | if (client == NULL) |
| 627 | return ERR_PTR(-ENOMEM); |
| 628 | |
| 629 | mutex_init(&client->mount_mutex); |
| 630 | |
Sage Weil | 9bd2e6f | 2010-02-02 16:21:06 -0800 | [diff] [blame] | 631 | init_waitqueue_head(&client->auth_wq); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 632 | |
| 633 | client->sb = NULL; |
| 634 | client->mount_state = CEPH_MOUNT_MOUNTING; |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 635 | client->mount_args = args; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 636 | |
| 637 | client->msgr = NULL; |
| 638 | |
Sage Weil | 9bd2e6f | 2010-02-02 16:21:06 -0800 | [diff] [blame] | 639 | client->auth_err = 0; |
Yehuda Sadeh | 2baba25 | 2009-12-18 13:51:57 -0800 | [diff] [blame] | 640 | atomic_long_set(&client->writeback_count, 0); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 641 | |
Sage Weil | 859e7b1 | 2009-11-02 09:32:47 -0800 | [diff] [blame] | 642 | err = bdi_init(&client->backing_dev_info); |
| 643 | if (err < 0) |
| 644 | goto fail; |
| 645 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 646 | err = -ENOMEM; |
| 647 | client->wb_wq = create_workqueue("ceph-writeback"); |
| 648 | if (client->wb_wq == NULL) |
Sage Weil | 859e7b1 | 2009-11-02 09:32:47 -0800 | [diff] [blame] | 649 | goto fail_bdi; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 650 | client->pg_inv_wq = create_singlethread_workqueue("ceph-pg-invalid"); |
| 651 | if (client->pg_inv_wq == NULL) |
| 652 | goto fail_wb_wq; |
| 653 | client->trunc_wq = create_singlethread_workqueue("ceph-trunc"); |
| 654 | if (client->trunc_wq == NULL) |
| 655 | goto fail_pg_inv_wq; |
| 656 | |
Sage Weil | b9bfb93 | 2009-11-18 15:08:44 -0800 | [diff] [blame] | 657 | /* set up mempools */ |
| 658 | err = -ENOMEM; |
| 659 | client->wb_pagevec_pool = mempool_create_kmalloc_pool(10, |
| 660 | client->mount_args->wsize >> PAGE_CACHE_SHIFT); |
| 661 | if (!client->wb_pagevec_pool) |
| 662 | goto fail_trunc_wq; |
| 663 | |
Sage Weil | 85ccce4 | 2010-02-17 10:02:43 -0800 | [diff] [blame] | 664 | /* caps */ |
| 665 | client->min_caps = args->max_readdir; |
Sage Weil | b9bfb93 | 2009-11-18 15:08:44 -0800 | [diff] [blame] | 666 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 667 | /* subsystems */ |
| 668 | err = ceph_monc_init(&client->monc, client); |
| 669 | if (err < 0) |
Sage Weil | b9bfb93 | 2009-11-18 15:08:44 -0800 | [diff] [blame] | 670 | goto fail_mempool; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 671 | err = ceph_osdc_init(&client->osdc, client); |
| 672 | if (err < 0) |
| 673 | goto fail_monc; |
Sage Weil | 5f44f14 | 2009-11-18 14:52:18 -0800 | [diff] [blame] | 674 | err = ceph_mdsc_init(&client->mdsc, client); |
| 675 | if (err < 0) |
| 676 | goto fail_osdc; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 677 | return client; |
| 678 | |
Sage Weil | 5f44f14 | 2009-11-18 14:52:18 -0800 | [diff] [blame] | 679 | fail_osdc: |
| 680 | ceph_osdc_stop(&client->osdc); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 681 | fail_monc: |
| 682 | ceph_monc_stop(&client->monc); |
Sage Weil | b9bfb93 | 2009-11-18 15:08:44 -0800 | [diff] [blame] | 683 | fail_mempool: |
| 684 | mempool_destroy(client->wb_pagevec_pool); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 685 | fail_trunc_wq: |
| 686 | destroy_workqueue(client->trunc_wq); |
| 687 | fail_pg_inv_wq: |
| 688 | destroy_workqueue(client->pg_inv_wq); |
| 689 | fail_wb_wq: |
| 690 | destroy_workqueue(client->wb_wq); |
Sage Weil | 859e7b1 | 2009-11-02 09:32:47 -0800 | [diff] [blame] | 691 | fail_bdi: |
| 692 | bdi_destroy(&client->backing_dev_info); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 693 | fail: |
| 694 | kfree(client); |
| 695 | return ERR_PTR(err); |
| 696 | } |
| 697 | |
| 698 | static void ceph_destroy_client(struct ceph_client *client) |
| 699 | { |
| 700 | dout("destroy_client %p\n", client); |
| 701 | |
| 702 | /* unmount */ |
| 703 | ceph_mdsc_stop(&client->mdsc); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 704 | ceph_osdc_stop(&client->osdc); |
| 705 | |
Sage Weil | a922d38 | 2010-05-29 09:41:23 -0700 | [diff] [blame] | 706 | /* |
| 707 | * make sure mds and osd connections close out before destroying |
| 708 | * the auth module, which is needed to free those connections' |
| 709 | * ceph_authorizers. |
| 710 | */ |
| 711 | ceph_msgr_flush(); |
| 712 | |
| 713 | ceph_monc_stop(&client->monc); |
| 714 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 715 | ceph_debugfs_client_cleanup(client); |
| 716 | destroy_workqueue(client->wb_wq); |
| 717 | destroy_workqueue(client->pg_inv_wq); |
| 718 | destroy_workqueue(client->trunc_wq); |
| 719 | |
Sage Weil | 5dfc589 | 2010-05-04 16:14:46 -0700 | [diff] [blame] | 720 | bdi_destroy(&client->backing_dev_info); |
| 721 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 722 | if (client->msgr) |
| 723 | ceph_messenger_destroy(client->msgr); |
Sage Weil | b9bfb93 | 2009-11-18 15:08:44 -0800 | [diff] [blame] | 724 | mempool_destroy(client->wb_pagevec_pool); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 725 | |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 726 | destroy_mount_args(client->mount_args); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 727 | |
| 728 | kfree(client); |
| 729 | dout("destroy_client %p done\n", client); |
| 730 | } |
| 731 | |
| 732 | /* |
Sage Weil | 0743304 | 2009-11-18 16:50:41 -0800 | [diff] [blame] | 733 | * Initially learn our fsid, or verify an fsid matches. |
| 734 | */ |
| 735 | int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid) |
| 736 | { |
| 737 | if (client->have_fsid) { |
| 738 | if (ceph_fsid_compare(&client->fsid, fsid)) { |
Sage Weil | a8b763a | 2010-07-08 13:00:18 -0700 | [diff] [blame] | 739 | pr_err("bad fsid, had %pU got %pU", |
| 740 | &client->fsid, fsid); |
Sage Weil | 0743304 | 2009-11-18 16:50:41 -0800 | [diff] [blame] | 741 | return -1; |
| 742 | } |
| 743 | } else { |
Sage Weil | a8b763a | 2010-07-08 13:00:18 -0700 | [diff] [blame] | 744 | pr_info("client%lld fsid %pU\n", client->monc.auth->global_id, |
| 745 | fsid); |
Sage Weil | 0743304 | 2009-11-18 16:50:41 -0800 | [diff] [blame] | 746 | memcpy(&client->fsid, fsid, sizeof(*fsid)); |
| 747 | ceph_debugfs_client_init(client); |
| 748 | client->have_fsid = true; |
| 749 | } |
| 750 | return 0; |
| 751 | } |
| 752 | |
| 753 | /* |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 754 | * true if we have the mon map (and have thus joined the cluster) |
| 755 | */ |
Sage Weil | 6822d00 | 2010-04-07 11:23:20 -0700 | [diff] [blame] | 756 | static int have_mon_and_osd_map(struct ceph_client *client) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 757 | { |
Sage Weil | 6822d00 | 2010-04-07 11:23:20 -0700 | [diff] [blame] | 758 | return client->monc.monmap && client->monc.monmap->epoch && |
| 759 | client->osdc.osdmap && client->osdc.osdmap->epoch; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | /* |
| 763 | * Bootstrap mount by opening the root directory. Note the mount |
| 764 | * @started time from caller, and time out if this takes too long. |
| 765 | */ |
| 766 | static struct dentry *open_root_dentry(struct ceph_client *client, |
| 767 | const char *path, |
| 768 | unsigned long started) |
| 769 | { |
| 770 | struct ceph_mds_client *mdsc = &client->mdsc; |
| 771 | struct ceph_mds_request *req = NULL; |
| 772 | int err; |
| 773 | struct dentry *root; |
| 774 | |
| 775 | /* open dir */ |
| 776 | dout("open_root_inode opening '%s'\n", path); |
| 777 | req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS); |
| 778 | if (IS_ERR(req)) |
Julia Lawall | 7e34bc5 | 2010-05-22 12:01:14 +0200 | [diff] [blame] | 779 | return ERR_CAST(req); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 780 | req->r_path1 = kstrdup(path, GFP_NOFS); |
| 781 | req->r_ino1.ino = CEPH_INO_ROOT; |
| 782 | req->r_ino1.snap = CEPH_NOSNAP; |
| 783 | req->r_started = started; |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 784 | req->r_timeout = client->mount_args->mount_timeout * HZ; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 785 | req->r_args.getattr.mask = cpu_to_le32(CEPH_STAT_CAP_INODE); |
| 786 | req->r_num_caps = 2; |
| 787 | err = ceph_mdsc_do_request(mdsc, NULL, req); |
| 788 | if (err == 0) { |
| 789 | dout("open_root_inode success\n"); |
| 790 | if (ceph_ino(req->r_target_inode) == CEPH_INO_ROOT && |
| 791 | client->sb->s_root == NULL) |
| 792 | root = d_alloc_root(req->r_target_inode); |
| 793 | else |
| 794 | root = d_obtain_alias(req->r_target_inode); |
| 795 | req->r_target_inode = NULL; |
| 796 | dout("open_root_inode success, root dentry is %p\n", root); |
| 797 | } else { |
| 798 | root = ERR_PTR(err); |
| 799 | } |
| 800 | ceph_mdsc_put_request(req); |
| 801 | return root; |
| 802 | } |
| 803 | |
| 804 | /* |
| 805 | * mount: join the ceph cluster, and open root directory. |
| 806 | */ |
| 807 | static int ceph_mount(struct ceph_client *client, struct vfsmount *mnt, |
| 808 | const char *path) |
| 809 | { |
| 810 | struct ceph_entity_addr *myaddr = NULL; |
| 811 | int err; |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 812 | unsigned long timeout = client->mount_args->mount_timeout * HZ; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 813 | unsigned long started = jiffies; /* note the start time */ |
| 814 | struct dentry *root; |
| 815 | |
| 816 | dout("mount start\n"); |
| 817 | mutex_lock(&client->mount_mutex); |
| 818 | |
| 819 | /* initialize the messenger */ |
| 820 | if (client->msgr == NULL) { |
| 821 | if (ceph_test_opt(client, MYIP)) |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 822 | myaddr = &client->mount_args->my_addr; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 823 | client->msgr = ceph_messenger_create(myaddr); |
| 824 | if (IS_ERR(client->msgr)) { |
| 825 | err = PTR_ERR(client->msgr); |
| 826 | client->msgr = NULL; |
| 827 | goto out; |
| 828 | } |
| 829 | client->msgr->nocrc = ceph_test_opt(client, NOCRC); |
| 830 | } |
| 831 | |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 832 | /* open session, and wait for mon, mds, and osd maps */ |
| 833 | err = ceph_monc_open_session(&client->monc); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 834 | if (err < 0) |
| 835 | goto out; |
| 836 | |
Sage Weil | 6822d00 | 2010-04-07 11:23:20 -0700 | [diff] [blame] | 837 | while (!have_mon_and_osd_map(client)) { |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 838 | err = -EIO; |
| 839 | if (timeout && time_after_eq(jiffies, started + timeout)) |
| 840 | goto out; |
| 841 | |
| 842 | /* wait */ |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 843 | dout("mount waiting for mon_map\n"); |
Sage Weil | 9bd2e6f | 2010-02-02 16:21:06 -0800 | [diff] [blame] | 844 | err = wait_event_interruptible_timeout(client->auth_wq, |
Sage Weil | 6822d00 | 2010-04-07 11:23:20 -0700 | [diff] [blame] | 845 | have_mon_and_osd_map(client) || (client->auth_err < 0), |
| 846 | timeout); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 847 | if (err == -EINTR || err == -ERESTARTSYS) |
| 848 | goto out; |
Sage Weil | 9bd2e6f | 2010-02-02 16:21:06 -0800 | [diff] [blame] | 849 | if (client->auth_err < 0) { |
| 850 | err = client->auth_err; |
Yehuda Sadeh | dc14657 | 2009-11-20 13:59:13 -0800 | [diff] [blame] | 851 | goto out; |
| 852 | } |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | dout("mount opening root\n"); |
| 856 | root = open_root_dentry(client, "", started); |
| 857 | if (IS_ERR(root)) { |
| 858 | err = PTR_ERR(root); |
| 859 | goto out; |
| 860 | } |
| 861 | if (client->sb->s_root) |
| 862 | dput(root); |
| 863 | else |
| 864 | client->sb->s_root = root; |
| 865 | |
| 866 | if (path[0] == 0) { |
| 867 | dget(root); |
| 868 | } else { |
| 869 | dout("mount opening base mountpoint\n"); |
| 870 | root = open_root_dentry(client, path, started); |
| 871 | if (IS_ERR(root)) { |
| 872 | err = PTR_ERR(root); |
| 873 | dput(client->sb->s_root); |
| 874 | client->sb->s_root = NULL; |
| 875 | goto out; |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | mnt->mnt_root = root; |
| 880 | mnt->mnt_sb = client->sb; |
| 881 | |
| 882 | client->mount_state = CEPH_MOUNT_MOUNTED; |
| 883 | dout("mount success\n"); |
| 884 | err = 0; |
| 885 | |
| 886 | out: |
| 887 | mutex_unlock(&client->mount_mutex); |
| 888 | return err; |
| 889 | } |
| 890 | |
| 891 | static int ceph_set_super(struct super_block *s, void *data) |
| 892 | { |
| 893 | struct ceph_client *client = data; |
| 894 | int ret; |
| 895 | |
| 896 | dout("set_super %p data %p\n", s, data); |
| 897 | |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 898 | s->s_flags = client->mount_args->sb_flags; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 899 | s->s_maxbytes = 1ULL << 40; /* temp value until we get mdsmap */ |
| 900 | |
| 901 | s->s_fs_info = client; |
| 902 | client->sb = s; |
| 903 | |
| 904 | s->s_op = &ceph_super_ops; |
| 905 | s->s_export_op = &ceph_export_ops; |
| 906 | |
| 907 | s->s_time_gran = 1000; /* 1000 ns == 1 us */ |
| 908 | |
| 909 | ret = set_anon_super(s, NULL); /* what is that second arg for? */ |
| 910 | if (ret != 0) |
| 911 | goto fail; |
| 912 | |
| 913 | return ret; |
| 914 | |
| 915 | fail: |
| 916 | s->s_fs_info = NULL; |
| 917 | client->sb = NULL; |
| 918 | return ret; |
| 919 | } |
| 920 | |
| 921 | /* |
| 922 | * share superblock if same fs AND options |
| 923 | */ |
| 924 | static int ceph_compare_super(struct super_block *sb, void *data) |
| 925 | { |
| 926 | struct ceph_client *new = data; |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 927 | struct ceph_mount_args *args = new->mount_args; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 928 | struct ceph_client *other = ceph_sb_to_client(sb); |
| 929 | int i; |
| 930 | |
| 931 | dout("ceph_compare_super %p\n", sb); |
| 932 | if (args->flags & CEPH_OPT_FSID) { |
| 933 | if (ceph_fsid_compare(&args->fsid, &other->fsid)) { |
| 934 | dout("fsid doesn't match\n"); |
| 935 | return 0; |
| 936 | } |
| 937 | } else { |
| 938 | /* do we share (a) monitor? */ |
| 939 | for (i = 0; i < new->monc.monmap->num_mon; i++) |
| 940 | if (ceph_monmap_contains(other->monc.monmap, |
| 941 | &new->monc.monmap->mon_inst[i].addr)) |
| 942 | break; |
| 943 | if (i == new->monc.monmap->num_mon) { |
| 944 | dout("mon ip not part of monmap\n"); |
| 945 | return 0; |
| 946 | } |
| 947 | dout("mon ip matches existing sb %p\n", sb); |
| 948 | } |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 949 | if (args->sb_flags != other->mount_args->sb_flags) { |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 950 | dout("flags differ\n"); |
| 951 | return 0; |
| 952 | } |
| 953 | return 1; |
| 954 | } |
| 955 | |
| 956 | /* |
| 957 | * construct our own bdi so we can control readahead, etc. |
| 958 | */ |
Jeff Mahoney | 00d5643 | 2010-06-10 11:13:58 -0400 | [diff] [blame] | 959 | static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0); |
Sage Weil | 31e0cf8 | 2010-05-04 16:39:35 -0700 | [diff] [blame] | 960 | |
Sage Weil | 859e7b1 | 2009-11-02 09:32:47 -0800 | [diff] [blame] | 961 | static int ceph_register_bdi(struct super_block *sb, struct ceph_client *client) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 962 | { |
| 963 | int err; |
| 964 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 965 | /* set ra_pages based on rsize mount option? */ |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 966 | if (client->mount_args->rsize >= PAGE_CACHE_SIZE) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 967 | client->backing_dev_info.ra_pages = |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 968 | (client->mount_args->rsize + PAGE_CACHE_SIZE - 1) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 969 | >> PAGE_SHIFT; |
Sage Weil | 31e0cf8 | 2010-05-04 16:39:35 -0700 | [diff] [blame] | 970 | err = bdi_register(&client->backing_dev_info, NULL, "ceph-%d", |
| 971 | atomic_long_inc_return(&bdi_seq)); |
Sage Weil | 5dfc589 | 2010-05-04 16:14:46 -0700 | [diff] [blame] | 972 | if (!err) |
| 973 | sb->s_bdi = &client->backing_dev_info; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 974 | return err; |
| 975 | } |
| 976 | |
| 977 | static int ceph_get_sb(struct file_system_type *fs_type, |
| 978 | int flags, const char *dev_name, void *data, |
| 979 | struct vfsmount *mnt) |
| 980 | { |
| 981 | struct super_block *sb; |
| 982 | struct ceph_client *client; |
| 983 | int err; |
| 984 | int (*compare_super)(struct super_block *, void *) = ceph_compare_super; |
Sage Weil | 6a18be1 | 2009-11-04 11:40:05 -0800 | [diff] [blame] | 985 | const char *path = NULL; |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 986 | struct ceph_mount_args *args; |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 987 | |
| 988 | dout("ceph_get_sb\n"); |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 989 | args = parse_mount_args(flags, data, dev_name, &path); |
| 990 | if (IS_ERR(args)) { |
| 991 | err = PTR_ERR(args); |
| 992 | goto out_final; |
| 993 | } |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 994 | |
| 995 | /* create client (which we may/may not use) */ |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 996 | client = ceph_create_client(args); |
| 997 | if (IS_ERR(client)) { |
| 998 | err = PTR_ERR(client); |
| 999 | goto out_final; |
| 1000 | } |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1001 | |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 1002 | if (client->mount_args->flags & CEPH_OPT_NOSHARE) |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1003 | compare_super = NULL; |
| 1004 | sb = sget(fs_type, compare_super, ceph_set_super, client); |
| 1005 | if (IS_ERR(sb)) { |
| 1006 | err = PTR_ERR(sb); |
| 1007 | goto out; |
| 1008 | } |
| 1009 | |
Cheng Renquan | 640ef79 | 2010-03-26 17:40:33 +0800 | [diff] [blame] | 1010 | if (ceph_sb_to_client(sb) != client) { |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1011 | ceph_destroy_client(client); |
Cheng Renquan | 640ef79 | 2010-03-26 17:40:33 +0800 | [diff] [blame] | 1012 | client = ceph_sb_to_client(sb); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1013 | dout("get_sb got existing client %p\n", client); |
| 1014 | } else { |
| 1015 | dout("get_sb using new client %p\n", client); |
Sage Weil | 859e7b1 | 2009-11-02 09:32:47 -0800 | [diff] [blame] | 1016 | err = ceph_register_bdi(sb, client); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1017 | if (err < 0) |
| 1018 | goto out_splat; |
| 1019 | } |
| 1020 | |
| 1021 | err = ceph_mount(client, mnt, path); |
| 1022 | if (err < 0) |
| 1023 | goto out_splat; |
| 1024 | dout("root %p inode %p ino %llx.%llx\n", mnt->mnt_root, |
| 1025 | mnt->mnt_root->d_inode, ceph_vinop(mnt->mnt_root->d_inode)); |
| 1026 | return 0; |
| 1027 | |
| 1028 | out_splat: |
| 1029 | ceph_mdsc_close_sessions(&client->mdsc); |
Al Viro | 3981f2e | 2010-03-21 19:22:29 -0400 | [diff] [blame] | 1030 | deactivate_locked_super(sb); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1031 | goto out_final; |
| 1032 | |
| 1033 | out: |
| 1034 | ceph_destroy_client(client); |
| 1035 | out_final: |
| 1036 | dout("ceph_get_sb fail %d\n", err); |
| 1037 | return err; |
| 1038 | } |
| 1039 | |
| 1040 | static void ceph_kill_sb(struct super_block *s) |
| 1041 | { |
| 1042 | struct ceph_client *client = ceph_sb_to_client(s); |
| 1043 | dout("kill_sb %p\n", s); |
| 1044 | ceph_mdsc_pre_umount(&client->mdsc); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1045 | kill_anon_super(s); /* will call put_super after sb is r/o */ |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1046 | ceph_destroy_client(client); |
| 1047 | } |
| 1048 | |
| 1049 | static struct file_system_type ceph_fs_type = { |
| 1050 | .owner = THIS_MODULE, |
| 1051 | .name = "ceph", |
| 1052 | .get_sb = ceph_get_sb, |
| 1053 | .kill_sb = ceph_kill_sb, |
| 1054 | .fs_flags = FS_RENAME_DOES_D_MOVE, |
| 1055 | }; |
| 1056 | |
| 1057 | #define _STRINGIFY(x) #x |
| 1058 | #define STRINGIFY(x) _STRINGIFY(x) |
| 1059 | |
| 1060 | static int __init init_ceph(void) |
| 1061 | { |
| 1062 | int ret = 0; |
| 1063 | |
| 1064 | ret = ceph_debugfs_init(); |
| 1065 | if (ret < 0) |
| 1066 | goto out; |
| 1067 | |
| 1068 | ret = ceph_msgr_init(); |
| 1069 | if (ret < 0) |
| 1070 | goto out_debugfs; |
| 1071 | |
| 1072 | ret = init_caches(); |
| 1073 | if (ret) |
| 1074 | goto out_msgr; |
| 1075 | |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1076 | ret = register_filesystem(&ceph_fs_type); |
| 1077 | if (ret) |
| 1078 | goto out_icache; |
| 1079 | |
Sage Weil | c8f1658 | 2010-04-19 13:50:26 -0700 | [diff] [blame] | 1080 | pr_info("loaded (mon/mds/osd proto %d/%d/%d, osdmap %d/%d %d/%d)\n", |
| 1081 | CEPH_MONC_PROTOCOL, CEPH_MDSC_PROTOCOL, CEPH_OSDC_PROTOCOL, |
| 1082 | CEPH_OSDMAP_VERSION, CEPH_OSDMAP_VERSION_EXT, |
| 1083 | CEPH_OSDMAP_INC_VERSION, CEPH_OSDMAP_INC_VERSION_EXT); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1084 | return 0; |
| 1085 | |
| 1086 | out_icache: |
| 1087 | destroy_caches(); |
| 1088 | out_msgr: |
| 1089 | ceph_msgr_exit(); |
| 1090 | out_debugfs: |
| 1091 | ceph_debugfs_cleanup(); |
| 1092 | out: |
| 1093 | return ret; |
| 1094 | } |
| 1095 | |
| 1096 | static void __exit exit_ceph(void) |
| 1097 | { |
| 1098 | dout("exit_ceph\n"); |
| 1099 | unregister_filesystem(&ceph_fs_type); |
Sage Weil | 16725b9 | 2009-10-06 11:31:07 -0700 | [diff] [blame] | 1100 | destroy_caches(); |
| 1101 | ceph_msgr_exit(); |
| 1102 | ceph_debugfs_cleanup(); |
| 1103 | } |
| 1104 | |
| 1105 | module_init(init_ceph); |
| 1106 | module_exit(exit_ceph); |
| 1107 | |
| 1108 | MODULE_AUTHOR("Sage Weil <sage@newdream.net>"); |
| 1109 | MODULE_AUTHOR("Yehuda Sadeh <yehuda@hq.newdream.net>"); |
| 1110 | MODULE_AUTHOR("Patience Warnick <patience@newdream.net>"); |
| 1111 | MODULE_DESCRIPTION("Ceph filesystem for Linux"); |
| 1112 | MODULE_LICENSE("GPL"); |