super.c (79e24da00b1137031245f3341828e4215b1b5b59) | super.c (8ae1af3cd127d507dcb1acf67f16120f20632aed) |
---|---|
1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 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. 7 * 8 * This program is distributed in the hope that it will be useful, --- 289 unchanged lines hidden (view full) --- 298 Opt_space_cache, Opt_space_cache_version, Opt_clear_cache, 299 Opt_user_subvol_rm_allowed, Opt_enospc_debug, Opt_subvolrootid, 300 Opt_defrag, Opt_inode_cache, Opt_no_space_cache, Opt_recovery, 301 Opt_skip_balance, Opt_check_integrity, 302 Opt_check_integrity_including_extent_data, 303 Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree, 304 Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard, 305 Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow, | 1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 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. 7 * 8 * This program is distributed in the hope that it will be useful, --- 289 unchanged lines hidden (view full) --- 298 Opt_space_cache, Opt_space_cache_version, Opt_clear_cache, 299 Opt_user_subvol_rm_allowed, Opt_enospc_debug, Opt_subvolrootid, 300 Opt_defrag, Opt_inode_cache, Opt_no_space_cache, Opt_recovery, 301 Opt_skip_balance, Opt_check_integrity, 302 Opt_check_integrity_including_extent_data, 303 Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree, 304 Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard, 305 Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow, |
306 Opt_datasum, Opt_treelog, Opt_noinode_cache, | 306 Opt_datasum, Opt_treelog, Opt_noinode_cache, Opt_usebackuproot, 307 Opt_nologreplay, Opt_norecovery, |
307#ifdef CONFIG_BTRFS_DEBUG 308 Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all, 309#endif 310 Opt_err, 311}; 312 313static const match_table_t tokens = { 314 {Opt_degraded, "degraded"}, --- 15 unchanged lines hidden (view full) --- 330 {Opt_compress_force_type, "compress-force=%s"}, 331 {Opt_ssd, "ssd"}, 332 {Opt_ssd_spread, "ssd_spread"}, 333 {Opt_nossd, "nossd"}, 334 {Opt_acl, "acl"}, 335 {Opt_noacl, "noacl"}, 336 {Opt_notreelog, "notreelog"}, 337 {Opt_treelog, "treelog"}, | 308#ifdef CONFIG_BTRFS_DEBUG 309 Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all, 310#endif 311 Opt_err, 312}; 313 314static const match_table_t tokens = { 315 {Opt_degraded, "degraded"}, --- 15 unchanged lines hidden (view full) --- 331 {Opt_compress_force_type, "compress-force=%s"}, 332 {Opt_ssd, "ssd"}, 333 {Opt_ssd_spread, "ssd_spread"}, 334 {Opt_nossd, "nossd"}, 335 {Opt_acl, "acl"}, 336 {Opt_noacl, "noacl"}, 337 {Opt_notreelog, "notreelog"}, 338 {Opt_treelog, "treelog"}, |
339 {Opt_nologreplay, "nologreplay"}, 340 {Opt_norecovery, "norecovery"}, |
|
338 {Opt_flushoncommit, "flushoncommit"}, 339 {Opt_noflushoncommit, "noflushoncommit"}, 340 {Opt_ratio, "metadata_ratio=%d"}, 341 {Opt_discard, "discard"}, 342 {Opt_nodiscard, "nodiscard"}, 343 {Opt_space_cache, "space_cache"}, 344 {Opt_space_cache_version, "space_cache=%s"}, 345 {Opt_clear_cache, "clear_cache"}, 346 {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"}, 347 {Opt_enospc_debug, "enospc_debug"}, 348 {Opt_noenospc_debug, "noenospc_debug"}, 349 {Opt_subvolrootid, "subvolrootid=%d"}, 350 {Opt_defrag, "autodefrag"}, 351 {Opt_nodefrag, "noautodefrag"}, 352 {Opt_inode_cache, "inode_cache"}, 353 {Opt_noinode_cache, "noinode_cache"}, 354 {Opt_no_space_cache, "nospace_cache"}, | 341 {Opt_flushoncommit, "flushoncommit"}, 342 {Opt_noflushoncommit, "noflushoncommit"}, 343 {Opt_ratio, "metadata_ratio=%d"}, 344 {Opt_discard, "discard"}, 345 {Opt_nodiscard, "nodiscard"}, 346 {Opt_space_cache, "space_cache"}, 347 {Opt_space_cache_version, "space_cache=%s"}, 348 {Opt_clear_cache, "clear_cache"}, 349 {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"}, 350 {Opt_enospc_debug, "enospc_debug"}, 351 {Opt_noenospc_debug, "noenospc_debug"}, 352 {Opt_subvolrootid, "subvolrootid=%d"}, 353 {Opt_defrag, "autodefrag"}, 354 {Opt_nodefrag, "noautodefrag"}, 355 {Opt_inode_cache, "inode_cache"}, 356 {Opt_noinode_cache, "noinode_cache"}, 357 {Opt_no_space_cache, "nospace_cache"}, |
355 {Opt_recovery, "recovery"}, | 358 {Opt_recovery, "recovery"}, /* deprecated */ 359 {Opt_usebackuproot, "usebackuproot"}, |
356 {Opt_skip_balance, "skip_balance"}, 357 {Opt_check_integrity, "check_int"}, 358 {Opt_check_integrity_including_extent_data, "check_int_data"}, 359 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"}, 360 {Opt_rescan_uuid_tree, "rescan_uuid_tree"}, 361 {Opt_fatal_errors, "fatal_errors=%s"}, 362 {Opt_commit_interval, "commit=%d"}, 363#ifdef CONFIG_BTRFS_DEBUG --- 4 unchanged lines hidden (view full) --- 368 {Opt_err, NULL}, 369}; 370 371/* 372 * Regular mount options parser. Everything that is needed only when 373 * reading in a new superblock is parsed here. 374 * XXX JDM: This needs to be cleaned up for remount. 375 */ | 360 {Opt_skip_balance, "skip_balance"}, 361 {Opt_check_integrity, "check_int"}, 362 {Opt_check_integrity_including_extent_data, "check_int_data"}, 363 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"}, 364 {Opt_rescan_uuid_tree, "rescan_uuid_tree"}, 365 {Opt_fatal_errors, "fatal_errors=%s"}, 366 {Opt_commit_interval, "commit=%d"}, 367#ifdef CONFIG_BTRFS_DEBUG --- 4 unchanged lines hidden (view full) --- 372 {Opt_err, NULL}, 373}; 374 375/* 376 * Regular mount options parser. Everything that is needed only when 377 * reading in a new superblock is parsed here. 378 * XXX JDM: This needs to be cleaned up for remount. 379 */ |
376int btrfs_parse_options(struct btrfs_root *root, char *options) | 380int btrfs_parse_options(struct btrfs_root *root, char *options, 381 unsigned long new_flags) |
377{ 378 struct btrfs_fs_info *info = root->fs_info; 379 substring_t args[MAX_OPT_ARGS]; 380 char *p, *num, *orig = NULL; 381 u64 cache_gen; 382 int intarg; 383 int ret = 0; 384 char *compress_type; 385 bool compress_force = false; 386 enum btrfs_compression_type saved_compress_type; 387 bool saved_compress_force; 388 int no_compress = 0; 389 390 cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); 391 if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE)) 392 btrfs_set_opt(info->mount_opt, FREE_SPACE_TREE); 393 else if (cache_gen) 394 btrfs_set_opt(info->mount_opt, SPACE_CACHE); 395 | 382{ 383 struct btrfs_fs_info *info = root->fs_info; 384 substring_t args[MAX_OPT_ARGS]; 385 char *p, *num, *orig = NULL; 386 u64 cache_gen; 387 int intarg; 388 int ret = 0; 389 char *compress_type; 390 bool compress_force = false; 391 enum btrfs_compression_type saved_compress_type; 392 bool saved_compress_force; 393 int no_compress = 0; 394 395 cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); 396 if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE)) 397 btrfs_set_opt(info->mount_opt, FREE_SPACE_TREE); 398 else if (cache_gen) 399 btrfs_set_opt(info->mount_opt, SPACE_CACHE); 400 |
401 /* 402 * Even the options are empty, we still need to do extra check 403 * against new flags 404 */ |
|
396 if (!options) | 405 if (!options) |
397 goto out; | 406 goto check; |
398 399 /* 400 * strsep changes the string, duplicate it because parse_options 401 * gets called twice 402 */ 403 options = kstrdup(options, GFP_NOFS); 404 if (!options) 405 return -ENOMEM; --- 195 unchanged lines hidden (view full) --- 601 case Opt_notreelog: 602 btrfs_set_and_info(root, NOTREELOG, 603 "disabling tree log"); 604 break; 605 case Opt_treelog: 606 btrfs_clear_and_info(root, NOTREELOG, 607 "enabling tree log"); 608 break; | 407 408 /* 409 * strsep changes the string, duplicate it because parse_options 410 * gets called twice 411 */ 412 options = kstrdup(options, GFP_NOFS); 413 if (!options) 414 return -ENOMEM; --- 195 unchanged lines hidden (view full) --- 610 case Opt_notreelog: 611 btrfs_set_and_info(root, NOTREELOG, 612 "disabling tree log"); 613 break; 614 case Opt_treelog: 615 btrfs_clear_and_info(root, NOTREELOG, 616 "enabling tree log"); 617 break; |
618 case Opt_norecovery: 619 case Opt_nologreplay: 620 btrfs_set_and_info(root, NOLOGREPLAY, 621 "disabling log replay at mount time"); 622 break; |
|
609 case Opt_flushoncommit: 610 btrfs_set_and_info(root, FLUSHONCOMMIT, 611 "turning on flush-on-commit"); 612 break; 613 case Opt_noflushoncommit: 614 btrfs_clear_and_info(root, FLUSHONCOMMIT, 615 "turning off flush-on-commit"); 616 break; --- 74 unchanged lines hidden (view full) --- 691 btrfs_set_and_info(root, AUTO_DEFRAG, 692 "enabling auto defrag"); 693 break; 694 case Opt_nodefrag: 695 btrfs_clear_and_info(root, AUTO_DEFRAG, 696 "disabling auto defrag"); 697 break; 698 case Opt_recovery: | 623 case Opt_flushoncommit: 624 btrfs_set_and_info(root, FLUSHONCOMMIT, 625 "turning on flush-on-commit"); 626 break; 627 case Opt_noflushoncommit: 628 btrfs_clear_and_info(root, FLUSHONCOMMIT, 629 "turning off flush-on-commit"); 630 break; --- 74 unchanged lines hidden (view full) --- 705 btrfs_set_and_info(root, AUTO_DEFRAG, 706 "enabling auto defrag"); 707 break; 708 case Opt_nodefrag: 709 btrfs_clear_and_info(root, AUTO_DEFRAG, 710 "disabling auto defrag"); 711 break; 712 case Opt_recovery: |
699 btrfs_info(root->fs_info, "enabling auto recovery"); 700 btrfs_set_opt(info->mount_opt, RECOVERY); | 713 btrfs_warn(root->fs_info, 714 "'recovery' is deprecated, use 'usebackuproot' instead"); 715 case Opt_usebackuproot: 716 btrfs_info(root->fs_info, 717 "trying to use backup root at mount time"); 718 btrfs_set_opt(info->mount_opt, USEBACKUPROOT); |
701 break; 702 case Opt_skip_balance: 703 btrfs_set_opt(info->mount_opt, SKIP_BALANCE); 704 break; 705#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 706 case Opt_check_integrity_including_extent_data: 707 btrfs_info(root->fs_info, 708 "enabling check integrity including extent data"); --- 78 unchanged lines hidden (view full) --- 787 case Opt_err: 788 btrfs_info(root->fs_info, "unrecognized mount option '%s'", p); 789 ret = -EINVAL; 790 goto out; 791 default: 792 break; 793 } 794 } | 719 break; 720 case Opt_skip_balance: 721 btrfs_set_opt(info->mount_opt, SKIP_BALANCE); 722 break; 723#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 724 case Opt_check_integrity_including_extent_data: 725 btrfs_info(root->fs_info, 726 "enabling check integrity including extent data"); --- 78 unchanged lines hidden (view full) --- 805 case Opt_err: 806 btrfs_info(root->fs_info, "unrecognized mount option '%s'", p); 807 ret = -EINVAL; 808 goto out; 809 default: 810 break; 811 } 812 } |
813check: 814 /* 815 * Extra check for current option against current flag 816 */ 817 if (btrfs_test_opt(root, NOLOGREPLAY) && !(new_flags & MS_RDONLY)) { 818 btrfs_err(root->fs_info, 819 "nologreplay must be used with ro mount option"); 820 ret = -EINVAL; 821 } |
|
795out: 796 if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE) && 797 !btrfs_test_opt(root, FREE_SPACE_TREE) && 798 !btrfs_test_opt(root, CLEAR_CACHE)) { 799 btrfs_err(root->fs_info, "cannot disable free space tree"); 800 ret = -EINVAL; 801 802 } --- 394 unchanged lines hidden (view full) --- 1197 if (btrfs_test_opt(root, NOSSD)) 1198 seq_puts(seq, ",nossd"); 1199 if (btrfs_test_opt(root, SSD_SPREAD)) 1200 seq_puts(seq, ",ssd_spread"); 1201 else if (btrfs_test_opt(root, SSD)) 1202 seq_puts(seq, ",ssd"); 1203 if (btrfs_test_opt(root, NOTREELOG)) 1204 seq_puts(seq, ",notreelog"); | 822out: 823 if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE) && 824 !btrfs_test_opt(root, FREE_SPACE_TREE) && 825 !btrfs_test_opt(root, CLEAR_CACHE)) { 826 btrfs_err(root->fs_info, "cannot disable free space tree"); 827 ret = -EINVAL; 828 829 } --- 394 unchanged lines hidden (view full) --- 1224 if (btrfs_test_opt(root, NOSSD)) 1225 seq_puts(seq, ",nossd"); 1226 if (btrfs_test_opt(root, SSD_SPREAD)) 1227 seq_puts(seq, ",ssd_spread"); 1228 else if (btrfs_test_opt(root, SSD)) 1229 seq_puts(seq, ",ssd"); 1230 if (btrfs_test_opt(root, NOTREELOG)) 1231 seq_puts(seq, ",notreelog"); |
1232 if (btrfs_test_opt(root, NOLOGREPLAY)) 1233 seq_puts(seq, ",nologreplay"); |
|
1205 if (btrfs_test_opt(root, FLUSHONCOMMIT)) 1206 seq_puts(seq, ",flushoncommit"); 1207 if (btrfs_test_opt(root, DISCARD)) 1208 seq_puts(seq, ",discard"); 1209 if (!(root->fs_info->sb->s_flags & MS_POSIXACL)) 1210 seq_puts(seq, ",noacl"); 1211 if (btrfs_test_opt(root, SPACE_CACHE)) 1212 seq_puts(seq, ",space_cache"); --- 10 unchanged lines hidden (view full) --- 1223 if (btrfs_test_opt(root, ENOSPC_DEBUG)) 1224 seq_puts(seq, ",enospc_debug"); 1225 if (btrfs_test_opt(root, AUTO_DEFRAG)) 1226 seq_puts(seq, ",autodefrag"); 1227 if (btrfs_test_opt(root, INODE_MAP_CACHE)) 1228 seq_puts(seq, ",inode_cache"); 1229 if (btrfs_test_opt(root, SKIP_BALANCE)) 1230 seq_puts(seq, ",skip_balance"); | 1234 if (btrfs_test_opt(root, FLUSHONCOMMIT)) 1235 seq_puts(seq, ",flushoncommit"); 1236 if (btrfs_test_opt(root, DISCARD)) 1237 seq_puts(seq, ",discard"); 1238 if (!(root->fs_info->sb->s_flags & MS_POSIXACL)) 1239 seq_puts(seq, ",noacl"); 1240 if (btrfs_test_opt(root, SPACE_CACHE)) 1241 seq_puts(seq, ",space_cache"); --- 10 unchanged lines hidden (view full) --- 1252 if (btrfs_test_opt(root, ENOSPC_DEBUG)) 1253 seq_puts(seq, ",enospc_debug"); 1254 if (btrfs_test_opt(root, AUTO_DEFRAG)) 1255 seq_puts(seq, ",autodefrag"); 1256 if (btrfs_test_opt(root, INODE_MAP_CACHE)) 1257 seq_puts(seq, ",inode_cache"); 1258 if (btrfs_test_opt(root, SKIP_BALANCE)) 1259 seq_puts(seq, ",skip_balance"); |
1231 if (btrfs_test_opt(root, RECOVERY)) 1232 seq_puts(seq, ",recovery"); | |
1233#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 1234 if (btrfs_test_opt(root, CHECK_INTEGRITY_INCLUDING_EXTENT_DATA)) 1235 seq_puts(seq, ",check_int_data"); 1236 else if (btrfs_test_opt(root, CHECK_INTEGRITY)) 1237 seq_puts(seq, ",check_int"); 1238 if (info->check_integrity_print_mask) 1239 seq_printf(seq, ",check_int_print_mask=%d", 1240 info->check_integrity_print_mask); --- 439 unchanged lines hidden (view full) --- 1680 ret = setup_security_options(fs_info, sb, 1681 &new_sec_opts); 1682 if (ret) { 1683 security_free_mnt_opts(&new_sec_opts); 1684 goto restore; 1685 } 1686 } 1687 | 1260#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 1261 if (btrfs_test_opt(root, CHECK_INTEGRITY_INCLUDING_EXTENT_DATA)) 1262 seq_puts(seq, ",check_int_data"); 1263 else if (btrfs_test_opt(root, CHECK_INTEGRITY)) 1264 seq_puts(seq, ",check_int"); 1265 if (info->check_integrity_print_mask) 1266 seq_printf(seq, ",check_int_print_mask=%d", 1267 info->check_integrity_print_mask); --- 439 unchanged lines hidden (view full) --- 1707 ret = setup_security_options(fs_info, sb, 1708 &new_sec_opts); 1709 if (ret) { 1710 security_free_mnt_opts(&new_sec_opts); 1711 goto restore; 1712 } 1713 } 1714 |
1688 ret = btrfs_parse_options(root, data); | 1715 ret = btrfs_parse_options(root, data, *flags); |
1689 if (ret) { 1690 ret = -EINVAL; 1691 goto restore; 1692 } 1693 1694 btrfs_remount_begin(fs_info, old_opts, *flags); 1695 btrfs_resize_thread_pool(fs_info, 1696 fs_info->thread_pool_size, old_thread_pool_size); --- 461 unchanged lines hidden (view full) --- 2158 break; 2159 case BTRFS_IOC_DEVICES_READY: 2160 ret = btrfs_scan_one_device(vol->name, FMODE_READ, 2161 &btrfs_fs_type, &fs_devices); 2162 if (ret) 2163 break; 2164 ret = !(fs_devices->num_devices == fs_devices->total_devices); 2165 break; | 1716 if (ret) { 1717 ret = -EINVAL; 1718 goto restore; 1719 } 1720 1721 btrfs_remount_begin(fs_info, old_opts, *flags); 1722 btrfs_resize_thread_pool(fs_info, 1723 fs_info->thread_pool_size, old_thread_pool_size); --- 461 unchanged lines hidden (view full) --- 2185 break; 2186 case BTRFS_IOC_DEVICES_READY: 2187 ret = btrfs_scan_one_device(vol->name, FMODE_READ, 2188 &btrfs_fs_type, &fs_devices); 2189 if (ret) 2190 break; 2191 ret = !(fs_devices->num_devices == fs_devices->total_devices); 2192 break; |
2193 case BTRFS_IOC_GET_SUPPORTED_FEATURES: 2194 ret = btrfs_ioctl_get_supported_features((void __user*)arg); 2195 break; |
|
2166 } 2167 2168 kfree(vol); 2169 return ret; 2170} 2171 2172static int btrfs_freeze(struct super_block *sb) 2173{ --- 82 unchanged lines hidden (view full) --- 2256 return misc_register(&btrfs_misc); 2257} 2258 2259static void btrfs_interface_exit(void) 2260{ 2261 misc_deregister(&btrfs_misc); 2262} 2263 | 2196 } 2197 2198 kfree(vol); 2199 return ret; 2200} 2201 2202static int btrfs_freeze(struct super_block *sb) 2203{ --- 82 unchanged lines hidden (view full) --- 2286 return misc_register(&btrfs_misc); 2287} 2288 2289static void btrfs_interface_exit(void) 2290{ 2291 misc_deregister(&btrfs_misc); 2292} 2293 |
2264static void btrfs_print_info(void) | 2294static void btrfs_print_mod_info(void) |
2265{ 2266 printk(KERN_INFO "Btrfs loaded" 2267#ifdef CONFIG_BTRFS_DEBUG 2268 ", debug=on" 2269#endif 2270#ifdef CONFIG_BTRFS_ASSERT 2271 ", assert=on" 2272#endif --- 85 unchanged lines hidden (view full) --- 2358 goto free_prelim_ref; 2359 2360 err = btrfs_interface_init(); 2361 if (err) 2362 goto free_end_io_wq; 2363 2364 btrfs_init_lockdep(); 2365 | 2295{ 2296 printk(KERN_INFO "Btrfs loaded" 2297#ifdef CONFIG_BTRFS_DEBUG 2298 ", debug=on" 2299#endif 2300#ifdef CONFIG_BTRFS_ASSERT 2301 ", assert=on" 2302#endif --- 85 unchanged lines hidden (view full) --- 2388 goto free_prelim_ref; 2389 2390 err = btrfs_interface_init(); 2391 if (err) 2392 goto free_end_io_wq; 2393 2394 btrfs_init_lockdep(); 2395 |
2366 btrfs_print_info(); | 2396 btrfs_print_mod_info(); |
2367 2368 err = btrfs_run_sanity_tests(); 2369 if (err) 2370 goto unregister_ioctl; 2371 2372 err = register_filesystem(&btrfs_fs_type); 2373 if (err) 2374 goto unregister_ioctl; --- 54 unchanged lines hidden --- | 2397 2398 err = btrfs_run_sanity_tests(); 2399 if (err) 2400 goto unregister_ioctl; 2401 2402 err = register_filesystem(&btrfs_fs_type); 2403 if (err) 2404 goto unregister_ioctl; --- 54 unchanged lines hidden --- |