aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-01-13 00:36:07 -0500
committerChris Mason <clm@fb.com>2014-01-28 16:20:34 -0500
commit078025347c8ed43ff330e392476d8866ac1b297f (patch)
tree1481318375cd77421e667af2dea34e5957300504 /fs/btrfs
parent3818aea275423236db38a2d2d0a4951bc6da2e01 (diff)
btrfs: Cleanup the btrfs_parse_options for remount.
Since remount will pending the new mount options to the original mount options, which will make btrfs_parse_options check the old options then new options, causing some stupid output like "enabling XXX" following by "disable XXX". This patch will add extra check before every btrfs_info to skip the output from old options checking. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/super.c137
1 files changed, 77 insertions, 60 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 362aef44a17b..c02f63356895 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -383,6 +383,20 @@ static match_table_t tokens = {
383 {Opt_err, NULL}, 383 {Opt_err, NULL},
384}; 384};
385 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
386/* 400/*
387 * Regular mount options parser. Everything that is needed only when 401 * Regular mount options parser. Everything that is needed only when
388 * reading in a new superblock is parsed here. 402 * reading in a new superblock is parsed here.
@@ -398,6 +412,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
398 int ret = 0; 412 int ret = 0;
399 char *compress_type; 413 char *compress_type;
400 bool compress_force = false; 414 bool compress_force = false;
415 bool compress = false;
401 416
402 cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); 417 cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy);
403 if (cache_gen) 418 if (cache_gen)
@@ -437,24 +452,28 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
437 */ 452 */
438 break; 453 break;
439 case Opt_nodatasum: 454 case Opt_nodatasum:
440 btrfs_info(root->fs_info, "setting nodatasum"); 455 btrfs_set_and_info(root, NODATASUM,
441 btrfs_set_opt(info->mount_opt, NODATASUM); 456 "setting nodatasum");
442 break; 457 break;
443 case Opt_datasum: 458 case Opt_datasum:
444 if (btrfs_test_opt(root, NODATACOW)) 459 if (btrfs_test_opt(root, NODATASUM)) {
445 btrfs_info(root->fs_info, "setting datasum, datacow enabled"); 460 if (btrfs_test_opt(root, NODATACOW))
446 else 461 btrfs_info(root->fs_info, "setting datasum, datacow enabled");
447 btrfs_info(root->fs_info, "setting datasum"); 462 else
463 btrfs_info(root->fs_info, "setting datasum");
464 }
448 btrfs_clear_opt(info->mount_opt, NODATACOW); 465 btrfs_clear_opt(info->mount_opt, NODATACOW);
449 btrfs_clear_opt(info->mount_opt, NODATASUM); 466 btrfs_clear_opt(info->mount_opt, NODATASUM);
450 break; 467 break;
451 case Opt_nodatacow: 468 case Opt_nodatacow:
452 if (!btrfs_test_opt(root, COMPRESS) || 469 if (!btrfs_test_opt(root, NODATACOW)) {
453 !btrfs_test_opt(root, FORCE_COMPRESS)) { 470 if (!btrfs_test_opt(root, COMPRESS) ||
471 !btrfs_test_opt(root, FORCE_COMPRESS)) {
454 btrfs_info(root->fs_info, 472 btrfs_info(root->fs_info,
455 "setting nodatacow, compression disabled"); 473 "setting nodatacow, compression disabled");
456 } else { 474 } else {
457 btrfs_info(root->fs_info, "setting nodatacow"); 475 btrfs_info(root->fs_info, "setting nodatacow");
476 }
458 } 477 }
459 btrfs_clear_opt(info->mount_opt, COMPRESS); 478 btrfs_clear_opt(info->mount_opt, COMPRESS);
460 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); 479 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
@@ -462,9 +481,8 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
462 btrfs_set_opt(info->mount_opt, NODATASUM); 481 btrfs_set_opt(info->mount_opt, NODATASUM);
463 break; 482 break;
464 case Opt_datacow: 483 case Opt_datacow:
465 if (btrfs_test_opt(root, NODATACOW)) 484 btrfs_clear_and_info(root, NODATACOW,
466 btrfs_info(root->fs_info, "setting datacow"); 485 "setting datacow");
467 btrfs_clear_opt(info->mount_opt, NODATACOW);
468 break; 486 break;
469 case Opt_compress_force: 487 case Opt_compress_force:
470 case Opt_compress_force_type: 488 case Opt_compress_force_type:
@@ -472,6 +490,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
472 /* Fallthrough */ 490 /* Fallthrough */
473 case Opt_compress: 491 case Opt_compress:
474 case Opt_compress_type: 492 case Opt_compress_type:
493 compress = true;
475 if (token == Opt_compress || 494 if (token == Opt_compress ||
476 token == Opt_compress_force || 495 token == Opt_compress_force ||
477 strcmp(args[0].from, "zlib") == 0) { 496 strcmp(args[0].from, "zlib") == 0) {
@@ -498,37 +517,36 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
498 } 517 }
499 518
500 if (compress_force) { 519 if (compress_force) {
501 btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); 520 btrfs_set_and_info(root, FORCE_COMPRESS,
502 btrfs_info(root->fs_info, "force %s compression", 521 "force %s compression",
503 compress_type); 522 compress_type);
504 } else if (btrfs_test_opt(root, COMPRESS)) { 523 } else if (compress) {
505 pr_info("btrfs: use %s compression\n", 524 if (!btrfs_test_opt(root, COMPRESS))
506 compress_type); 525 btrfs_info(root->fs_info,
526 "btrfs: use %s compression\n",
527 compress_type);
507 } 528 }
508 break; 529 break;
509 case Opt_ssd: 530 case Opt_ssd:
510 btrfs_info(root->fs_info, "use ssd allocation scheme"); 531 btrfs_set_and_info(root, SSD,
511 btrfs_set_opt(info->mount_opt, SSD); 532 "use ssd allocation scheme");
512 break; 533 break;
513 case Opt_ssd_spread: 534 case Opt_ssd_spread:
514 btrfs_info(root->fs_info, "use spread ssd allocation scheme"); 535 btrfs_set_and_info(root, SSD_SPREAD,
515 btrfs_set_opt(info->mount_opt, SSD); 536 "use spread ssd allocation scheme");
516 btrfs_set_opt(info->mount_opt, SSD_SPREAD);
517 break; 537 break;
518 case Opt_nossd: 538 case Opt_nossd:
519 btrfs_info(root->fs_info, "not using ssd allocation scheme"); 539 btrfs_clear_and_info(root, NOSSD,
520 btrfs_set_opt(info->mount_opt, NOSSD); 540 "not using ssd allocation scheme");
521 btrfs_clear_opt(info->mount_opt, SSD); 541 btrfs_clear_opt(info->mount_opt, SSD);
522 btrfs_clear_opt(info->mount_opt, SSD_SPREAD);
523 break; 542 break;
524 case Opt_barrier: 543 case Opt_barrier:
525 if (btrfs_test_opt(root, NOBARRIER)) 544 btrfs_clear_and_info(root, NOBARRIER,
526 btrfs_info(root->fs_info, "turning on barriers"); 545 "turning on barriers");
527 btrfs_clear_opt(info->mount_opt, NOBARRIER);
528 break; 546 break;
529 case Opt_nobarrier: 547 case Opt_nobarrier:
530 btrfs_info(root->fs_info, "turning off barriers"); 548 btrfs_set_and_info(root, NOBARRIER,
531 btrfs_set_opt(info->mount_opt, NOBARRIER); 549 "turning off barriers");
532 break; 550 break;
533 case Opt_thread_pool: 551 case Opt_thread_pool:
534 ret = match_int(&args[0], &intarg); 552 ret = match_int(&args[0], &intarg);
@@ -580,22 +598,20 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
580 root->fs_info->sb->s_flags &= ~MS_POSIXACL; 598 root->fs_info->sb->s_flags &= ~MS_POSIXACL;
581 break; 599 break;
582 case Opt_notreelog: 600 case Opt_notreelog:
583 btrfs_info(root->fs_info, "disabling tree log"); 601 btrfs_set_and_info(root, NOTREELOG,
584 btrfs_set_opt(info->mount_opt, NOTREELOG); 602 "disabling tree log");
585 break; 603 break;
586 case Opt_treelog: 604 case Opt_treelog:
587 if (btrfs_test_opt(root, NOTREELOG)) 605 btrfs_clear_and_info(root, NOTREELOG,
588 btrfs_info(root->fs_info, "enabling tree log"); 606 "enabling tree log");
589 btrfs_clear_opt(info->mount_opt, NOTREELOG);
590 break; 607 break;
591 case Opt_flushoncommit: 608 case Opt_flushoncommit:
592 btrfs_info(root->fs_info, "turning on flush-on-commit"); 609 btrfs_set_and_info(root, FLUSHONCOMMIT,
593 btrfs_set_opt(info->mount_opt, FLUSHONCOMMIT); 610 "turning on flush-on-commit");
594 break; 611 break;
595 case Opt_noflushoncommit: 612 case Opt_noflushoncommit:
596 if (btrfs_test_opt(root, FLUSHONCOMMIT)) 613 btrfs_clear_and_info(root, FLUSHONCOMMIT,
597 btrfs_info(root->fs_info, "turning off flush-on-commit"); 614 "turning off flush-on-commit");
598 btrfs_clear_opt(info->mount_opt, FLUSHONCOMMIT);
599 break; 615 break;
600 case Opt_ratio: 616 case Opt_ratio:
601 ret = match_int(&args[0], &intarg); 617 ret = match_int(&args[0], &intarg);
@@ -611,33 +627,35 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
611 } 627 }
612 break; 628 break;
613 case Opt_discard: 629 case Opt_discard:
614 btrfs_set_opt(info->mount_opt, DISCARD); 630 btrfs_set_and_info(root, DISCARD,
631 "turning on discard");
615 break; 632 break;
616 case Opt_nodiscard: 633 case Opt_nodiscard:
617 btrfs_clear_opt(info->mount_opt, DISCARD); 634 btrfs_clear_and_info(root, DISCARD,
635 "turning off discard");
618 break; 636 break;
619 case Opt_space_cache: 637 case Opt_space_cache:
620 btrfs_set_opt(info->mount_opt, SPACE_CACHE); 638 btrfs_set_and_info(root, SPACE_CACHE,
639 "enabling disk space caching");
621 break; 640 break;
622 case Opt_rescan_uuid_tree: 641 case Opt_rescan_uuid_tree:
623 btrfs_set_opt(info->mount_opt, RESCAN_UUID_TREE); 642 btrfs_set_opt(info->mount_opt, RESCAN_UUID_TREE);
624 break; 643 break;
625 case Opt_no_space_cache: 644 case Opt_no_space_cache:
626 btrfs_info(root->fs_info, "disabling disk space caching"); 645 btrfs_clear_and_info(root, SPACE_CACHE,
627 btrfs_clear_opt(info->mount_opt, SPACE_CACHE); 646 "disabling disk space caching");
628 break; 647 break;
629 case Opt_inode_cache: 648 case Opt_inode_cache:
630 btrfs_info(root->fs_info, "enabling inode map caching"); 649 btrfs_set_and_info(root, CHANGE_INODE_CACHE,
631 btrfs_set_opt(info->mount_opt, CHANGE_INODE_CACHE); 650 "enabling inode map caching");
632 break; 651 break;
633 case Opt_noinode_cache: 652 case Opt_noinode_cache:
634 if (btrfs_test_opt(root, CHANGE_INODE_CACHE)) 653 btrfs_clear_and_info(root, CHANGE_INODE_CACHE,
635 btrfs_info(root->fs_info, "disabling inode map caching"); 654 "disabling inode map caching");
636 btrfs_clear_opt(info->mount_opt, CHANGE_INODE_CACHE);
637 break; 655 break;
638 case Opt_clear_cache: 656 case Opt_clear_cache:
639 btrfs_info(root->fs_info, "force clearing of disk cache"); 657 btrfs_set_and_info(root, CLEAR_CACHE,
640 btrfs_set_opt(info->mount_opt, CLEAR_CACHE); 658 "force clearing of disk cache");
641 break; 659 break;
642 case Opt_user_subvol_rm_allowed: 660 case Opt_user_subvol_rm_allowed:
643 btrfs_set_opt(info->mount_opt, USER_SUBVOL_RM_ALLOWED); 661 btrfs_set_opt(info->mount_opt, USER_SUBVOL_RM_ALLOWED);
@@ -649,13 +667,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
649 btrfs_clear_opt(info->mount_opt, ENOSPC_DEBUG); 667 btrfs_clear_opt(info->mount_opt, ENOSPC_DEBUG);
650 break; 668 break;
651 case Opt_defrag: 669 case Opt_defrag:
652 btrfs_info(root->fs_info, "enabling auto defrag"); 670 btrfs_set_and_info(root, AUTO_DEFRAG,
653 btrfs_set_opt(info->mount_opt, AUTO_DEFRAG); 671 "enabling auto defrag");
654 break; 672 break;
655 case Opt_nodefrag: 673 case Opt_nodefrag:
656 if (btrfs_test_opt(root, AUTO_DEFRAG)) 674 btrfs_clear_and_info(root, AUTO_DEFRAG,
657 btrfs_info(root->fs_info, "disabling auto defrag"); 675 "disabling auto defrag");
658 btrfs_clear_opt(info->mount_opt, AUTO_DEFRAG);
659 break; 676 break;
660 case Opt_recovery: 677 case Opt_recovery:
661 btrfs_info(root->fs_info, "enabling auto recovery"); 678 btrfs_info(root->fs_info, "enabling auto recovery");