aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c254
1 files changed, 171 insertions, 83 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index d71a11d13dfa..d04db817be5c 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -48,6 +48,8 @@
48#include "transaction.h" 48#include "transaction.h"
49#include "btrfs_inode.h" 49#include "btrfs_inode.h"
50#include "print-tree.h" 50#include "print-tree.h"
51#include "hash.h"
52#include "props.h"
51#include "xattr.h" 53#include "xattr.h"
52#include "volumes.h" 54#include "volumes.h"
53#include "export.h" 55#include "export.h"
@@ -152,11 +154,12 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
152 vaf.fmt = fmt; 154 vaf.fmt = fmt;
153 vaf.va = &args; 155 vaf.va = &args;
154 156
155 printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: errno=%d %s (%pV)\n", 157 printk(KERN_CRIT
158 "BTRFS: error (device %s) in %s:%d: errno=%d %s (%pV)\n",
156 sb->s_id, function, line, errno, errstr, &vaf); 159 sb->s_id, function, line, errno, errstr, &vaf);
157 va_end(args); 160 va_end(args);
158 } else { 161 } else {
159 printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: errno=%d %s\n", 162 printk(KERN_CRIT "BTRFS: error (device %s) in %s:%d: errno=%d %s\n",
160 sb->s_id, function, line, errno, errstr); 163 sb->s_id, function, line, errno, errstr);
161 } 164 }
162 165
@@ -250,7 +253,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
250 */ 253 */
251 if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, 254 if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED,
252 &root->fs_info->fs_state)) { 255 &root->fs_info->fs_state)) {
253 WARN(1, KERN_DEBUG "btrfs: Transaction aborted (error %d)\n", 256 WARN(1, KERN_DEBUG "BTRFS: Transaction aborted (error %d)\n",
254 errno); 257 errno);
255 } 258 }
256 trans->aborted = errno; 259 trans->aborted = errno;
@@ -294,8 +297,8 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
294 panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n", 297 panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n",
295 s_id, function, line, &vaf, errno, errstr); 298 s_id, function, line, &vaf, errno, errstr);
296 299
297 printk(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n", 300 btrfs_crit(fs_info, "panic in %s:%d: %pV (errno=%d %s)",
298 s_id, function, line, &vaf, errno, errstr); 301 function, line, &vaf, errno, errstr);
299 va_end(args); 302 va_end(args);
300 /* Caller calls BUG() */ 303 /* Caller calls BUG() */
301} 304}
@@ -322,7 +325,9 @@ enum {
322 Opt_no_space_cache, Opt_recovery, Opt_skip_balance, 325 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
323 Opt_check_integrity, Opt_check_integrity_including_extent_data, 326 Opt_check_integrity, Opt_check_integrity_including_extent_data,
324 Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree, 327 Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree,
325 Opt_commit_interval, 328 Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard,
329 Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow,
330 Opt_datasum, Opt_treelog, Opt_noinode_cache,
326 Opt_err, 331 Opt_err,
327}; 332};
328 333
@@ -332,8 +337,11 @@ static match_table_t tokens = {
332 {Opt_subvolid, "subvolid=%s"}, 337 {Opt_subvolid, "subvolid=%s"},
333 {Opt_device, "device=%s"}, 338 {Opt_device, "device=%s"},
334 {Opt_nodatasum, "nodatasum"}, 339 {Opt_nodatasum, "nodatasum"},
340 {Opt_datasum, "datasum"},
335 {Opt_nodatacow, "nodatacow"}, 341 {Opt_nodatacow, "nodatacow"},
342 {Opt_datacow, "datacow"},
336 {Opt_nobarrier, "nobarrier"}, 343 {Opt_nobarrier, "nobarrier"},
344 {Opt_barrier, "barrier"},
337 {Opt_max_inline, "max_inline=%s"}, 345 {Opt_max_inline, "max_inline=%s"},
338 {Opt_alloc_start, "alloc_start=%s"}, 346 {Opt_alloc_start, "alloc_start=%s"},
339 {Opt_thread_pool, "thread_pool=%d"}, 347 {Opt_thread_pool, "thread_pool=%d"},
@@ -344,18 +352,25 @@ static match_table_t tokens = {
344 {Opt_ssd, "ssd"}, 352 {Opt_ssd, "ssd"},
345 {Opt_ssd_spread, "ssd_spread"}, 353 {Opt_ssd_spread, "ssd_spread"},
346 {Opt_nossd, "nossd"}, 354 {Opt_nossd, "nossd"},
355 {Opt_acl, "acl"},
347 {Opt_noacl, "noacl"}, 356 {Opt_noacl, "noacl"},
348 {Opt_notreelog, "notreelog"}, 357 {Opt_notreelog, "notreelog"},
358 {Opt_treelog, "treelog"},
349 {Opt_flushoncommit, "flushoncommit"}, 359 {Opt_flushoncommit, "flushoncommit"},
360 {Opt_noflushoncommit, "noflushoncommit"},
350 {Opt_ratio, "metadata_ratio=%d"}, 361 {Opt_ratio, "metadata_ratio=%d"},
351 {Opt_discard, "discard"}, 362 {Opt_discard, "discard"},
363 {Opt_nodiscard, "nodiscard"},
352 {Opt_space_cache, "space_cache"}, 364 {Opt_space_cache, "space_cache"},
353 {Opt_clear_cache, "clear_cache"}, 365 {Opt_clear_cache, "clear_cache"},
354 {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"}, 366 {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"},
355 {Opt_enospc_debug, "enospc_debug"}, 367 {Opt_enospc_debug, "enospc_debug"},
368 {Opt_noenospc_debug, "noenospc_debug"},
356 {Opt_subvolrootid, "subvolrootid=%d"}, 369 {Opt_subvolrootid, "subvolrootid=%d"},
357 {Opt_defrag, "autodefrag"}, 370 {Opt_defrag, "autodefrag"},
371 {Opt_nodefrag, "noautodefrag"},
358 {Opt_inode_cache, "inode_cache"}, 372 {Opt_inode_cache, "inode_cache"},
373 {Opt_noinode_cache, "noinode_cache"},
359 {Opt_no_space_cache, "nospace_cache"}, 374 {Opt_no_space_cache, "nospace_cache"},
360 {Opt_recovery, "recovery"}, 375 {Opt_recovery, "recovery"},
361 {Opt_skip_balance, "skip_balance"}, 376 {Opt_skip_balance, "skip_balance"},
@@ -368,6 +383,20 @@ static match_table_t tokens = {
368 {Opt_err, NULL}, 383 {Opt_err, NULL},
369}; 384};
370 385
386#define btrfs_set_and_info(root, opt, fmt, args...) \
387{ \
388 if (!btrfs_test_opt(root, opt)) \
389 btrfs_info(root->fs_info, fmt, ##args); \
390 btrfs_set_opt(root->fs_info->mount_opt, opt); \
391}
392
393#define btrfs_clear_and_info(root, opt, fmt, args...) \
394{ \
395 if (btrfs_test_opt(root, opt)) \
396 btrfs_info(root->fs_info, fmt, ##args); \
397 btrfs_clear_opt(root->fs_info->mount_opt, opt); \
398}
399
371/* 400/*
372 * Regular mount options parser. Everything that is needed only when 401 * Regular mount options parser. Everything that is needed only when
373 * reading in a new superblock is parsed here. 402 * reading in a new superblock is parsed here.
@@ -383,6 +412,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
383 int ret = 0; 412 int ret = 0;
384 char *compress_type; 413 char *compress_type;
385 bool compress_force = false; 414 bool compress_force = false;
415 bool compress = false;
386 416
387 cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); 417 cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy);
388 if (cache_gen) 418 if (cache_gen)
@@ -409,7 +439,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
409 token = match_token(p, tokens, args); 439 token = match_token(p, tokens, args);
410 switch (token) { 440 switch (token) {
411 case Opt_degraded: 441 case Opt_degraded:
412 printk(KERN_INFO "btrfs: allowing degraded mounts\n"); 442 btrfs_info(root->fs_info, "allowing degraded mounts");
413 btrfs_set_opt(info->mount_opt, DEGRADED); 443 btrfs_set_opt(info->mount_opt, DEGRADED);
414 break; 444 break;
415 case Opt_subvol: 445 case Opt_subvol:
@@ -422,27 +452,45 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
422 */ 452 */
423 break; 453 break;
424 case Opt_nodatasum: 454 case Opt_nodatasum:
425 printk(KERN_INFO "btrfs: setting nodatasum\n"); 455 btrfs_set_and_info(root, NODATASUM,
426 btrfs_set_opt(info->mount_opt, NODATASUM); 456 "setting nodatasum");
457 break;
458 case Opt_datasum:
459 if (btrfs_test_opt(root, NODATASUM)) {
460 if (btrfs_test_opt(root, NODATACOW))
461 btrfs_info(root->fs_info, "setting datasum, datacow enabled");
462 else
463 btrfs_info(root->fs_info, "setting datasum");
464 }
465 btrfs_clear_opt(info->mount_opt, NODATACOW);
466 btrfs_clear_opt(info->mount_opt, NODATASUM);
427 break; 467 break;
428 case Opt_nodatacow: 468 case Opt_nodatacow:
429 if (!btrfs_test_opt(root, COMPRESS) || 469 if (!btrfs_test_opt(root, NODATACOW)) {
430 !btrfs_test_opt(root, FORCE_COMPRESS)) { 470 if (!btrfs_test_opt(root, COMPRESS) ||
431 printk(KERN_INFO "btrfs: setting nodatacow, compression disabled\n"); 471 !btrfs_test_opt(root, FORCE_COMPRESS)) {
432 } else { 472 btrfs_info(root->fs_info,
433 printk(KERN_INFO "btrfs: setting nodatacow\n"); 473 "setting nodatacow, compression disabled");
474 } else {
475 btrfs_info(root->fs_info, "setting nodatacow");
476 }
434 } 477 }
435 btrfs_clear_opt(info->mount_opt, COMPRESS); 478 btrfs_clear_opt(info->mount_opt, COMPRESS);
436 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); 479 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
437 btrfs_set_opt(info->mount_opt, NODATACOW); 480 btrfs_set_opt(info->mount_opt, NODATACOW);
438 btrfs_set_opt(info->mount_opt, NODATASUM); 481 btrfs_set_opt(info->mount_opt, NODATASUM);
439 break; 482 break;
483 case Opt_datacow:
484 btrfs_clear_and_info(root, NODATACOW,
485 "setting datacow");
486 break;
440 case Opt_compress_force: 487 case Opt_compress_force:
441 case Opt_compress_force_type: 488 case Opt_compress_force_type:
442 compress_force = true; 489 compress_force = true;
443 /* Fallthrough */ 490 /* Fallthrough */
444 case Opt_compress: 491 case Opt_compress:
445 case Opt_compress_type: 492 case Opt_compress_type:
493 compress = true;
446 if (token == Opt_compress || 494 if (token == Opt_compress ||
447 token == Opt_compress_force || 495 token == Opt_compress_force ||
448 strcmp(args[0].from, "zlib") == 0) { 496 strcmp(args[0].from, "zlib") == 0) {
@@ -469,34 +517,36 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
469 } 517 }
470 518
471 if (compress_force) { 519 if (compress_force) {
472 btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); 520 btrfs_set_and_info(root, FORCE_COMPRESS,
473 pr_info("btrfs: force %s compression\n", 521 "force %s compression",
474 compress_type); 522 compress_type);
475 } else if (btrfs_test_opt(root, COMPRESS)) { 523 } else if (compress) {
476 pr_info("btrfs: use %s compression\n", 524 if (!btrfs_test_opt(root, COMPRESS))
477 compress_type); 525 btrfs_info(root->fs_info,
526 "btrfs: use %s compression\n",
527 compress_type);
478 } 528 }
479 break; 529 break;
480 case Opt_ssd: 530 case Opt_ssd:
481 printk(KERN_INFO "btrfs: use ssd allocation scheme\n"); 531 btrfs_set_and_info(root, SSD,
482 btrfs_set_opt(info->mount_opt, SSD); 532 "use ssd allocation scheme");
483 break; 533 break;
484 case Opt_ssd_spread: 534 case Opt_ssd_spread:
485 printk(KERN_INFO "btrfs: use spread ssd " 535 btrfs_set_and_info(root, SSD_SPREAD,
486 "allocation scheme\n"); 536 "use spread ssd allocation scheme");
487 btrfs_set_opt(info->mount_opt, SSD);
488 btrfs_set_opt(info->mount_opt, SSD_SPREAD);
489 break; 537 break;
490 case Opt_nossd: 538 case Opt_nossd:
491 printk(KERN_INFO "btrfs: not using ssd allocation " 539 btrfs_clear_and_info(root, NOSSD,
492 "scheme\n"); 540 "not using ssd allocation scheme");
493 btrfs_set_opt(info->mount_opt, NOSSD);
494 btrfs_clear_opt(info->mount_opt, SSD); 541 btrfs_clear_opt(info->mount_opt, SSD);
495 btrfs_clear_opt(info->mount_opt, SSD_SPREAD); 542 break;
543 case Opt_barrier:
544 btrfs_clear_and_info(root, NOBARRIER,
545 "turning on barriers");
496 break; 546 break;
497 case Opt_nobarrier: 547 case Opt_nobarrier:
498 printk(KERN_INFO "btrfs: turning off barriers\n"); 548 btrfs_set_and_info(root, NOBARRIER,
499 btrfs_set_opt(info->mount_opt, NOBARRIER); 549 "turning off barriers");
500 break; 550 break;
501 case Opt_thread_pool: 551 case Opt_thread_pool:
502 ret = match_int(&args[0], &intarg); 552 ret = match_int(&args[0], &intarg);
@@ -516,11 +566,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
516 kfree(num); 566 kfree(num);
517 567
518 if (info->max_inline) { 568 if (info->max_inline) {
519 info->max_inline = max_t(u64, 569 info->max_inline = min_t(u64,
520 info->max_inline, 570 info->max_inline,
521 root->sectorsize); 571 root->sectorsize);
522 } 572 }
523 printk(KERN_INFO "btrfs: max_inline at %llu\n", 573 btrfs_info(root->fs_info, "max_inline at %llu",
524 info->max_inline); 574 info->max_inline);
525 } else { 575 } else {
526 ret = -ENOMEM; 576 ret = -ENOMEM;
@@ -534,24 +584,34 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
534 info->alloc_start = memparse(num, NULL); 584 info->alloc_start = memparse(num, NULL);
535 mutex_unlock(&info->chunk_mutex); 585 mutex_unlock(&info->chunk_mutex);
536 kfree(num); 586 kfree(num);
537 printk(KERN_INFO 587 btrfs_info(root->fs_info, "allocations start at %llu",
538 "btrfs: allocations start at %llu\n",
539 info->alloc_start); 588 info->alloc_start);
540 } else { 589 } else {
541 ret = -ENOMEM; 590 ret = -ENOMEM;
542 goto out; 591 goto out;
543 } 592 }
544 break; 593 break;
594 case Opt_acl:
595 root->fs_info->sb->s_flags |= MS_POSIXACL;
596 break;
545 case Opt_noacl: 597 case Opt_noacl:
546 root->fs_info->sb->s_flags &= ~MS_POSIXACL; 598 root->fs_info->sb->s_flags &= ~MS_POSIXACL;
547 break; 599 break;
548 case Opt_notreelog: 600 case Opt_notreelog:
549 printk(KERN_INFO "btrfs: disabling tree log\n"); 601 btrfs_set_and_info(root, NOTREELOG,
550 btrfs_set_opt(info->mount_opt, NOTREELOG); 602 "disabling tree log");
603 break;
604 case Opt_treelog:
605 btrfs_clear_and_info(root, NOTREELOG,
606 "enabling tree log");
551 break; 607 break;
552 case Opt_flushoncommit: 608 case Opt_flushoncommit:
553 printk(KERN_INFO "btrfs: turning on flush-on-commit\n"); 609 btrfs_set_and_info(root, FLUSHONCOMMIT,
554 btrfs_set_opt(info->mount_opt, FLUSHONCOMMIT); 610 "turning on flush-on-commit");
611 break;
612 case Opt_noflushoncommit:
613 btrfs_clear_and_info(root, FLUSHONCOMMIT,
614 "turning off flush-on-commit");
555 break; 615 break;
556 case Opt_ratio: 616 case Opt_ratio:
557 ret = match_int(&args[0], &intarg); 617 ret = match_int(&args[0], &intarg);
@@ -559,7 +619,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
559 goto out; 619 goto out;
560 } else if (intarg >= 0) { 620 } else if (intarg >= 0) {
561 info->metadata_ratio = intarg; 621 info->metadata_ratio = intarg;
562 printk(KERN_INFO "btrfs: metadata ratio %d\n", 622 btrfs_info(root->fs_info, "metadata ratio %d",
563 info->metadata_ratio); 623 info->metadata_ratio);
564 } else { 624 } else {
565 ret = -EINVAL; 625 ret = -EINVAL;
@@ -567,25 +627,35 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
567 } 627 }
568 break; 628 break;
569 case Opt_discard: 629 case Opt_discard:
570 btrfs_set_opt(info->mount_opt, DISCARD); 630 btrfs_set_and_info(root, DISCARD,
631 "turning on discard");
632 break;
633 case Opt_nodiscard:
634 btrfs_clear_and_info(root, DISCARD,
635 "turning off discard");
571 break; 636 break;
572 case Opt_space_cache: 637 case Opt_space_cache:
573 btrfs_set_opt(info->mount_opt, SPACE_CACHE); 638 btrfs_set_and_info(root, SPACE_CACHE,
639 "enabling disk space caching");
574 break; 640 break;
575 case Opt_rescan_uuid_tree: 641 case Opt_rescan_uuid_tree:
576 btrfs_set_opt(info->mount_opt, RESCAN_UUID_TREE); 642 btrfs_set_opt(info->mount_opt, RESCAN_UUID_TREE);
577 break; 643 break;
578 case Opt_no_space_cache: 644 case Opt_no_space_cache:
579 printk(KERN_INFO "btrfs: disabling disk space caching\n"); 645 btrfs_clear_and_info(root, SPACE_CACHE,
580 btrfs_clear_opt(info->mount_opt, SPACE_CACHE); 646 "disabling disk space caching");
581 break; 647 break;
582 case Opt_inode_cache: 648 case Opt_inode_cache:
583 printk(KERN_INFO "btrfs: enabling inode map caching\n"); 649 btrfs_set_and_info(root, CHANGE_INODE_CACHE,
584 btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE); 650 "enabling inode map caching");
651 break;
652 case Opt_noinode_cache:
653 btrfs_clear_and_info(root, CHANGE_INODE_CACHE,
654 "disabling inode map caching");
585 break; 655 break;
586 case Opt_clear_cache: 656 case Opt_clear_cache:
587 printk(KERN_INFO "btrfs: force clearing of disk cache\n"); 657 btrfs_set_and_info(root, CLEAR_CACHE,
588 btrfs_set_opt(info->mount_opt, CLEAR_CACHE); 658 "force clearing of disk cache");
589 break; 659 break;
590 case Opt_user_subvol_rm_allowed: 660 case Opt_user_subvol_rm_allowed:
591 btrfs_set_opt(info->mount_opt, USER_SUBVOL_RM_ALLOWED); 661 btrfs_set_opt(info->mount_opt, USER_SUBVOL_RM_ALLOWED);
@@ -593,12 +663,19 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
593 case Opt_enospc_debug: 663 case Opt_enospc_debug:
594 btrfs_set_opt(info->mount_opt, ENOSPC_DEBUG); 664 btrfs_set_opt(info->mount_opt, ENOSPC_DEBUG);
595 break; 665 break;
666 case Opt_noenospc_debug:
667 btrfs_clear_opt(info->mount_opt, ENOSPC_DEBUG);
668 break;
596 case Opt_defrag: 669 case Opt_defrag:
597 printk(KERN_INFO "btrfs: enabling auto defrag\n"); 670 btrfs_set_and_info(root, AUTO_DEFRAG,
598 btrfs_set_opt(info->mount_opt, AUTO_DEFRAG); 671 "enabling auto defrag");
672 break;
673 case Opt_nodefrag:
674 btrfs_clear_and_info(root, AUTO_DEFRAG,
675 "disabling auto defrag");
599 break; 676 break;
600 case Opt_recovery: 677 case Opt_recovery:
601 printk(KERN_INFO "btrfs: enabling auto recovery\n"); 678 btrfs_info(root->fs_info, "enabling auto recovery");
602 btrfs_set_opt(info->mount_opt, RECOVERY); 679 btrfs_set_opt(info->mount_opt, RECOVERY);
603 break; 680 break;
604 case Opt_skip_balance: 681 case Opt_skip_balance:
@@ -606,14 +683,14 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
606 break; 683 break;
607#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 684#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
608 case Opt_check_integrity_including_extent_data: 685 case Opt_check_integrity_including_extent_data:
609 printk(KERN_INFO "btrfs: enabling check integrity" 686 btrfs_info(root->fs_info,
610 " including extent data\n"); 687 "enabling check integrity including extent data");
611 btrfs_set_opt(info->mount_opt, 688 btrfs_set_opt(info->mount_opt,
612 CHECK_INTEGRITY_INCLUDING_EXTENT_DATA); 689 CHECK_INTEGRITY_INCLUDING_EXTENT_DATA);
613 btrfs_set_opt(info->mount_opt, CHECK_INTEGRITY); 690 btrfs_set_opt(info->mount_opt, CHECK_INTEGRITY);
614 break; 691 break;
615 case Opt_check_integrity: 692 case Opt_check_integrity:
616 printk(KERN_INFO "btrfs: enabling check integrity\n"); 693 btrfs_info(root->fs_info, "enabling check integrity");
617 btrfs_set_opt(info->mount_opt, CHECK_INTEGRITY); 694 btrfs_set_opt(info->mount_opt, CHECK_INTEGRITY);
618 break; 695 break;
619 case Opt_check_integrity_print_mask: 696 case Opt_check_integrity_print_mask:
@@ -622,8 +699,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
622 goto out; 699 goto out;
623 } else if (intarg >= 0) { 700 } else if (intarg >= 0) {
624 info->check_integrity_print_mask = intarg; 701 info->check_integrity_print_mask = intarg;
625 printk(KERN_INFO "btrfs:" 702 btrfs_info(root->fs_info, "check_integrity_print_mask 0x%x",
626 " check_integrity_print_mask 0x%x\n",
627 info->check_integrity_print_mask); 703 info->check_integrity_print_mask);
628 } else { 704 } else {
629 ret = -EINVAL; 705 ret = -EINVAL;
@@ -634,8 +710,8 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
634 case Opt_check_integrity_including_extent_data: 710 case Opt_check_integrity_including_extent_data:
635 case Opt_check_integrity: 711 case Opt_check_integrity:
636 case Opt_check_integrity_print_mask: 712 case Opt_check_integrity_print_mask:
637 printk(KERN_ERR "btrfs: support for check_integrity*" 713 btrfs_err(root->fs_info,
638 " not compiled in!\n"); 714 "support for check_integrity* not compiled in!");
639 ret = -EINVAL; 715 ret = -EINVAL;
640 goto out; 716 goto out;
641#endif 717#endif
@@ -655,28 +731,24 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
655 intarg = 0; 731 intarg = 0;
656 ret = match_int(&args[0], &intarg); 732 ret = match_int(&args[0], &intarg);
657 if (ret < 0) { 733 if (ret < 0) {
658 printk(KERN_ERR 734 btrfs_err(root->fs_info, "invalid commit interval");
659 "btrfs: invalid commit interval\n");
660 ret = -EINVAL; 735 ret = -EINVAL;
661 goto out; 736 goto out;
662 } 737 }
663 if (intarg > 0) { 738 if (intarg > 0) {
664 if (intarg > 300) { 739 if (intarg > 300) {
665 printk(KERN_WARNING 740 btrfs_warn(root->fs_info, "excessive commit interval %d",
666 "btrfs: excessive commit interval %d\n",
667 intarg); 741 intarg);
668 } 742 }
669 info->commit_interval = intarg; 743 info->commit_interval = intarg;
670 } else { 744 } else {
671 printk(KERN_INFO 745 btrfs_info(root->fs_info, "using default commit interval %ds",
672 "btrfs: using default commit interval %ds\n",
673 BTRFS_DEFAULT_COMMIT_INTERVAL); 746 BTRFS_DEFAULT_COMMIT_INTERVAL);
674 info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL; 747 info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL;
675 } 748 }
676 break; 749 break;
677 case Opt_err: 750 case Opt_err:
678 printk(KERN_INFO "btrfs: unrecognized mount option " 751 btrfs_info(root->fs_info, "unrecognized mount option '%s'", p);
679 "'%s'\n", p);
680 ret = -EINVAL; 752 ret = -EINVAL;
681 goto out; 753 goto out;
682 default: 754 default:
@@ -685,7 +757,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
685 } 757 }
686out: 758out:
687 if (!ret && btrfs_test_opt(root, SPACE_CACHE)) 759 if (!ret && btrfs_test_opt(root, SPACE_CACHE))
688 printk(KERN_INFO "btrfs: disk space caching is enabled\n"); 760 btrfs_info(root->fs_info, "disk space caching is enabled");
689 kfree(orig); 761 kfree(orig);
690 return ret; 762 return ret;
691} 763}
@@ -748,7 +820,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
748 break; 820 break;
749 case Opt_subvolrootid: 821 case Opt_subvolrootid:
750 printk(KERN_WARNING 822 printk(KERN_WARNING
751 "btrfs: 'subvolrootid' mount option is deprecated and has no effect\n"); 823 "BTRFS: 'subvolrootid' mount option is deprecated and has "
824 "no effect\n");
752 break; 825 break;
753 case Opt_device: 826 case Opt_device:
754 device_name = match_strdup(&args[0]); 827 device_name = match_strdup(&args[0]);
@@ -782,6 +855,7 @@ static struct dentry *get_default_root(struct super_block *sb,
782 struct btrfs_path *path; 855 struct btrfs_path *path;
783 struct btrfs_key location; 856 struct btrfs_key location;
784 struct inode *inode; 857 struct inode *inode;
858 struct dentry *dentry;
785 u64 dir_id; 859 u64 dir_id;
786 int new = 0; 860 int new = 0;
787 861
@@ -852,7 +926,13 @@ setup_root:
852 return dget(sb->s_root); 926 return dget(sb->s_root);
853 } 927 }
854 928
855 return d_obtain_alias(inode); 929 dentry = d_obtain_alias(inode);
930 if (!IS_ERR(dentry)) {
931 spin_lock(&dentry->d_lock);
932 dentry->d_flags &= ~DCACHE_DISCONNECTED;
933 spin_unlock(&dentry->d_lock);
934 }
935 return dentry;
856} 936}
857 937
858static int btrfs_fill_super(struct super_block *sb, 938static int btrfs_fill_super(struct super_block *sb,
@@ -877,7 +957,7 @@ static int btrfs_fill_super(struct super_block *sb,
877 sb->s_flags |= MS_I_VERSION; 957 sb->s_flags |= MS_I_VERSION;
878 err = open_ctree(sb, fs_devices, (char *)data); 958 err = open_ctree(sb, fs_devices, (char *)data);
879 if (err) { 959 if (err) {
880 printk("btrfs: open_ctree failed\n"); 960 printk(KERN_ERR "BTRFS: open_ctree failed\n");
881 return err; 961 return err;
882 } 962 }
883 963
@@ -1115,7 +1195,7 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
1115 dput(root); 1195 dput(root);
1116 root = ERR_PTR(-EINVAL); 1196 root = ERR_PTR(-EINVAL);
1117 deactivate_locked_super(s); 1197 deactivate_locked_super(s);
1118 printk(KERN_ERR "btrfs: '%s' is not a valid subvolume\n", 1198 printk(KERN_ERR "BTRFS: '%s' is not a valid subvolume\n",
1119 subvol_name); 1199 subvol_name);
1120 } 1200 }
1121 1201
@@ -1240,7 +1320,7 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
1240 1320
1241 fs_info->thread_pool_size = new_pool_size; 1321 fs_info->thread_pool_size = new_pool_size;
1242 1322
1243 printk(KERN_INFO "btrfs: resize thread pool %d -> %d\n", 1323 btrfs_info(fs_info, "resize thread pool %d -> %d",
1244 old_pool_size, new_pool_size); 1324 old_pool_size, new_pool_size);
1245 1325
1246 btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size); 1326 btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size);
@@ -1346,7 +1426,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
1346 } else { 1426 } else {
1347 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) { 1427 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) {
1348 btrfs_err(fs_info, 1428 btrfs_err(fs_info,
1349 "Remounting read-write after error is not allowed\n"); 1429 "Remounting read-write after error is not allowed");
1350 ret = -EINVAL; 1430 ret = -EINVAL;
1351 goto restore; 1431 goto restore;
1352 } 1432 }
@@ -1358,8 +1438,8 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
1358 if (fs_info->fs_devices->missing_devices > 1438 if (fs_info->fs_devices->missing_devices >
1359 fs_info->num_tolerated_disk_barrier_failures && 1439 fs_info->num_tolerated_disk_barrier_failures &&
1360 !(*flags & MS_RDONLY)) { 1440 !(*flags & MS_RDONLY)) {
1361 printk(KERN_WARNING 1441 btrfs_warn(fs_info,
1362 "Btrfs: too many missing devices, writeable remount is not allowed\n"); 1442 "too many missing devices, writeable remount is not allowed");
1363 ret = -EACCES; 1443 ret = -EACCES;
1364 goto restore; 1444 goto restore;
1365 } 1445 }
@@ -1384,16 +1464,15 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
1384 1464
1385 ret = btrfs_resume_dev_replace_async(fs_info); 1465 ret = btrfs_resume_dev_replace_async(fs_info);
1386 if (ret) { 1466 if (ret) {
1387 pr_warn("btrfs: failed to resume dev_replace\n"); 1467 btrfs_warn(fs_info, "failed to resume dev_replace");
1388 goto restore; 1468 goto restore;
1389 } 1469 }
1390 1470
1391 if (!fs_info->uuid_root) { 1471 if (!fs_info->uuid_root) {
1392 pr_info("btrfs: creating UUID tree\n"); 1472 btrfs_info(fs_info, "creating UUID tree");
1393 ret = btrfs_create_uuid_tree(fs_info); 1473 ret = btrfs_create_uuid_tree(fs_info);
1394 if (ret) { 1474 if (ret) {
1395 pr_warn("btrfs: failed to create the uuid tree" 1475 btrfs_warn(fs_info, "failed to create the UUID tree %d", ret);
1396 "%d\n", ret);
1397 goto restore; 1476 goto restore;
1398 } 1477 }
1399 } 1478 }
@@ -1773,7 +1852,7 @@ static int btrfs_interface_init(void)
1773static void btrfs_interface_exit(void) 1852static void btrfs_interface_exit(void)
1774{ 1853{
1775 if (misc_deregister(&btrfs_misc) < 0) 1854 if (misc_deregister(&btrfs_misc) < 0)
1776 printk(KERN_INFO "btrfs: misc_deregister failed for control device\n"); 1855 printk(KERN_INFO "BTRFS: misc_deregister failed for control device\n");
1777} 1856}
1778 1857
1779static void btrfs_print_info(void) 1858static void btrfs_print_info(void)
@@ -1818,10 +1897,16 @@ static int __init init_btrfs_fs(void)
1818{ 1897{
1819 int err; 1898 int err;
1820 1899
1821 err = btrfs_init_sysfs(); 1900 err = btrfs_hash_init();
1822 if (err) 1901 if (err)
1823 return err; 1902 return err;
1824 1903
1904 btrfs_props_init();
1905
1906 err = btrfs_init_sysfs();
1907 if (err)
1908 goto free_hash;
1909
1825 btrfs_init_compress(); 1910 btrfs_init_compress();
1826 1911
1827 err = btrfs_init_cachep(); 1912 err = btrfs_init_cachep();
@@ -1895,6 +1980,8 @@ free_cachep:
1895free_compress: 1980free_compress:
1896 btrfs_exit_compress(); 1981 btrfs_exit_compress();
1897 btrfs_exit_sysfs(); 1982 btrfs_exit_sysfs();
1983free_hash:
1984 btrfs_hash_exit();
1898 return err; 1985 return err;
1899} 1986}
1900 1987
@@ -1913,9 +2000,10 @@ static void __exit exit_btrfs_fs(void)
1913 btrfs_exit_sysfs(); 2000 btrfs_exit_sysfs();
1914 btrfs_cleanup_fs_uuids(); 2001 btrfs_cleanup_fs_uuids();
1915 btrfs_exit_compress(); 2002 btrfs_exit_compress();
2003 btrfs_hash_exit();
1916} 2004}
1917 2005
1918module_init(init_btrfs_fs) 2006late_initcall(init_btrfs_fs);
1919module_exit(exit_btrfs_fs) 2007module_exit(exit_btrfs_fs)
1920 2008
1921MODULE_LICENSE("GPL"); 2009MODULE_LICENSE("GPL");