~wb-munzinger/+junk/ocfs2-tools

« back to all changes in this revision

Viewing changes to fsck.ocfs2/fsck.c

  • Committer: David Weber
  • Date: 2012-01-30 08:42:00 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: wb@munzinger.de-20120130084200-c8cy478mu9fk7tkf
Import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
                " -b superblock Treat given block as the super block\n"
134
134
                " -B blocksize  Force the given block size\n"
135
135
                " -G            Ask to fix mismatched inode generations\n"
 
136
                " -P            Show progress\n"
 
137
                " -t            Show I/O statistics\n"
 
138
                " -tt           Show I/O statistics per pass\n"
136
139
                " -u            Access the device with buffering\n"
137
140
                " -V            Output fsck.ocfs2's version\n"
138
141
                " -v            Provide verbose debugging output\n"
407
410
        fprintf(stderr, "%s %s\n", whoami, VERSION);
408
411
}
409
412
 
 
413
#define P_(singular, plural, n) ((n) == 1 ? (singular) : (plural))
 
414
 
 
415
static void show_stats(o2fsck_state *ost)
 
416
{
 
417
        uint32_t dir_links, num_links;
 
418
 
 
419
        if (!ost->ost_show_stats)
 
420
                return;
 
421
 
 
422
        dir_links = ost->ost_dir_count;
 
423
        num_links = ost->ost_links_count - ost->ost_dir_count;
 
424
 
 
425
        printf("\n  # of inodes with depth 0/1/2/3/4/5: %u/%u/%u/%u/%u/%u\n",
 
426
               ost->ost_tree_depth_count[0], ost->ost_tree_depth_count[1],
 
427
               ost->ost_tree_depth_count[2], ost->ost_tree_depth_count[3],
 
428
               ost->ost_tree_depth_count[4], ost->ost_tree_depth_count[5]);
 
429
        printf("  # of orphaned inodes found/deleted: %u/%u\n",
 
430
               ost->ost_orphan_count, ost->ost_orphan_deleted_count);
 
431
 
 
432
        printf(P_("\n%12u regular file", "\n%12u regular files",
 
433
                  ost->ost_file_count), ost->ost_file_count);
 
434
        printf(P_(" (%u inline,", " (%u inlines,",
 
435
                  ost->ost_inline_file_count), ost->ost_inline_file_count);
 
436
        printf(P_(" %u reflink)\n", " %u reflinks)\n",
 
437
                  ost->ost_reflinks_count), ost->ost_reflinks_count);
 
438
        printf(P_("%12u directory", "%12u directories",
 
439
                  ost->ost_dir_count), ost->ost_dir_count);
 
440
        printf(P_(" (%u inline)\n", " (%u inlines)\n",
 
441
                  ost->ost_inline_dir_count), ost->ost_inline_dir_count);
 
442
        printf(P_("%12u character device file\n",
 
443
                  "%12u character device files\n", ost->ost_chardev_count),
 
444
               ost->ost_chardev_count);
 
445
        printf(P_("%12u block device file\n", "%12u block device files\n",
 
446
                  ost->ost_blockdev_count), ost->ost_blockdev_count);
 
447
        printf(P_("%12u fifo\n", "%12u fifos\n", ost->ost_fifo_count),
 
448
               ost->ost_fifo_count);
 
449
        printf(P_("%12u link\n", "%12u links\n", num_links), num_links);
 
450
        printf(P_("%12u symbolic link", "%12u symbolic links",
 
451
                  ost->ost_symlinks_count), ost->ost_symlinks_count);
 
452
        printf(P_(" (%u fast symbolic link)\n", " (%u fast symbolic links)\n",
 
453
                  ost->ost_fast_symlinks_count), ost->ost_fast_symlinks_count);
 
454
        printf(P_("%12u socket\n", "%12u sockets\n", ost->ost_sockets_count),
 
455
               ost->ost_sockets_count);
 
456
        printf("\n");
 
457
}
 
458
 
410
459
static errcode_t open_and_check(o2fsck_state *ost, char *filename,
411
460
                                int open_flags, uint64_t blkno,
412
461
                                uint64_t blksize)
591
640
             !strcmp(running.c_cluster, disk.c_cluster)))
592
641
                goto bail;
593
642
 
 
643
#define RECOVER_CLUSTER_WARNING                                         \
 
644
        "The running cluster is using the %s stack\n"                   \
 
645
        "%s%s, but the filesystem is configured for\n"                  \
 
646
        "the %s stack%s%s. Thus, %s cannot\n"                           \
 
