diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-27 16:57:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-27 16:57:12 -0400 |
commit | a0c3061093c8b49facef95dc09a618c6e0d17cb5 (patch) | |
tree | 1d6ff7c06134b71a8bd0721395386e82e46e60c8 /fs/btrfs/super.c | |
parent | 10799db60cbc4f990dd69eb49883477095c66af7 (diff) | |
parent | 174ba50915b08dcfd07c8b5fb795b46a165fa09a (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable: (58 commits)
Btrfs: use the device_list_mutex during write_dev_supers
Btrfs: setup free ino caching in a more asynchronous way
btrfs scrub: don't coalesce pages that are logically discontiguous
Btrfs: return -ENOMEM in clear_extent_bit
Btrfs: add mount -o auto_defrag
Btrfs: using rcu lock in the reader side of devices list
Btrfs: drop unnecessary device lock
Btrfs: fix the race between remove dev and alloc chunk
Btrfs: fix the race between reading and updating devices
Btrfs: fix bh leak on __btrfs_open_devices path
Btrfs: fix unsafe usage of merge_state
Btrfs: allocate extent state and check the result properly
fs/btrfs: Add missing btrfs_free_path
Btrfs: check return value of btrfs_inc_extent_ref()
Btrfs: return error to caller if read_one_inode() fails
Btrfs: BUG_ON is deleted from the caller of btrfs_truncate_item & btrfs_extend_item
Btrfs: return error code to caller when btrfs_del_item fails
Btrfs: return error code to caller when btrfs_previous_item fails
btrfs: fix typo 'testeing' -> 'testing'
btrfs: typo: 'btrfS' -> 'btrfs'
...
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index be4ffa12f3ef..9b2e7e5bc3ef 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <linux/cleancache.h> | 42 | #include <linux/cleancache.h> |
43 | #include "compat.h" | 43 | #include "compat.h" |
44 | #include "delayed-inode.h" | ||
44 | #include "ctree.h" | 45 | #include "ctree.h" |
45 | #include "disk-io.h" | 46 | #include "disk-io.h" |
46 | #include "transaction.h" | 47 | #include "transaction.h" |
@@ -160,7 +161,7 @@ enum { | |||
160 | Opt_compress_type, Opt_compress_force, Opt_compress_force_type, | 161 | Opt_compress_type, Opt_compress_force, Opt_compress_force_type, |
161 | Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard, | 162 | Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard, |
162 | Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed, | 163 | Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed, |
163 | Opt_enospc_debug, Opt_subvolrootid, Opt_err, | 164 | Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, Opt_err, |
164 | }; | 165 | }; |
165 | 166 | ||
166 | static match_table_t tokens = { | 167 | static match_table_t tokens = { |
@@ -191,6 +192,7 @@ static match_table_t tokens = { | |||
191 | {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"}, | 192 | {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"}, |
192 | {Opt_enospc_debug, "enospc_debug"}, | 193 | {Opt_enospc_debug, "enospc_debug"}, |
193 | {Opt_subvolrootid, "subvolrootid=%d"}, | 194 | {Opt_subvolrootid, "subvolrootid=%d"}, |
195 | {Opt_defrag, "autodefrag"}, | ||
194 | {Opt_err, NULL}, | 196 | {Opt_err, NULL}, |
195 | }; | 197 | }; |
196 | 198 | ||
@@ -369,6 +371,10 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
369 | case Opt_enospc_debug: | 371 | case Opt_enospc_debug: |
370 | btrfs_set_opt(info->mount_opt, ENOSPC_DEBUG); | 372 | btrfs_set_opt(info->mount_opt, ENOSPC_DEBUG); |
371 | break; | 373 | break; |
374 | case Opt_defrag: | ||
375 | printk(KERN_INFO "btrfs: enabling auto defrag"); | ||
376 | btrfs_set_opt(info->mount_opt, AUTO_DEFRAG); | ||
377 | break; | ||
372 | case Opt_err: | 378 | case Opt_err: |
373 | printk(KERN_INFO "btrfs: unrecognized mount option " | 379 | printk(KERN_INFO "btrfs: unrecognized mount option " |
374 | "'%s'\n", p); | 380 | "'%s'\n", p); |
@@ -507,8 +513,10 @@ static struct dentry *get_default_root(struct super_block *sb, | |||
507 | */ | 513 | */ |
508 | dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); | 514 | dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); |
509 | di = btrfs_lookup_dir_item(NULL, root, path, dir_id, "default", 7, 0); | 515 | di = btrfs_lookup_dir_item(NULL, root, path, dir_id, "default", 7, 0); |
510 | if (IS_ERR(di)) | 516 | if (IS_ERR(di)) { |
517 | btrfs_free_path(path); | ||
511 | return ERR_CAST(di); | 518 | return ERR_CAST(di); |
519 | } | ||
512 | if (!di) { | 520 | if (!di) { |
513 | /* | 521 | /* |
514 | * Ok the default dir item isn't there. This is weird since | 522 | * Ok the default dir item isn't there. This is weird since |
@@ -741,7 +749,7 @@ static int btrfs_set_super(struct super_block *s, void *data) | |||
741 | * for multiple device setup. Make sure to keep it in sync. | 749 | * for multiple device setup. Make sure to keep it in sync. |
742 | */ | 750 | */ |
743 | static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, | 751 | static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, |
744 | const char *dev_name, void *data) | 752 | const char *device_name, void *data) |
745 | { | 753 | { |
746 | struct block_device *bdev = NULL; | 754 | struct block_device *bdev = NULL; |
747 | struct super_block *s; | 755 | struct super_block *s; |
@@ -764,7 +772,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, | |||
764 | if (error) | 772 | if (error) |
765 | return ERR_PTR(error); | 773 | return ERR_PTR(error); |
766 | 774 | ||
767 | error = btrfs_scan_one_device(dev_name, mode, fs_type, &fs_devices); | 775 | error = btrfs_scan_one_device(device_name, mode, fs_type, &fs_devices); |
768 | if (error) | 776 | if (error) |
769 | goto error_free_subvol_name; | 777 | goto error_free_subvol_name; |
770 | 778 | ||
@@ -915,6 +923,32 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) | |||
915 | return 0; | 923 | return 0; |
916 | } | 924 | } |
917 | 925 | ||
926 | /* Used to sort the devices by max_avail(descending sort) */ | ||
927 | static int btrfs_cmp_device_free_bytes(const void *dev_info1, | ||
928 | const void *dev_info2) | ||
929 | { | ||
930 | if (((struct btrfs_device_info *)dev_info1)->max_avail > | ||
931 | ((struct btrfs_device_info *)dev_info2)->max_avail) | ||
932 | return -1; | ||
933 | else if (((struct btrfs_device_info *)dev_info1)->max_avail < | ||
934 | ((struct btrfs_device_info *)dev_info2)->max_avail) | ||
935 | return 1; | ||
936 | else | ||
937 | return 0; | ||
938 | } | ||
939 | |||
940 | /* | ||
941 | * sort the devices by max_avail, in which max free extent size of each device | ||
942 | * is stored.(Descending Sort) | ||
943 | */ | ||
944 | static inline void btrfs_descending_sort_devices( | ||
945 | struct btrfs_device_info *devices, | ||
946 | size_t nr_devices) | ||
947 | { | ||
948 | sort(devices, nr_devices, sizeof(struct btrfs_device_info), | ||
949 | btrfs_cmp_device_free_bytes, NULL); | ||
950 | } | ||
951 | |||
918 | /* | 952 | /* |
919 | * The helper to calc the free space on the devices that can be used to store | 953 | * The helper to calc the free space on the devices that can be used to store |
920 | * file data. | 954 | * file data. |
@@ -1208,10 +1242,14 @@ static int __init init_btrfs_fs(void) | |||
1208 | if (err) | 1242 | if (err) |
1209 | goto free_extent_io; | 1243 | goto free_extent_io; |
1210 | 1244 | ||
1211 | err = btrfs_interface_init(); | 1245 | err = btrfs_delayed_inode_init(); |
1212 | if (err) | 1246 | if (err) |
1213 | goto free_extent_map; | 1247 | goto free_extent_map; |
1214 | 1248 | ||
1249 | err = btrfs_interface_init(); | ||
1250 | if (err) | ||
1251 | goto free_delayed_inode; | ||
1252 | |||
1215 | err = register_filesystem(&btrfs_fs_type); | 1253 | err = register_filesystem(&btrfs_fs_type); |
1216 | if (err) | 1254 | if (err) |
1217 | goto unregister_ioctl; | 1255 | goto unregister_ioctl; |
@@ -1221,6 +1259,8 @@ static int __init init_btrfs_fs(void) | |||
1221 | 1259 | ||
1222 | unregister_ioctl: | 1260 | unregister_ioctl: |
1223 | btrfs_interface_exit(); | 1261 | btrfs_interface_exit(); |
1262 | free_delayed_inode: | ||
1263 | btrfs_delayed_inode_exit(); | ||
1224 | free_extent_map: | 1264 | free_extent_map: |
1225 | extent_map_exit(); | 1265 | extent_map_exit(); |
1226 | free_extent_io: | 1266 | free_extent_io: |
@@ -1237,6 +1277,7 @@ free_sysfs: | |||
1237 | static void __exit exit_btrfs_fs(void) | 1277 | static void __exit exit_btrfs_fs(void) |
1238 | { | 1278 | { |
1239 | btrfs_destroy_cachep(); | 1279 | btrfs_destroy_cachep(); |
1280 | btrfs_delayed_inode_exit(); | ||
1240 | extent_map_exit(); | 1281 | extent_map_exit(); |
1241 | extent_io_exit(); | 1282 | extent_io_exit(); |
1242 | btrfs_interface_exit(); | 1283 | btrfs_interface_exit(); |