2 * Copyright (C) 2007 Oracle. All rights reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
19 #include <linux/blkdev.h>
20 #include <linux/module.h>
21 #include <linux/buffer_head.h>
23 #include <linux/pagemap.h>
24 #include <linux/highmem.h>
25 #include <linux/time.h>
26 #include <linux/init.h>
27 #include <linux/seq_file.h>
28 #include <linux/string.h>
29 #include <linux/backing-dev.h>
30 #include <linux/mount.h>
31 #include <linux/mpage.h>
32 #include <linux/swap.h>
33 #include <linux/writeback.h>
34 #include <linux/statfs.h>
35 #include <linux/compat.h>
36 #include <linux/parser.h>
37 #include <linux/ctype.h>
38 #include <linux/namei.h>
39 #include <linux/miscdevice.h>
40 #include <linux/magic.h>
44 #include "transaction.h"
45 #include "btrfs_inode.h"
47 #include "print-tree.h"
52 #include "compression.h"
54 static const struct super_operations btrfs_super_ops
;
56 static void btrfs_put_super(struct super_block
*sb
)
58 struct btrfs_root
*root
= btrfs_sb(sb
);
61 ret
= close_ctree(root
);
66 Opt_degraded
, Opt_subvol
, Opt_subvolid
, Opt_device
, Opt_nodatasum
,
67 Opt_nodatacow
, Opt_max_extent
, Opt_max_inline
, Opt_alloc_start
,
68 Opt_nobarrier
, Opt_ssd
, Opt_nossd
, Opt_ssd_spread
, Opt_thread_pool
,
69 Opt_noacl
, Opt_compress
, Opt_compress_force
, Opt_notreelog
, Opt_ratio
,
74 static match_table_t tokens
= {
75 {Opt_degraded
, "degraded"},
76 {Opt_subvol
, "subvol=%s"},
77 {Opt_subvolid
, "subvolid=%d"},
78 {Opt_device
, "device=%s"},
79 {Opt_nodatasum
, "nodatasum"},
80 {Opt_nodatacow
, "nodatacow"},
81 {Opt_nobarrier
, "nobarrier"},
82 {Opt_max_extent
, "max_extent=%s"},
83 {Opt_max_inline
, "max_inline=%s"},
84 {Opt_alloc_start
, "alloc_start=%s"},
85 {Opt_thread_pool
, "thread_pool=%d"},
86 {Opt_compress
, "compress"},
87 {Opt_compress_force
, "compress-force"},
89 {Opt_ssd_spread
, "ssd_spread"},
92 {Opt_notreelog
, "notreelog"},
93 {Opt_flushoncommit
, "flushoncommit"},
94 {Opt_ratio
, "metadata_ratio=%d"},
95 {Opt_discard
, "discard"},
99 u64
btrfs_parse_size(char *str
)
106 res
= simple_strtoul(str
, &end
, 10);
110 last
= tolower(last
);
125 * Regular mount options parser. Everything that is needed only when
126 * reading in a new superblock is parsed here.
128 int btrfs_parse_options(struct btrfs_root
*root
, char *options
)
130 struct btrfs_fs_info
*info
= root
->fs_info
;
131 substring_t args
[MAX_OPT_ARGS
];
132 char *p
, *num
, *orig
;
140 * strsep changes the string, duplicate it because parse_options
143 options
= kstrdup(options
, GFP_NOFS
);
149 while ((p
= strsep(&options
, ",")) != NULL
) {
154 token
= match_token(p
, tokens
, args
);
157 printk(KERN_INFO
"btrfs: allowing degraded mounts\n");
158 btrfs_set_opt(info
->mount_opt
, DEGRADED
);
164 * These are parsed by btrfs_parse_early_options
165 * and can be happily ignored here.
169 printk(KERN_INFO
"btrfs: setting nodatasum\n");
170 btrfs_set_opt(info
->mount_opt
, NODATASUM
);
173 printk(KERN_INFO
"btrfs: setting nodatacow\n");
174 btrfs_set_opt(info
->mount_opt
, NODATACOW
);
175 btrfs_set_opt(info
->mount_opt
, NODATASUM
);
178 printk(KERN_INFO
"btrfs: use compression\n");
179 btrfs_set_opt(info
->mount_opt
, COMPRESS
);
181 case Opt_compress_force
:
182 printk(KERN_INFO
"btrfs: forcing compression\n");
183 btrfs_set_opt(info
->mount_opt
, FORCE_COMPRESS
);
184 btrfs_set_opt(info
->mount_opt
, COMPRESS
);
187 printk(KERN_INFO
"btrfs: use ssd allocation scheme\n");
188 btrfs_set_opt(info
->mount_opt
, SSD
);
191 printk(KERN_INFO
"btrfs: use spread ssd "
192 "allocation scheme\n");
193 btrfs_set_opt(info
->mount_opt
, SSD
);
194 btrfs_set_opt(info
->mount_opt
, SSD_SPREAD
);
197 printk(KERN_INFO
"btrfs: not using ssd allocation "
199 btrfs_set_opt(info
->mount_opt
, NOSSD
);
200 btrfs_clear_opt(info
->mount_opt
, SSD
);
201 btrfs_clear_opt(info
->mount_opt
, SSD_SPREAD
);
204 printk(KERN_INFO
"btrfs: turning off barriers\n");
205 btrfs_set_opt(info
->mount_opt
, NOBARRIER
);
207 case Opt_thread_pool
:
209 match_int(&args
[0], &intarg
);
211 info
->thread_pool_size
= intarg
;
212 printk(KERN_INFO
"btrfs: thread pool %d\n",
213 info
->thread_pool_size
);
217 num
= match_strdup(&args
[0]);
219 info
->max_extent
= btrfs_parse_size(num
);
222 info
->max_extent
= max_t(u64
,
223 info
->max_extent
, root
->sectorsize
);
224 printk(KERN_INFO
"btrfs: max_extent at %llu\n",
225 (unsigned long long)info
->max_extent
);
229 num
= match_strdup(&args
[0]);
231 info
->max_inline
= btrfs_parse_size(num
);
234 if (info
->max_inline
) {
235 info
->max_inline
= max_t(u64
,
239 printk(KERN_INFO
"btrfs: max_inline at %llu\n",
240 (unsigned long long)info
->max_inline
);
243 case Opt_alloc_start
:
244 num
= match_strdup(&args
[0]);
246 info
->alloc_start
= btrfs_parse_size(num
);
249 "btrfs: allocations start at %llu\n",
250 (unsigned long long)info
->alloc_start
);
254 root
->fs_info
->sb
->s_flags
&= ~MS_POSIXACL
;
257 printk(KERN_INFO
"btrfs: disabling tree log\n");
258 btrfs_set_opt(info
->mount_opt
, NOTREELOG
);
260 case Opt_flushoncommit
:
261 printk(KERN_INFO
"btrfs: turning on flush-on-commit\n");
262 btrfs_set_opt(info
->mount_opt
, FLUSHONCOMMIT
);
266 match_int(&args
[0], &intarg
);
268 info
->metadata_ratio
= intarg
;
269 printk(KERN_INFO
"btrfs: metadata ratio %d\n",
270 info
->metadata_ratio
);
274 btrfs_set_opt(info
->mount_opt
, DISCARD
);
277 printk(KERN_INFO
"btrfs: unrecognized mount option "
291 * Parse mount options that are required early in the mount process.
293 * All other options will be parsed on much later in the mount process and
294 * only when we need to allocate a new super block.
296 static int btrfs_parse_early_options(const char *options
, fmode_t flags
,
297 void *holder
, char **subvol_name
, u64
*subvol_objectid
,
298 struct btrfs_fs_devices
**fs_devices
)
300 substring_t args
[MAX_OPT_ARGS
];
309 * strsep changes the string, duplicate it because parse_options
312 opts
= kstrdup(options
, GFP_KERNEL
);
316 while ((p
= strsep(&opts
, ",")) != NULL
) {
321 token
= match_token(p
, tokens
, args
);
324 *subvol_name
= match_strdup(&args
[0]);
328 match_int(&args
[0], &intarg
);
330 *subvol_objectid
= intarg
;
333 error
= btrfs_scan_one_device(match_strdup(&args
[0]),
334 flags
, holder
, fs_devices
);
347 * If no subvolume name is specified we use the default one. Allocate
348 * a copy of the string "." here so that code later in the
349 * mount path doesn't care if it's the default volume or another one.
352 *subvol_name
= kstrdup(".", GFP_KERNEL
);
359 static struct dentry
*get_default_root(struct super_block
*sb
,
362 struct btrfs_root
*root
= sb
->s_fs_info
;
363 struct btrfs_root
*new_root
;
364 struct btrfs_dir_item
*di
;
365 struct btrfs_path
*path
;
366 struct btrfs_key location
;
368 struct dentry
*dentry
;
373 * We have a specific subvol we want to mount, just setup location and
374 * go look up the root.
376 if (subvol_objectid
) {
377 location
.objectid
= subvol_objectid
;
378 location
.type
= BTRFS_ROOT_ITEM_KEY
;
379 location
.offset
= (u64
)-1;
383 path
= btrfs_alloc_path();
385 return ERR_PTR(-ENOMEM
);
386 path
->leave_spinning
= 1;
389 * Find the "default" dir item which points to the root item that we
390 * will mount by default if we haven't been given a specific subvolume
393 dir_id
= btrfs_super_root_dir(&root
->fs_info
->super_copy
);
394 di
= btrfs_lookup_dir_item(NULL
, root
, path
, dir_id
, "default", 7, 0);
397 * Ok the default dir item isn't there. This is weird since
398 * it's always been there, but don't freak out, just try and
399 * mount to root most subvolume.
401 btrfs_free_path(path
);
402 dir_id
= BTRFS_FIRST_FREE_OBJECTID
;
403 new_root
= root
->fs_info
->fs_root
;
407 btrfs_dir_item_key_to_cpu(path
->nodes
[0], di
, &location
);
408 btrfs_free_path(path
);
411 new_root
= btrfs_read_fs_root_no_name(root
->fs_info
, &location
);
412 if (IS_ERR(new_root
))
413 return ERR_PTR(PTR_ERR(new_root
));
415 if (btrfs_root_refs(&new_root
->root_item
) == 0)
416 return ERR_PTR(-ENOENT
);
418 dir_id
= btrfs_root_dirid(&new_root
->root_item
);
420 location
.objectid
= dir_id
;
421 location
.type
= BTRFS_INODE_ITEM_KEY
;
424 inode
= btrfs_iget(sb
, &location
, new_root
, &new);
426 return ERR_PTR(-ENOMEM
);
429 * If we're just mounting the root most subvol put the inode and return
430 * a reference to the dentry. We will have already gotten a reference
431 * to the inode in btrfs_fill_super so we're good to go.
433 if (!new && sb
->s_root
->d_inode
== inode
) {
435 return dget(sb
->s_root
);
439 const struct qstr name
= { .name
= "/", .len
= 1 };
442 * New inode, we need to make the dentry a sibling of s_root so
443 * everything gets cleaned up properly on unmount.
445 dentry
= d_alloc(sb
->s_root
, &name
);
448 return ERR_PTR(-ENOMEM
);
450 d_splice_alias(inode
, dentry
);
453 * We found the inode in cache, just find a dentry for it and
454 * put the reference to the inode we just got.
456 dentry
= d_find_alias(inode
);
463 static int btrfs_fill_super(struct super_block
*sb
,
464 struct btrfs_fs_devices
*fs_devices
,
465 void *data
, int silent
)
468 struct dentry
*root_dentry
;
469 struct btrfs_super_block
*disk_super
;
470 struct btrfs_root
*tree_root
;
471 struct btrfs_key key
;
474 sb
->s_maxbytes
= MAX_LFS_FILESIZE
;
475 sb
->s_magic
= BTRFS_SUPER_MAGIC
;
476 sb
->s_op
= &btrfs_super_ops
;
477 sb
->s_export_op
= &btrfs_export_ops
;
478 sb
->s_xattr
= btrfs_xattr_handlers
;
480 #ifdef CONFIG_BTRFS_FS_POSIX_ACL
481 sb
->s_flags
|= MS_POSIXACL
;
484 tree_root
= open_ctree(sb
, fs_devices
, (char *)data
);
486 if (IS_ERR(tree_root
)) {
487 printk("btrfs: open_ctree failed\n");
488 return PTR_ERR(tree_root
);
490 sb
->s_fs_info
= tree_root
;
491 disk_super
= &tree_root
->fs_info
->super_copy
;
493 key
.objectid
= BTRFS_FIRST_FREE_OBJECTID
;
494 key
.type
= BTRFS_INODE_ITEM_KEY
;
496 inode
= btrfs_iget(sb
, &key
, tree_root
->fs_info
->fs_root
, NULL
);
498 err
= PTR_ERR(inode
);
502 root_dentry
= d_alloc_root(inode
);
509 sb
->s_root
= root_dentry
;
511 save_mount_options(sb
, data
);
515 close_ctree(tree_root
);
519 int btrfs_sync_fs(struct super_block
*sb
, int wait
)
521 struct btrfs_trans_handle
*trans
;
522 struct btrfs_root
*root
= btrfs_sb(sb
);
526 filemap_flush(root
->fs_info
->btree_inode
->i_mapping
);
530 btrfs_start_delalloc_inodes(root
, 0);
531 btrfs_wait_ordered_extents(root
, 0, 0);
533 trans
= btrfs_start_transaction(root
, 1);
534 ret
= btrfs_commit_transaction(trans
, root
);
538 static int btrfs_show_options(struct seq_file
*seq
, struct vfsmount
*vfs
)
540 struct btrfs_root
*root
= btrfs_sb(vfs
->mnt_sb
);
541 struct btrfs_fs_info
*info
= root
->fs_info
;
543 if (btrfs_test_opt(root
, DEGRADED
))
544 seq_puts(seq
, ",degraded");
545 if (btrfs_test_opt(root
, NODATASUM
))
546 seq_puts(seq
, ",nodatasum");
547 if (btrfs_test_opt(root
, NODATACOW
))
548 seq_puts(seq
, ",nodatacow");
549 if (btrfs_test_opt(root
, NOBARRIER
))
550 seq_puts(seq
, ",nobarrier");
551 if (info
->max_extent
!= (u64
)-1)
552 seq_printf(seq
, ",max_extent=%llu",
553 (unsigned long long)info
->max_extent
);
554 if (info
->max_inline
!= 8192 * 1024)
555 seq_printf(seq
, ",max_inline=%llu",
556 (unsigned long long)info
->max_inline
);
557 if (info
->alloc_start
!= 0)
558 seq_printf(seq
, ",alloc_start=%llu",
559 (unsigned long long)info
->alloc_start
);
560 if (info
->thread_pool_size
!= min_t(unsigned long,
561 num_online_cpus() + 2, 8))
562 seq_printf(seq
, ",thread_pool=%d", info
->thread_pool_size
);
563 if (btrfs_test_opt(root
, COMPRESS
))
564 seq_puts(seq
, ",compress");
565 if (btrfs_test_opt(root
, NOSSD
))
566 seq_puts(seq
, ",nossd");
567 if (btrfs_test_opt(root
, SSD_SPREAD
))
568 seq_puts(seq
, ",ssd_spread");
569 else if (btrfs_test_opt(root
, SSD
))
570 seq_puts(seq
, ",ssd");
571 if (btrfs_test_opt(root
, NOTREELOG
))
572 seq_puts(seq
, ",notreelog");
573 if (btrfs_test_opt(root
, FLUSHONCOMMIT
))
574 seq_puts(seq
, ",flushoncommit");
575 if (btrfs_test_opt(root
, DISCARD
))
576 seq_puts(seq
, ",discard");
577 if (!(root
->fs_info
->sb
->s_flags
& MS_POSIXACL
))
578 seq_puts(seq
, ",noacl");
582 static int btrfs_test_super(struct super_block
*s
, void *data
)
584 struct btrfs_fs_devices
*test_fs_devices
= data
;
585 struct btrfs_root
*root
= btrfs_sb(s
);
587 return root
->fs_info
->fs_devices
== test_fs_devices
;
591 * Find a superblock for the given device / mount point.
593 * Note: This is based on get_sb_bdev from fs/super.c with a few additions
594 * for multiple device setup. Make sure to keep it in sync.
596 static int btrfs_get_sb(struct file_system_type
*fs_type
, int flags
,
597 const char *dev_name
, void *data
, struct vfsmount
*mnt
)
599 struct block_device
*bdev
= NULL
;
600 struct super_block
*s
;
602 struct btrfs_fs_devices
*fs_devices
= NULL
;
603 fmode_t mode
= FMODE_READ
;
604 char *subvol_name
= NULL
;
605 u64 subvol_objectid
= 0;
609 if (!(flags
& MS_RDONLY
))
612 error
= btrfs_parse_early_options(data
, mode
, fs_type
,
613 &subvol_name
, &subvol_objectid
,
618 error
= btrfs_scan_one_device(dev_name
, mode
, fs_type
, &fs_devices
);
620 goto error_free_subvol_name
;
622 error
= btrfs_open_devices(fs_devices
, mode
, fs_type
);
624 goto error_free_subvol_name
;
626 if (!(flags
& MS_RDONLY
) && fs_devices
->rw_devices
== 0) {
628 goto error_close_devices
;
631 bdev
= fs_devices
->latest_bdev
;
632 s
= sget(fs_type
, btrfs_test_super
, set_anon_super
, fs_devices
);
637 if ((flags
^ s
->s_flags
) & MS_RDONLY
) {
638 deactivate_locked_super(s
);
640 goto error_close_devices
;
644 btrfs_close_devices(fs_devices
);
646 char b
[BDEVNAME_SIZE
];
649 strlcpy(s
->s_id
, bdevname(bdev
, b
), sizeof(s
->s_id
));
650 error
= btrfs_fill_super(s
, fs_devices
, data
,
651 flags
& MS_SILENT
? 1 : 0);
653 deactivate_locked_super(s
);
654 goto error_free_subvol_name
;
657 btrfs_sb(s
)->fs_info
->bdev_holder
= fs_type
;
658 s
->s_flags
|= MS_ACTIVE
;
661 root
= get_default_root(s
, subvol_objectid
);
663 error
= PTR_ERR(root
);
664 deactivate_locked_super(s
);
667 /* if they gave us a subvolume name bind mount into that */
668 if (strcmp(subvol_name
, ".")) {
669 struct dentry
*new_root
;
670 mutex_lock(&root
->d_inode
->i_mutex
);
671 new_root
= lookup_one_len(subvol_name
, root
,
672 strlen(subvol_name
));
673 mutex_unlock(&root
->d_inode
->i_mutex
);
675 if (IS_ERR(new_root
)) {
676 deactivate_locked_super(s
);
677 error
= PTR_ERR(new_root
);
679 goto error_close_devices
;
681 if (!new_root
->d_inode
) {
684 deactivate_locked_super(s
);
686 goto error_close_devices
;
693 mnt
->mnt_root
= root
;
701 btrfs_close_devices(fs_devices
);
702 error_free_subvol_name
:
708 static int btrfs_remount(struct super_block
*sb
, int *flags
, char *data
)
710 struct btrfs_root
*root
= btrfs_sb(sb
);
713 ret
= btrfs_parse_options(root
, data
);
717 if ((*flags
& MS_RDONLY
) == (sb
->s_flags
& MS_RDONLY
))
720 if (*flags
& MS_RDONLY
) {
721 sb
->s_flags
|= MS_RDONLY
;
723 ret
= btrfs_commit_super(root
);
726 if (root
->fs_info
->fs_devices
->rw_devices
== 0)
729 if (btrfs_super_log_root(&root
->fs_info
->super_copy
) != 0)
732 /* recover relocation */
733 ret
= btrfs_recover_relocation(root
);
736 ret
= btrfs_cleanup_fs_roots(root
->fs_info
);
739 sb
->s_flags
&= ~MS_RDONLY
;
745 static int btrfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
747 struct btrfs_root
*root
= btrfs_sb(dentry
->d_sb
);
748 struct btrfs_super_block
*disk_super
= &root
->fs_info
->super_copy
;
749 int bits
= dentry
->d_sb
->s_blocksize_bits
;
750 __be32
*fsid
= (__be32
*)root
->fs_info
->fsid
;
752 buf
->f_namelen
= BTRFS_NAME_LEN
;
753 buf
->f_blocks
= btrfs_super_total_bytes(disk_super
) >> bits
;
754 buf
->f_bfree
= buf
->f_blocks
-
755 (btrfs_super_bytes_used(disk_super
) >> bits
);
756 buf
->f_bavail
= buf
->f_bfree
;
757 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
758 buf
->f_type
= BTRFS_SUPER_MAGIC
;
760 /* We treat it as constant endianness (it doesn't matter _which_)
761 because we want the fsid to come out the same whether mounted
762 on a big-endian or little-endian host */
763 buf
->f_fsid
.val
[0] = be32_to_cpu(fsid
[0]) ^ be32_to_cpu(fsid
[2]);
764 buf
->f_fsid
.val
[1] = be32_to_cpu(fsid
[1]) ^ be32_to_cpu(fsid
[3]);
765 /* Mask in the root object ID too, to disambiguate subvols */
766 buf
->f_fsid
.val
[0] ^= BTRFS_I(dentry
->d_inode
)->root
->objectid
>> 32;
767 buf
->f_fsid
.val
[1] ^= BTRFS_I(dentry
->d_inode
)->root
->objectid
;
772 static struct file_system_type btrfs_fs_type
= {
773 .owner
= THIS_MODULE
,
775 .get_sb
= btrfs_get_sb
,
776 .kill_sb
= kill_anon_super
,
777 .fs_flags
= FS_REQUIRES_DEV
,
781 * used by btrfsctl to scan devices when no FS is mounted
783 static long btrfs_control_ioctl(struct file
*file
, unsigned int cmd
,
786 struct btrfs_ioctl_vol_args
*vol
;
787 struct btrfs_fs_devices
*fs_devices
;
790 if (!capable(CAP_SYS_ADMIN
))
793 vol
= memdup_user((void __user
*)arg
, sizeof(*vol
));
798 case BTRFS_IOC_SCAN_DEV
:
799 ret
= btrfs_scan_one_device(vol
->name
, FMODE_READ
,
800 &btrfs_fs_type
, &fs_devices
);
808 static int btrfs_freeze(struct super_block
*sb
)
810 struct btrfs_root
*root
= btrfs_sb(sb
);
811 mutex_lock(&root
->fs_info
->transaction_kthread_mutex
);
812 mutex_lock(&root
->fs_info
->cleaner_mutex
);
816 static int btrfs_unfreeze(struct super_block
*sb
)
818 struct btrfs_root
*root
= btrfs_sb(sb
);
819 mutex_unlock(&root
->fs_info
->cleaner_mutex
);
820 mutex_unlock(&root
->fs_info
->transaction_kthread_mutex
);
824 static const struct super_operations btrfs_super_ops
= {
825 .drop_inode
= btrfs_drop_inode
,
826 .delete_inode
= btrfs_delete_inode
,
827 .put_super
= btrfs_put_super
,
828 .sync_fs
= btrfs_sync_fs
,
829 .show_options
= btrfs_show_options
,
830 .write_inode
= btrfs_write_inode
,
831 .dirty_inode
= btrfs_dirty_inode
,
832 .alloc_inode
= btrfs_alloc_inode
,
833 .destroy_inode
= btrfs_destroy_inode
,
834 .statfs
= btrfs_statfs
,
835 .remount_fs
= btrfs_remount
,
836 .freeze_fs
= btrfs_freeze
,
837 .unfreeze_fs
= btrfs_unfreeze
,
840 static const struct file_operations btrfs_ctl_fops
= {
841 .unlocked_ioctl
= btrfs_control_ioctl
,
842 .compat_ioctl
= btrfs_control_ioctl
,
843 .owner
= THIS_MODULE
,
846 static struct miscdevice btrfs_misc
= {
847 .minor
= MISC_DYNAMIC_MINOR
,
848 .name
= "btrfs-control",
849 .fops
= &btrfs_ctl_fops
852 static int btrfs_interface_init(void)
854 return misc_register(&btrfs_misc
);
857 static void btrfs_interface_exit(void)
859 if (misc_deregister(&btrfs_misc
) < 0)
860 printk(KERN_INFO
"misc_deregister failed for control device");
863 static int __init
init_btrfs_fs(void)
867 err
= btrfs_init_sysfs();
871 err
= btrfs_init_cachep();
875 err
= extent_io_init();
879 err
= extent_map_init();
883 err
= btrfs_interface_init();
885 goto free_extent_map
;
887 err
= register_filesystem(&btrfs_fs_type
);
889 goto unregister_ioctl
;
891 printk(KERN_INFO
"%s loaded\n", BTRFS_BUILD_VERSION
);
895 btrfs_interface_exit();
901 btrfs_destroy_cachep();
907 static void __exit
exit_btrfs_fs(void)
909 btrfs_destroy_cachep();
912 btrfs_interface_exit();
913 unregister_filesystem(&btrfs_fs_type
);
915 btrfs_cleanup_fs_uuids();
919 module_init(init_btrfs_fs
)
920 module_exit(exit_btrfs_fs
)
922 MODULE_LICENSE("GPL");