647
        "determine whether the filesystem is in use or not. This utility can\n"\
 
648
        "reconfigure the filesystem to use the currently running cluster configuration.\n"\
 
649
        "DANGER: YOU MUST BE ABSOLUTELY SURE THAT NO OTHER NODE IS USING THIS\n"\
 
650
        "FILESYSTEM BEFORE MODIFYING ITS CLUSTER CONFIGURATION.\n"      \
 
651
        "Recover cluster configuration information the running cluster?"
 
652
 
594
653
        /* recover the backup information to superblock. */
595
 
        if (prompt(ost, PN, PR_RECOVER_CLUSTER_INFO,
596
 
                   "The running cluster is using the %s stack%s%s, but "
597
 
                   "the filesystem is configured for the %s stack%s%s.  "
598
 
                   "Thus, %s cannot determine whether the filesystem is in "
599
 
                   "use.  %s can reconfigure the filesystem to use the "
600
 
                   "currently running cluster configuration.  DANGER: "
601
 
                   "YOU MUST BE ABSOLUTELY SURE THAT NO OTHER NODE IS "
602
 
                   "USING THIS FILESYSTEM BEFORE MODIFYING ITS CLUSTER "
603
 
                   "CONFIGURATION.  Recover cluster configuration "
604
 
                   "information the running cluster?",
 
654
        if (prompt(ost, PN, PR_RECOVER_CLUSTER_INFO, RECOVER_CLUSTER_WARNING,
605
655
                   running.c_stack ? running.c_stack : "classic o2cb",
606
 
                   running.c_stack ? " with the cluster name " : "",
 
656
                   running.c_stack ? "with the cluster name " : "",
607
657
                   running.c_stack ? running.c_cluster : "",
608
658
                   disk.c_stack ? disk.c_stack : "classic o2cb",
609
659
                   disk.c_stack ? " with the cluster name " : "",
610
 
                   disk.c_stack ? disk.c_cluster : "", whoami, whoami)) {
 
660
                   disk.c_stack ? disk.c_cluster : "", whoami)) {
611
661
                ret = ocfs2_set_cluster_desc(ost->ost_fs, &running);
612
662
                if (ret)
613
663
                        goto bail;
655
705
        setlinebuf(stderr);
656
706
        setlinebuf(stdout);
657
707
 
658
 
        while((c = getopt(argc, argv, "b:B:DfFGnupavVyr:")) != EOF) {
 
708
        tools_progress_disable();
 
709
 
 
710
        while ((c = getopt(argc, argv, "b:B:DfFGnupavVytPr:")) != EOF) {
659
711
                switch (c) {
660
712
                        case 'b':
661
713
                                blkno = read_number(optarg);
716
768
                                ost->ost_answer = 0;
717
769
                                break;
718
770
 
 
771
                        case 'P':
 
772
                                tools_progress_enable();
 
773
                                break;
 
774
 
719
775
                        case 'y':
720
776
                                ost->ost_ask = 0;
721
777
                                ost->ost_answer = 1;
738
794
                                sb_num = read_number(optarg);
739
795
                                break;
740
796
 
 
797
                        case 't':
 
798
                                if (ost->ost_show_stats)
 
799
                                        ost->ost_show_extended_stats = 1;
 
800
                                ost->ost_show_stats = 1;
 
801
                                break;
 
802
 
741
803
                        default:
742
804
                                fsck_mask |= FSCK_USAGE;
743
805
                                print_usage();
845
907
 
846
908
                block_signals(SIG_BLOCK);
847
909
                ret = ocfs2_initialize_dlm(ost->ost_fs, whoami);
848
 
                if (ret == O2CB_ET_INVALID_STACK_NAME) {
 
910
                if (ret == O2CB_ET_INVALID_STACK_NAME ||
 
911
                    ret == O2CB_ET_INVALID_CLUSTER_NAME ||
 
912
                    ret == O2CB_ET_INVALID_HEARTBEAT_MODE) {
849
913
                        block_signals(SIG_UNBLOCK);
850
914
                        ret = recover_cluster_info(ost);
851
915
                        if (ret) {
982
1046
        else {
983
1047
                fsck_mask = FSCK_OK;
984
1048
                ost->ost_saw_error = 0;
985
 
                printf("All passes succeeded.\n");
 
1049
                printf("All passes succeeded.\n\n");
 
1050
                o2fsck_print_resource_track(NULL, ost, &ost->ost_rt,
 
1051
                                            ost->ost_fs->fs_io);
 
1052
                show_stats(ost);
986
1053
        }
987
1054
 
988
1055
clear_dirty_flag: