1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
9 #include <sys/resource.h>
10 #include "xfs_multidisk.h"
18 #include "err_protos.h"
27 * option tables for getsubopt calls
31 * -o: user-supplied override options
43 static char *o_opts
[] = {
44 [ASSUME_XFS
] = "assume_xfs",
45 [IHASH_SIZE
] = "ihash",
46 [BHASH_SIZE
] = "bhash",
47 [AG_STRIDE
] = "ag_stride",
48 [FORCE_GEO
] = "force_geometry",
49 [PHASE2_THREADS
] = "phase2_threads",
54 * -c: conversion options
57 CONVERT_LAZY_COUNT
= 0,
61 static char *c_opts
[] = {
62 [CONVERT_LAZY_COUNT
] = "lazycount",
67 static int bhash_option_used
;
68 static long max_mem_specified
; /* in megabytes */
69 static int phase2_threads
= 32;
70 static bool report_corrected
;
76 "Usage: %s [options] device\n"
79 " -f The device is a file\n"
80 " -L Force log zeroing. Do this as a last resort.\n"
81 " -l logdev Specifies the device where the external log resides.\n"
82 " -m maxmem Maximum amount of memory to be used in megabytes.\n"
83 " -n No modify mode, just checks the filesystem for damage.\n"
84 " (Cannot be used together with -e.)\n"
85 " -P Disables prefetching.\n"
86 " -r rtdev Specifies the device where the realtime section resides.\n"
87 " -v Verbose output.\n"
88 " -c subopts Change filesystem parameters - use xfs_admin.\n"
89 " -o subopts Override default behaviour, refer to man page.\n"
90 " -t interval Reporting interval in seconds.\n"
91 " -d Repair dangerously.\n"
92 " -e Exit with a non-zero code if any errors were repaired.\n"
93 " (Cannot be used together with -n.)\n"
94 " -V Reports version and exits.\n"), progname
);
99 err_string(int err_code
)
101 static char *err_message
[XR_BAD_ERR_CODE
];
105 err_message
[XR_OK
] = _("no error");
106 err_message
[XR_BAD_MAGIC
] = _("bad magic number");
107 err_message
[XR_BAD_BLOCKSIZE
] = _("bad blocksize field");
108 err_message
[XR_BAD_BLOCKLOG
] = _("bad blocksize log field");
109 err_message
[XR_BAD_VERSION
] = _("bad or unsupported version");
110 err_message
[XR_BAD_INPROGRESS
] =
111 _("filesystem mkfs-in-progress bit set");
112 err_message
[XR_BAD_FS_SIZE_DATA
] =
113 _("inconsistent filesystem geometry information");
114 err_message
[XR_BAD_INO_SIZE_DATA
] =
115 _("bad inode size or inconsistent with number of inodes/block"),
116 err_message
[XR_BAD_SECT_SIZE_DATA
] = _("bad sector size");
117 err_message
[XR_AGF_GEO_MISMATCH
] =
118 _("AGF geometry info conflicts with filesystem geometry");
119 err_message
[XR_AGI_GEO_MISMATCH
] =
120 _("AGI geometry info conflicts with filesystem geometry");
121 err_message
[XR_SB_GEO_MISMATCH
] =
122 _("AG superblock geometry info conflicts with filesystem geometry");
123 err_message
[XR_EOF
] = _("attempted to perform I/O beyond EOF");
124 err_message
[XR_BAD_RT_GEO_DATA
] =
125 _("inconsistent filesystem geometry in realtime filesystem component");
126 err_message
[XR_BAD_INO_MAX_PCT
] =
127 _("maximum indicated percentage of inodes > 100%");
128 err_message
[XR_BAD_INO_ALIGN
] =
129 _("inconsistent inode alignment value");
130 err_message
[XR_INSUFF_SEC_SB
] =
131 _("not enough secondary superblocks with matching geometry");
132 err_message
[XR_BAD_SB_UNIT
] =
133 _("bad stripe unit in superblock");
134 err_message
[XR_BAD_SB_WIDTH
] =
135 _("bad stripe width in superblock");
136 err_message
[XR_BAD_SVN
] =
137 _("bad shared version number in superblock");
138 err_message
[XR_BAD_CRC
] =
139 _("bad CRC in superblock");
140 err_message
[XR_BAD_DIR_SIZE_DATA
] =
141 _("inconsistent directory geometry information");
142 err_message
[XR_BAD_LOG_GEOMETRY
] =
143 _("inconsistent log geometry information");
147 if (err_code
< XR_OK
|| err_code
>= XR_BAD_ERR_CODE
)
148 do_abort(_("bad error code - %d\n"), err_code
);
150 return(err_message
[err_code
]);
154 noval(char opt
, char *tbl
[], int idx
)
156 do_warn(_("-%c %s option cannot have a value\n"), opt
, tbl
[idx
]);
161 respec(char opt
, char *tbl
[], int idx
)
163 do_warn("-%c ", opt
);
165 do_warn("%s ", tbl
[idx
]);
166 do_warn(_("option respecified\n"));
171 unknown(char opt
, char *s
)
173 do_warn(_("unknown option -%c %s\n"), opt
, s
);
178 * sets only the global argument flags and variables
181 process_args(int argc
, char **argv
)
194 full_ino_ex_data
= 0;
203 report_interval
= PROG_RPT_DEFAULT
;
204 report_corrected
= false;
207 * XXX have to add suboption processing here
208 * attributes, quotas, nlinks, aligned_inos, sb_fbits
210 while ((c
= getopt(argc
, argv
, "c:o:fl:m:r:LnDvVdPet:")) != EOF
) {
220 switch (getsubopt(&p
, o_opts
, &val
)) {
223 noval('o', o_opts
, ASSUME_XFS
);
225 respec('o', o_opts
, ASSUME_XFS
);
230 _("-o ihash option has been removed and will be ignored\n"));
233 if (max_mem_specified
)
235 _("-o bhash option cannot be used with -m option\n"));
238 _("-o bhash requires a parameter\n"));
239 libxfs_bhash_size
= (int)strtol(val
, NULL
, 0);
240 bhash_option_used
= 1;
245 _("-o ag_stride requires a parameter\n"));
246 ag_stride
= (int)strtol(val
, NULL
, 0);
250 noval('o', o_opts
, FORCE_GEO
);
252 respec('o', o_opts
, FORCE_GEO
);
258 _("-o phase2_threads requires a parameter\n"));
259 phase2_threads
= (int)strtol(val
, NULL
, 0);
272 switch (getsubopt(&p
, c_opts
, &val
)) {
273 case CONVERT_LAZY_COUNT
:
276 _("-c lazycount requires a parameter\n"));
277 lazy_count
= (int)strtol(val
, NULL
, 0);
278 convert_lazy_count
= 1;
298 if (bhash_option_used
)
299 do_abort(_("-m option cannot be used with "
300 "-o bhash option\n"));
301 max_mem_specified
= strtol(optarg
, NULL
, 0);
316 printf(_("%s version %s\n"), progname
, VERSION
);
322 report_interval
= (int)strtol(optarg
, NULL
, 0);
325 report_corrected
= true;
332 if (argc
- optind
!= 1)
335 if ((fs_name
= argv
[optind
]) == NULL
)
338 if (report_corrected
&& no_modify
)
342 void __attribute__((noreturn
))
343 do_error(char const *msg
, ...)
347 fprintf(stderr
, _("\nfatal error -- "));
350 vfprintf(stderr
, msg
, args
);
357 * like do_error, only the error is internal, no system
358 * error so no oserror processing
360 void __attribute__((noreturn
))
361 do_abort(char const *msg
, ...)
366 vfprintf(stderr
, msg
, args
);
373 do_warn(char const *msg
, ...)
380 vfprintf(stderr
, msg
, args
);
387 do_log(char const *msg
, ...)
392 vfprintf(stderr
, msg
, args
);
397 calc_mkfs(xfs_mount_t
*mp
)
399 xfs_agblock_t fino_bno
;
402 do_inoalign
= mp
->m_sinoalign
;
405 * Pre-calculate the geometry of ag 0. We know what it looks like
406 * because we know what mkfs does: 2 allocation btree roots (by block
407 * and by size), the inode allocation btree root, the free inode
408 * allocation btree root (if enabled) and some number of blocks to
411 * Because the current shape of the btrees may differ from the current
412 * shape, we open code the mkfs freelist block count here. mkfs creates
413 * single level trees, so the calculation is pertty straight forward for
414 * the trees that use the AGFL.
416 bnobt_root
= howmany(4 * mp
->m_sb
.sb_sectsize
, mp
->m_sb
.sb_blocksize
);
417 bcntbt_root
= bnobt_root
+ 1;
418 inobt_root
= bnobt_root
+ 2;
419 fino_bno
= inobt_root
+ (2 * min(2, mp
->m_ag_maxlevels
)) + 1;
420 if (xfs_sb_version_hasfinobt(&mp
->m_sb
))
422 if (xfs_sb_version_hasrmapbt(&mp
->m_sb
)) {
423 fino_bno
+= min(2, mp
->m_rmap_maxlevels
); /* agfl blocks */
426 if (xfs_sb_version_hasreflink(&mp
->m_sb
))
430 * If the log is allocated in the first allocation group we need to
431 * add the number of blocks used by the log to the above calculation.
433 * This can happens with filesystems that only have a single
434 * allocation group, or very odd geometries created by old mkfs
435 * versions on very small filesystems.
437 if (mp
->m_sb
.sb_logstart
&&
438 XFS_FSB_TO_AGNO(mp
, mp
->m_sb
.sb_logstart
) == 0) {
441 * XXX(hch): verify that sb_logstart makes sense?
443 fino_bno
+= mp
->m_sb
.sb_logblocks
;
447 * ditto the location of the first inode chunks in the fs ('/')
449 if (xfs_sb_version_hasdalign(&mp
->m_sb
) && do_inoalign
) {
450 first_prealloc_ino
= XFS_AGB_TO_AGINO(mp
, roundup(fino_bno
,
452 } else if (xfs_sb_version_hasalign(&mp
->m_sb
) &&
453 mp
->m_sb
.sb_inoalignmt
> 1) {
454 first_prealloc_ino
= XFS_AGB_TO_AGINO(mp
,
456 mp
->m_sb
.sb_inoalignmt
));
458 first_prealloc_ino
= XFS_AGB_TO_AGINO(mp
, fino_bno
);
461 ASSERT(mp
->m_ialloc_blks
> 0);
463 if (mp
->m_ialloc_blks
> 1)
464 last_prealloc_ino
= first_prealloc_ino
+ XFS_INODES_PER_CHUNK
;
466 last_prealloc_ino
= XFS_AGB_TO_AGINO(mp
, fino_bno
+ 1);
469 * now the first 3 inodes in the system
471 if (mp
->m_sb
.sb_rootino
!= first_prealloc_ino
) {
473 _("sb root inode value %" PRIu64
" %sinconsistent with calculated value %u\n"),
475 (mp
->m_sb
.sb_rootino
== NULLFSINO
? "(NULLFSINO) ":""),
480 _("resetting superblock root inode pointer to %u\n"),
484 _("would reset superblock root inode pointer to %u\n"),
488 * just set the value -- safe since the superblock
489 * doesn't get flushed out if no_modify is set
491 mp
->m_sb
.sb_rootino
= first_prealloc_ino
;
494 if (mp
->m_sb
.sb_rbmino
!= first_prealloc_ino
+ 1) {
496 _("sb realtime bitmap inode %" PRIu64
" %sinconsistent with calculated value %u\n"),
498 (mp
->m_sb
.sb_rbmino
== NULLFSINO
? "(NULLFSINO) ":""),
499 first_prealloc_ino
+ 1);
503 _("resetting superblock realtime bitmap ino pointer to %u\n"),
504 first_prealloc_ino
+ 1);
507 _("would reset superblock realtime bitmap ino pointer to %u\n"),
508 first_prealloc_ino
+ 1);
511 * just set the value -- safe since the superblock
512 * doesn't get flushed out if no_modify is set
514 mp
->m_sb
.sb_rbmino
= first_prealloc_ino
+ 1;
517 if (mp
->m_sb
.sb_rsumino
!= first_prealloc_ino
+ 2) {
519 _("sb realtime summary inode %" PRIu64
" %sinconsistent with calculated value %u\n"),
521 (mp
->m_sb
.sb_rsumino
== NULLFSINO
? "(NULLFSINO) ":""),
522 first_prealloc_ino
+ 2);
526 _("resetting superblock realtime summary ino pointer to %u\n"),
527 first_prealloc_ino
+ 2);
530 _("would reset superblock realtime summary ino pointer to %u\n"),
531 first_prealloc_ino
+ 2);
534 * just set the value -- safe since the superblock
535 * doesn't get flushed out if no_modify is set
537 mp
->m_sb
.sb_rsumino
= first_prealloc_ino
+ 2;
543 * v5 superblock metadata track the LSN of last modification and thus require
544 * that the current LSN is always moving forward. The current LSN is reset if
545 * the log has been cleared, which puts the log behind parts of the filesystem
546 * on-disk and can disrupt log recovery.
548 * We have tracked the maximum LSN of every piece of metadata that has been read
549 * in via the read verifiers. Compare the max LSN with the log and if the log is
550 * behind, bump the cycle number and reformat the log.
554 struct xfs_mount
*mp
)
556 struct xlog
*log
= mp
->m_log
;
560 xfs_daddr_t logstart
;
561 xfs_daddr_t logblocks
;
564 if (!xfs_sb_version_hascrc(&mp
->m_sb
))
568 * If the log is ahead of the highest metadata LSN we've seen, we're
569 * safe and there's nothing to do.
571 max_cycle
= CYCLE_LSN(libxfs_max_lsn
);
572 max_block
= BLOCK_LSN(libxfs_max_lsn
);
573 if (max_cycle
< log
->l_curr_cycle
||
574 (max_cycle
== log
->l_curr_cycle
&& max_block
< log
->l_curr_block
))
578 * Going to the next cycle should be sufficient but we bump by a few
579 * counts to help cover any metadata LSNs we could have missed.
581 new_cycle
= max_cycle
+ 3;
582 logstart
= XFS_FSB_TO_DADDR(mp
, mp
->m_sb
.sb_logstart
);
583 logblocks
= XFS_FSB_TO_BB(mp
, mp
->m_sb
.sb_logblocks
);
584 logversion
= xfs_sb_version_haslogv2(&mp
->m_sb
) ? 2 : 1;
586 do_warn(_("Maximum metadata LSN (%d:%d) is ahead of log (%d:%d).\n"),
587 max_cycle
, max_block
, log
->l_curr_cycle
, log
->l_curr_block
);
590 do_warn(_("Would format log to cycle %d.\n"), new_cycle
);
594 do_warn(_("Format log to cycle %d.\n"), new_cycle
);
595 libxfs_log_clear(log
->l_dev
, NULL
, logstart
, logblocks
,
596 &mp
->m_sb
.sb_uuid
, logversion
, mp
->m_sb
.sb_logsunit
,
597 XLOG_FMT
, new_cycle
, true);
601 * mkfs increases the AG count for "multidisk" configurations, we want
602 * to target these for an increase in thread count. Hence check the superlock
603 * geometry information to determine if mkfs considered this a multidisk
607 is_multidisk_filesystem(
608 struct xfs_mount
*mp
)
610 struct xfs_sb
*sbp
= &mp
->m_sb
;
612 /* High agcount filesystems are always considered "multidisk" */
613 if (sbp
->sb_agcount
>= XFS_MULTIDISK_AGCOUNT
)
617 * If it doesn't have a sunit/swidth, mkfs didn't consider it a
618 * multi-disk array, so we don't either.
623 ASSERT(sbp
->sb_width
);
628 * if the sector size of the filesystem we are trying to repair is
629 * smaller than that of the underlying filesystem (i.e. we are repairing
630 * an image), the we have to turn off direct IO because we cannot do IO
631 * smaller than the host filesystem's sector size.
634 check_fs_vs_host_sectsize(
639 struct xfs_fsop_geom_v1 geom
= { 0 };
641 fd
= libxfs_device_to_fd(x
.ddev
);
643 if (ioctl(fd
, XFS_IOC_FSGEOMETRY_V1
, &geom
) < 0) {
644 do_log(_("Cannot get host filesystem geometry.\n"
645 "Repair may fail if there is a sector size mismatch between\n"
646 "the image and the host filesystem.\n"));
647 geom
.sectsize
= BBSIZE
;
650 if (sb
->sb_sectsize
< geom
.sectsize
) {
651 old_flags
= fcntl(fd
, F_GETFL
, 0);
652 if (fcntl(fd
, F_SETFL
, old_flags
& ~O_DIRECT
) < 0) {
654 "Sector size on host filesystem larger than image sector size.\n"
655 "Cannot turn off direct IO, so exiting.\n"));
662 main(int argc
, char **argv
)
664 xfs_mount_t
*temp_mp
;
669 struct xlog log
= {0};
674 progname
= basename(argv
[0]);
675 setlocale(LC_ALL
, "");
676 bindtextdomain(PACKAGE
, LOCALEDIR
);
678 dinode_bmbt_translation_init();
681 setbuf(stdout
, NULL
);
683 process_args(argc
, argv
);
686 msgbuf
= malloc(DURATION_BUF_SIZE
);
688 timestamp(PHASE_START
, 0, NULL
);
689 timestamp(PHASE_END
, 0, NULL
);
691 /* -f forces this, but let's be nice and autodetect it, as well. */
693 int fd
= libxfs_device_to_fd(x
.ddev
);
696 if (fstat(fd
, &statbuf
) < 0)
697 do_warn(_("%s: couldn't stat \"%s\"\n"),
699 else if (S_ISREG(statbuf
.st_mode
))
704 /* Best effort attempt to validate fs vs host sector size */
705 rval
= get_sb(&psb
, 0, XFS_MAX_SECTORSIZE
, 0);
707 check_fs_vs_host_sectsize(&psb
);
710 /* do phase1 to make sure we have a superblock */
712 timestamp(PHASE_END
, 1, NULL
);
714 if (no_modify
&& primary_sb_modified
) {
715 do_warn(_("Primary superblock would have been modified.\n"
716 "Cannot proceed further in no_modify mode.\n"
721 rval
= get_sb(&psb
, 0, XFS_MAX_SECTORSIZE
, 0);
723 do_warn(_("Primary superblock bad after phase 1!\n"
729 * Now that we have completely validated the superblock, geometry may
730 * have changed; re-check geometry vs the host filesystem geometry
733 check_fs_vs_host_sectsize(&psb
);
736 * Prepare the mount structure. Point the log reference to our local
737 * copy so it's available to the various phases. The log bits are
738 * initialized in phase 2.
740 memset(&xfs_m
, 0, sizeof(xfs_mount_t
));
741 mp
= libxfs_mount(&xfs_m
, &psb
, x
.ddev
, x
.logdev
, x
.rtdev
, 0);
745 _("%s: cannot repair this filesystem. Sorry.\n"),
751 /* Spit out function & line on these corruption macros */
753 mp
->m_flags
|= LIBXFS_MOUNT_WANT_CORRUPTED
;
756 * set XFS-independent status vars from the mount/sb structure
758 glob_agcount
= mp
->m_sb
.sb_agcount
;
760 chunks_pblock
= mp
->m_sb
.sb_inopblock
/ XFS_INODES_PER_CHUNK
;
761 max_symlink_blocks
= libxfs_symlink_blocks(mp
, XFS_SYMLINK_MAXLEN
);
762 inodes_per_cluster
= max(mp
->m_sb
.sb_inopblock
,
763 mp
->m_inode_cluster_size
>> mp
->m_sb
.sb_inodelog
);
766 * Automatic striding for high agcount filesystems.
768 * More AGs indicates that the filesystem is either large or can handle
769 * more IO parallelism. Either way, we should try to process multiple
770 * AGs at a time in such a configuration to try to saturate the
771 * underlying storage and speed the repair process. Only do this if
772 * prefetching is enabled.
774 * Given mkfs defaults for 16AGs for "multidisk" configurations, we want
775 * to target these for an increase in thread count. Hence a stride value
776 * of 15 is chosen to ensure we get at least 2 AGs being scanned at once
777 * on such filesystems.
779 * Limit the maximum thread count based on the available CPU power that
780 * is available. If we use too many threads, we might run out of memory
781 * and CPU power before we run out of IO concurrency. We limit to 8
782 * threads/CPU as this is enough threads to saturate a CPU on fast
783 * devices, yet few enough that it will saturate but won't overload slow
786 * Multidisk filesystems can handle more IO parallelism so we should try
787 * to process multiple AGs at a time in such a configuration to try to
788 * saturate the underlying storage and speed the repair process. Only do
789 * this if prefetching is enabled.
791 if (!ag_stride
&& do_prefetch
&& is_multidisk_filesystem(mp
)) {
793 * For small agcount multidisk systems, just double the
794 * parallelism. For larger AG count filesystems (32 and above)
795 * use more parallelism, and linearly increase the parallelism
796 * with the number of AGs.
798 ag_stride
= min(glob_agcount
, XFS_MULTIDISK_AGCOUNT
/ 2) - 1;
802 int max_threads
= platform_nproc() * 8;
804 thread_count
= (glob_agcount
+ ag_stride
- 1) / ag_stride
;
805 while (thread_count
> max_threads
) {
807 thread_count
= (glob_agcount
+ ag_stride
- 1) /
810 if (thread_count
> 0)
818 if (ag_stride
&& report_interval
) {
821 do_log(_(" - reporting progress in intervals of %s\n"),
822 duration(report_interval
, msgbuf
));
827 * Adjust libxfs cache sizes based on system memory,
828 * filesystem size and inode count.
830 * We'll set the cache size based on 3/4s the memory minus
831 * space used by the inode AVL tree and block usage map.
833 * Inode AVL tree space is approximately 4 bytes per inode,
834 * block usage map is currently 1 byte for 2 blocks.
836 * We assume most blocks will be inode clusters.
838 * Calculations are done in kilobyte units.
841 if (!bhash_option_used
|| max_mem_specified
) {
842 unsigned long mem_used
;
843 unsigned long max_mem
;
846 libxfs_bcache_purge();
847 cache_destroy(libxfs_bcache
);
849 mem_used
= (mp
->m_sb
.sb_icount
>> (10 - 2)) +
850 (mp
->m_sb
.sb_dblocks
>> (10 + 1)) +
851 50000; /* rough estimate of 50MB overhead */
852 max_mem
= max_mem_specified
? max_mem_specified
* 1024 :
853 libxfs_physmem() * 3 / 4;
855 if (getrlimit(RLIMIT_AS
, &rlim
) != -1 &&
856 rlim
.rlim_cur
!= RLIM_INFINITY
) {
857 rlim
.rlim_cur
= rlim
.rlim_max
;
858 setrlimit(RLIMIT_AS
, &rlim
);
859 /* use approximately 80% of rlimit to avoid overrun */
860 max_mem
= min(max_mem
, rlim
.rlim_cur
/ 1280);
862 max_mem
= min(max_mem
, (LONG_MAX
>> 10) + 1);
866 _(" - max_mem = %lu, icount = %" PRIu64
", imem = %" PRIu64
", dblock = %" PRIu64
", dmem = %" PRIu64
"\n"),
867 max_mem
, mp
->m_sb
.sb_icount
,
868 mp
->m_sb
.sb_icount
>> (10 - 2),
870 mp
->m_sb
.sb_dblocks
>> (10 + 1));
872 if (max_mem
<= mem_used
) {
873 if (max_mem_specified
) {
875 _("Required memory for repair is greater that the maximum specified\n"
876 "with the -m option. Please increase it to at least %lu.\n"),
880 _("Memory available for repair (%luMB) may not be sufficient.\n"
881 "At least %luMB is needed to repair this filesystem efficiently\n"
882 "If repair fails due to lack of memory, please\n"),
883 max_mem
/ 1024, mem_used
/ 1024);
886 _("turn prefetching off (-P) to reduce the memory footprint.\n"));
889 _("increase system RAM and/or swap space to at least %luMB.\n"),
890 mem_used
* 2 / 1024);
896 if (max_mem
>= (1 << 30))
898 libxfs_bhash_size
= max_mem
/ (HASH_CACHE_RATIO
*
899 (mp
->m_inode_cluster_size
>> 10));
900 if (libxfs_bhash_size
< 512)
901 libxfs_bhash_size
= 512;
904 do_log(_(" - block cache size set to %d entries\n"),
905 libxfs_bhash_size
* HASH_CACHE_RATIO
);
907 libxfs_bcache
= cache_init(0, libxfs_bhash_size
,
908 &libxfs_bcache_operations
);
912 * calculate what mkfs would do to this filesystem
917 * initialize block alloc map
924 /* initialize random globals now that we know the fs geometry */
925 inodes_per_block
= mp
->m_sb
.sb_inopblock
;
927 if (parse_sb_version(&mp
->m_sb
)) {
929 _("Found unsupported filesystem features. Exiting now.\n"));
933 /* make sure the per-ag freespace maps are ok so we can mount the fs */
934 phase2(mp
, phase2_threads
);
935 timestamp(PHASE_END
, 2, NULL
);
940 phase3(mp
, phase2_threads
);
941 timestamp(PHASE_END
, 3, NULL
);
944 timestamp(PHASE_END
, 4, NULL
);
947 printf(_("No modify flag set, skipping phase 5\n"));
951 timestamp(PHASE_END
, 5, NULL
);
954 * Done with the block usage maps, toss them...
959 if (!bad_ino_btree
) {
961 timestamp(PHASE_END
, 6, NULL
);
963 phase7(mp
, phase2_threads
);
964 timestamp(PHASE_END
, 7, NULL
);
967 _("Inode allocation btrees are too corrupted, skipping phases 6 and 7\n"));
970 if (lost_quotas
&& !have_uquotino
&& !have_gquotino
&& !have_pquotino
) {
973 _("Warning: no quota inodes were found. Quotas disabled.\n"));
976 _("Warning: no quota inodes were found. Quotas would be disabled.\n"));
978 } else if (lost_quotas
) {
981 _("Warning: quota inodes were cleared. Quotas disabled.\n"));
984 _("Warning: quota inodes would be cleared. Quotas would be disabled.\n"));
990 _("Warning: user quota information was cleared.\n"
991 "User quotas can not be enforced until limit information is recreated.\n"));
994 _("Warning: user quota information would be cleared.\n"
995 "User quotas could not be enforced until limit information was recreated.\n"));
1002 _("Warning: group quota information was cleared.\n"
1003 "Group quotas can not be enforced until limit information is recreated.\n"));
1006 _("Warning: group quota information would be cleared.\n"
1007 "Group quotas could not be enforced until limit information was recreated.\n"));
1011 if (lost_pquotino
) {
1014 _("Warning: project quota information was cleared.\n"
1015 "Project quotas can not be enforced until limit information is recreated.\n"));
1018 _("Warning: project quota information would be cleared.\n"
1019 "Project quotas could not be enforced until limit information was recreated.\n"));
1024 if (ag_stride
&& report_interval
)
1025 stop_progress_rpt();
1029 * Warn if the current LSN is problematic and the log requires a
1032 format_log_max_lsn(mp
);
1035 _("No modify flag set, skipping filesystem flush and exiting.\n"));
1045 * Clear the quota flags if they're on.
1047 sbp
= libxfs_getsb(mp
, 0);
1049 do_error(_("couldn't get superblock\n"));
1051 dsb
= XFS_BUF_TO_SBP(sbp
);
1053 if (be16_to_cpu(dsb
->sb_qflags
) & XFS_ALL_QUOTA_CHKD
) {
1054 do_warn(_("Note - quota info will be regenerated on next "
1056 dsb
->sb_qflags
&= cpu_to_be16(~XFS_ALL_QUOTA_CHKD
);
1061 _("Note - stripe unit (%d) and width (%d) were copied from a backup superblock.\n"
1062 "Please reset with mount -o sunit=<value>,swidth=<value> if necessary\n"),
1063 be32_to_cpu(dsb
->sb_unit
), be32_to_cpu(dsb
->sb_width
));
1066 libxfs_writebuf(sbp
, 0);
1069 * Done. Flush all cached buffers and inodes first to ensure all
1070 * verifiers are run (where we discover the max metadata LSN), reformat
1071 * the log if necessary and unmount.
1073 libxfs_bcache_flush();
1074 format_log_max_lsn(mp
);
1078 libxfs_device_close(x
.rtdev
);
1079 if (x
.logdev
&& x
.logdev
!= x
.ddev
)
1080 libxfs_device_close(x
.logdev
);
1081 libxfs_device_close(x
.ddev
);
1086 do_log(_("done\n"));
1088 if (dangerously
&& !no_modify
)
1090 _("Repair of readonly mount complete. Immediate reboot encouraged.\n"));
1096 if (fs_is_dirty
&& report_corrected
)