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"
12 #include "libfrog/avl64.h"
18 #include "err_protos.h"
25 #include "libfrog/fsgeom.h"
28 * option tables for getsubopt calls
32 * -o: user-supplied override options
44 static char *o_opts
[] = {
45 [ASSUME_XFS
] = "assume_xfs",
46 [IHASH_SIZE
] = "ihash",
47 [BHASH_SIZE
] = "bhash",
48 [AG_STRIDE
] = "ag_stride",
49 [FORCE_GEO
] = "force_geometry",
50 [PHASE2_THREADS
] = "phase2_threads",
55 * -c: conversion options
58 CONVERT_LAZY_COUNT
= 0,
62 static char *c_opts
[] = {
63 [CONVERT_LAZY_COUNT
] = "lazycount",
68 static int bhash_option_used
;
69 static long max_mem_specified
; /* in megabytes */
70 static int phase2_threads
= 32;
71 static bool report_corrected
;
77 "Usage: %s [options] device\n"
80 " -f The device is a file\n"
81 " -L Force log zeroing. Do this as a last resort.\n"
82 " -l logdev Specifies the device where the external log resides.\n"
83 " -m maxmem Maximum amount of memory to be used in megabytes.\n"
84 " -n No modify mode, just checks the filesystem for damage.\n"
85 " (Cannot be used together with -e.)\n"
86 " -P Disables prefetching.\n"
87 " -r rtdev Specifies the device where the realtime section resides.\n"
88 " -v Verbose output.\n"
89 " -c subopts Change filesystem parameters - use xfs_admin.\n"
90 " -o subopts Override default behaviour, refer to man page.\n"
91 " -t interval Reporting interval in seconds.\n"
92 " -d Repair dangerously.\n"
93 " -e Exit with a non-zero code if any errors were repaired.\n"
94 " (Cannot be used together with -n.)\n"
95 " -V Reports version and exits.\n"), progname
);
100 err_string(int err_code
)
102 static char *err_message
[XR_BAD_ERR_CODE
];
106 err_message
[XR_OK
] = _("no error");
107 err_message
[XR_BAD_MAGIC
] = _("bad magic number");
108 err_message
[XR_BAD_BLOCKSIZE
] = _("bad blocksize field");
109 err_message
[XR_BAD_BLOCKLOG
] = _("bad blocksize log field");
110 err_message
[XR_BAD_VERSION
] = _("bad or unsupported version");
111 err_message
[XR_BAD_INPROGRESS
] =
112 _("filesystem mkfs-in-progress bit set");
113 err_message
[XR_BAD_FS_SIZE_DATA
] =
114 _("inconsistent filesystem geometry information");
115 err_message
[XR_BAD_INO_SIZE_DATA
] =
116 _("bad inode size or inconsistent with number of inodes/block"),
117 err_message
[XR_BAD_SECT_SIZE_DATA
] = _("bad sector size");
118 err_message
[XR_AGF_GEO_MISMATCH
] =
119 _("AGF geometry info conflicts with filesystem geometry");
120 err_message
[XR_AGI_GEO_MISMATCH
] =
121 _("AGI geometry info conflicts with filesystem geometry");
122 err_message
[XR_SB_GEO_MISMATCH
] =
123 _("AG superblock geometry info conflicts with filesystem geometry");
124 err_message
[XR_EOF
] = _("attempted to perform I/O beyond EOF");
125 err_message
[XR_BAD_RT_GEO_DATA
] =
126 _("inconsistent filesystem geometry in realtime filesystem component");
127 err_message
[XR_BAD_INO_MAX_PCT
] =
128 _("maximum indicated percentage of inodes > 100%");
129 err_message
[XR_BAD_INO_ALIGN
] =
130 _("inconsistent inode alignment value");
131 err_message
[XR_INSUFF_SEC_SB
] =
132 _("not enough secondary superblocks with matching geometry");
133 err_message
[XR_BAD_SB_UNIT
] =
134 _("bad stripe unit in superblock");
135 err_message
[XR_BAD_SB_WIDTH
] =
136 _("bad stripe width in superblock");
137 err_message
[XR_BAD_SVN
] =
138 _("bad shared version number in superblock");
139 err_message
[XR_BAD_CRC
] =
140 _("bad CRC in superblock");
141 err_message
[XR_BAD_DIR_SIZE_DATA
] =
142 _("inconsistent directory geometry information");
143 err_message
[XR_BAD_LOG_GEOMETRY
] =
144 _("inconsistent log geometry information");
148 if (err_code
< XR_OK
|| err_code
>= XR_BAD_ERR_CODE
)
149 do_abort(_("bad error code - %d\n"), err_code
);
151 return(err_message
[err_code
]);
155 noval(char opt
, char *tbl
[], int idx
)
157 do_warn(_("-%c %s option cannot have a value\n"), opt
, tbl
[idx
]);
162 respec(char opt
, char *tbl
[], int idx
)
164 do_warn("-%c ", opt
);
166 do_warn("%s ", tbl
[idx
]);
167 do_warn(_("option respecified\n"));
172 unknown(char opt
, char *s
)
174 do_warn(_("unknown option -%c %s\n"), opt
, s
);
179 * sets only the global argument flags and variables
182 process_args(int argc
, char **argv
)
195 full_ino_ex_data
= 0;
204 report_interval
= PROG_RPT_DEFAULT
;
205 report_corrected
= false;
208 * XXX have to add suboption processing here
209 * attributes, quotas, nlinks, aligned_inos, sb_fbits
211 while ((c
= getopt(argc
, argv
, "c:o:fl:m:r:LnDvVdPet:")) != EOF
) {
221 switch (getsubopt(&p
, o_opts
, &val
)) {
224 noval('o', o_opts
, ASSUME_XFS
);
226 respec('o', o_opts
, ASSUME_XFS
);
231 _("-o ihash option has been removed and will be ignored\n"));
234 if (max_mem_specified
)
236 _("-o bhash option cannot be used with -m option\n"));
239 _("-o bhash requires a parameter\n"));
240 libxfs_bhash_size
= (int)strtol(val
, NULL
, 0);
241 bhash_option_used
= 1;
246 _("-o ag_stride requires a parameter\n"));
247 ag_stride
= (int)strtol(val
, NULL
, 0);
251 noval('o', o_opts
, FORCE_GEO
);
253 respec('o', o_opts
, FORCE_GEO
);
259 _("-o phase2_threads requires a parameter\n"));
260 phase2_threads
= (int)strtol(val
, NULL
, 0);
273 switch (getsubopt(&p
, c_opts
, &val
)) {
274 case CONVERT_LAZY_COUNT
:
277 _("-c lazycount requires a parameter\n"));
278 lazy_count
= (int)strtol(val
, NULL
, 0);
279 convert_lazy_count
= 1;
299 if (bhash_option_used
)
300 do_abort(_("-m option cannot be used with "
301 "-o bhash option\n"));
302 max_mem_specified
= strtol(optarg
, NULL
, 0);
317 printf(_("%s version %s\n"), progname
, VERSION
);
323 report_interval
= (int)strtol(optarg
, NULL
, 0);
326 report_corrected
= true;
333 if (argc
- optind
!= 1)
336 if ((fs_name
= argv
[optind
]) == NULL
)
339 if (report_corrected
&& no_modify
)
343 void __attribute__((noreturn
))
344 do_error(char const *msg
, ...)
348 fprintf(stderr
, _("\nfatal error -- "));
351 vfprintf(stderr
, msg
, args
);
358 * like do_error, only the error is internal, no system
359 * error so no oserror processing
361 void __attribute__((noreturn
))
362 do_abort(char const *msg
, ...)
367 vfprintf(stderr
, msg
, args
);
374 do_warn(char const *msg
, ...)
381 vfprintf(stderr
, msg
, args
);
388 do_log(char const *msg
, ...)
393 vfprintf(stderr
, msg
, args
);
398 calc_mkfs(xfs_mount_t
*mp
)
400 xfs_agblock_t fino_bno
;
403 do_inoalign
= M_IGEO(mp
)->ialloc_align
;
406 * Pre-calculate the geometry of ag 0. We know what it looks like
407 * because we know what mkfs does: 2 allocation btree roots (by block
408 * and by size), the inode allocation btree root, the free inode
409 * allocation btree root (if enabled) and some number of blocks to
412 * Because the current shape of the btrees may differ from the current
413 * shape, we open code the mkfs freelist block count here. mkfs creates
414 * single level trees, so the calculation is pertty straight forward for
415 * the trees that use the AGFL.
417 bnobt_root
= howmany(4 * mp
->m_sb
.sb_sectsize
, mp
->m_sb
.sb_blocksize
);
418 bcntbt_root
= bnobt_root
+ 1;
419 inobt_root
= bnobt_root
+ 2;
420 fino_bno
= inobt_root
+ (2 * min(2, mp
->m_ag_maxlevels
)) + 1;
421 if (xfs_sb_version_hasfinobt(&mp
->m_sb
))
423 if (xfs_sb_version_hasrmapbt(&mp
->m_sb
)) {
424 fino_bno
+= min(2, mp
->m_rmap_maxlevels
); /* agfl blocks */
427 if (xfs_sb_version_hasreflink(&mp
->m_sb
))
431 * If the log is allocated in the first allocation group we need to
432 * add the number of blocks used by the log to the above calculation.
434 * This can happens with filesystems that only have a single
435 * allocation group, or very odd geometries created by old mkfs
436 * versions on very small filesystems.
438 if (mp
->m_sb
.sb_logstart
&&
439 XFS_FSB_TO_AGNO(mp
, mp
->m_sb
.sb_logstart
) == 0) {
442 * XXX(hch): verify that sb_logstart makes sense?
444 fino_bno
+= mp
->m_sb
.sb_logblocks
;
448 * ditto the location of the first inode chunks in the fs ('/')
450 if (xfs_sb_version_hasdalign(&mp
->m_sb
) && do_inoalign
) {
451 first_prealloc_ino
= XFS_AGB_TO_AGINO(mp
, roundup(fino_bno
,
453 } else if (xfs_sb_version_hasalign(&mp
->m_sb
) &&
454 mp
->m_sb
.sb_inoalignmt
> 1) {
455 first_prealloc_ino
= XFS_AGB_TO_AGINO(mp
,
457 mp
->m_sb
.sb_inoalignmt
));
459 first_prealloc_ino
= XFS_AGB_TO_AGINO(mp
, fino_bno
);
462 ASSERT(M_IGEO(mp
)->ialloc_blks
> 0);
464 if (M_IGEO(mp
)->ialloc_blks
> 1)
465 last_prealloc_ino
= first_prealloc_ino
+ XFS_INODES_PER_CHUNK
;
467 last_prealloc_ino
= XFS_AGB_TO_AGINO(mp
, fino_bno
+ 1);
470 * now the first 3 inodes in the system
472 if (mp
->m_sb
.sb_rootino
!= first_prealloc_ino
) {
474 _("sb root inode value %" PRIu64
" %sinconsistent with calculated value %u\n"),
476 (mp
->m_sb
.sb_rootino
== NULLFSINO
? "(NULLFSINO) ":""),
481 _("resetting superblock root inode pointer to %u\n"),
485 _("would reset superblock root inode pointer to %u\n"),
489 * just set the value -- safe since the superblock
490 * doesn't get flushed out if no_modify is set
492 mp
->m_sb
.sb_rootino
= first_prealloc_ino
;
495 if (mp
->m_sb
.sb_rbmino
!= first_prealloc_ino
+ 1) {
497 _("sb realtime bitmap inode %" PRIu64
" %sinconsistent with calculated value %u\n"),
499 (mp
->m_sb
.sb_rbmino
== NULLFSINO
? "(NULLFSINO) ":""),
500 first_prealloc_ino
+ 1);
504 _("resetting superblock realtime bitmap ino pointer to %u\n"),
505 first_prealloc_ino
+ 1);
508 _("would reset superblock realtime bitmap ino pointer to %u\n"),
509 first_prealloc_ino
+ 1);
512 * just set the value -- safe since the superblock
513 * doesn't get flushed out if no_modify is set
515 mp
->m_sb
.sb_rbmino
= first_prealloc_ino
+ 1;
518 if (mp
->m_sb
.sb_rsumino
!= first_prealloc_ino
+ 2) {
520 _("sb realtime summary inode %" PRIu64
" %sinconsistent with calculated value %u\n"),
522 (mp
->m_sb
.sb_rsumino
== NULLFSINO
? "(NULLFSINO) ":""),
523 first_prealloc_ino
+ 2);
527 _("resetting superblock realtime summary ino pointer to %u\n"),
528 first_prealloc_ino
+ 2);
531 _("would reset superblock realtime summary ino pointer to %u\n"),
532 first_prealloc_ino
+ 2);
535 * just set the value -- safe since the superblock
536 * doesn't get flushed out if no_modify is set
538 mp
->m_sb
.sb_rsumino
= first_prealloc_ino
+ 2;
544 * v5 superblock metadata track the LSN of last modification and thus require
545 * that the current LSN is always moving forward. The current LSN is reset if
546 * the log has been cleared, which puts the log behind parts of the filesystem
547 * on-disk and can disrupt log recovery.
549 * We have tracked the maximum LSN of every piece of metadata that has been read
550 * in via the read verifiers. Compare the max LSN with the log and if the log is
551 * behind, bump the cycle number and reformat the log.
555 struct xfs_mount
*mp
)
557 struct xlog
*log
= mp
->m_log
;
561 xfs_daddr_t logstart
;
562 xfs_daddr_t logblocks
;
565 if (!xfs_sb_version_hascrc(&mp
->m_sb
))
569 * If the log is ahead of the highest metadata LSN we've seen, we're
570 * safe and there's nothing to do.
572 max_cycle
= CYCLE_LSN(libxfs_max_lsn
);
573 max_block
= BLOCK_LSN(libxfs_max_lsn
);
574 if (max_cycle
< log
->l_curr_cycle
||
575 (max_cycle
== log
->l_curr_cycle
&& max_block
< log
->l_curr_block
))
579 * Going to the next cycle should be sufficient but we bump by a few
580 * counts to help cover any metadata LSNs we could have missed.
582 new_cycle
= max_cycle
+ 3;
583 logstart
= XFS_FSB_TO_DADDR(mp
, mp
->m_sb
.sb_logstart
);
584 logblocks
= XFS_FSB_TO_BB(mp
, mp
->m_sb
.sb_logblocks
);
585 logversion
= xfs_sb_version_haslogv2(&mp
->m_sb
) ? 2 : 1;
587 do_warn(_("Maximum metadata LSN (%d:%d) is ahead of log (%d:%d).\n"),
588 max_cycle
, max_block
, log
->l_curr_cycle
, log
->l_curr_block
);
591 do_warn(_("Would format log to cycle %d.\n"), new_cycle
);
595 do_warn(_("Format log to cycle %d.\n"), new_cycle
);
596 libxfs_log_clear(log
->l_dev
, NULL
, logstart
, logblocks
,
597 &mp
->m_sb
.sb_uuid
, logversion
, mp
->m_sb
.sb_logsunit
,
598 XLOG_FMT
, new_cycle
, true);
602 * mkfs increases the AG count for "multidisk" configurations, we want
603 * to target these for an increase in thread count. Hence check the superlock
604 * geometry information to determine if mkfs considered this a multidisk
608 is_multidisk_filesystem(
609 struct xfs_mount
*mp
)
611 struct xfs_sb
*sbp
= &mp
->m_sb
;
613 /* High agcount filesystems are always considered "multidisk" */
614 if (sbp
->sb_agcount
>= XFS_MULTIDISK_AGCOUNT
)
618 * If it doesn't have a sunit/swidth, mkfs didn't consider it a
619 * multi-disk array, so we don't either.
624 ASSERT(sbp
->sb_width
);
629 * if the sector size of the filesystem we are trying to repair is
630 * smaller than that of the underlying filesystem (i.e. we are repairing
631 * an image), the we have to turn off direct IO because we cannot do IO
632 * smaller than the host filesystem's sector size.
635 check_fs_vs_host_sectsize(
640 struct xfs_fsop_geom geom
= { 0 };
642 fd
= libxfs_device_to_fd(x
.ddev
);
644 ret
= xfrog_geometry(fd
, &geom
);
646 do_log(_("Cannot get host filesystem geometry.\n"
647 "Repair may fail if there is a sector size mismatch between\n"
648 "the image and the host filesystem.\n"));
649 geom
.sectsize
= BBSIZE
;
652 if (sb
->sb_sectsize
< geom
.sectsize
) {
653 old_flags
= fcntl(fd
, F_GETFL
, 0);
654 if (fcntl(fd
, F_SETFL
, old_flags
& ~O_DIRECT
) < 0) {
656 "Sector size on host filesystem larger than image sector size.\n"
657 "Cannot turn off direct IO, so exiting.\n"));
664 main(int argc
, char **argv
)
666 xfs_mount_t
*temp_mp
;
671 struct xlog log
= {0};
675 struct xfs_ino_geometry
*igeo
;
677 progname
= basename(argv
[0]);
678 setlocale(LC_ALL
, "");
679 bindtextdomain(PACKAGE
, LOCALEDIR
);
681 dinode_bmbt_translation_init();
684 setbuf(stdout
, NULL
);
686 process_args(argc
, argv
);
689 msgbuf
= malloc(DURATION_BUF_SIZE
);
691 timestamp(PHASE_START
, 0, NULL
);
692 timestamp(PHASE_END
, 0, NULL
);
694 /* -f forces this, but let's be nice and autodetect it, as well. */
696 int fd
= libxfs_device_to_fd(x
.ddev
);
699 if (fstat(fd
, &statbuf
) < 0)
700 do_warn(_("%s: couldn't stat \"%s\"\n"),
702 else if (S_ISREG(statbuf
.st_mode
))
707 /* Best effort attempt to validate fs vs host sector size */
708 rval
= get_sb(&psb
, 0, XFS_MAX_SECTORSIZE
, 0);
710 check_fs_vs_host_sectsize(&psb
);
713 /* do phase1 to make sure we have a superblock */
715 timestamp(PHASE_END
, 1, NULL
);
717 if (no_modify
&& primary_sb_modified
) {
718 do_warn(_("Primary superblock would have been modified.\n"
719 "Cannot proceed further in no_modify mode.\n"
724 rval
= get_sb(&psb
, 0, XFS_MAX_SECTORSIZE
, 0);
726 do_warn(_("Primary superblock bad after phase 1!\n"
732 * Now that we have completely validated the superblock, geometry may
733 * have changed; re-check geometry vs the host filesystem geometry
736 check_fs_vs_host_sectsize(&psb
);
739 * Prepare the mount structure. Point the log reference to our local
740 * copy so it's available to the various phases. The log bits are
741 * initialized in phase 2.
743 memset(&xfs_m
, 0, sizeof(xfs_mount_t
));
744 mp
= libxfs_mount(&xfs_m
, &psb
, x
.ddev
, x
.logdev
, x
.rtdev
, 0);
748 _("%s: cannot repair this filesystem. Sorry.\n"),
755 /* Spit out function & line on these corruption macros */
757 mp
->m_flags
|= LIBXFS_MOUNT_WANT_CORRUPTED
;
760 * set XFS-independent status vars from the mount/sb structure
762 glob_agcount
= mp
->m_sb
.sb_agcount
;
764 chunks_pblock
= mp
->m_sb
.sb_inopblock
/ XFS_INODES_PER_CHUNK
;
765 max_symlink_blocks
= libxfs_symlink_blocks(mp
, XFS_SYMLINK_MAXLEN
);
766 inodes_per_cluster
= max(mp
->m_sb
.sb_inopblock
,
767 igeo
->inode_cluster_size
>> mp
->m_sb
.sb_inodelog
);
770 * Automatic striding for high agcount filesystems.
772 * More AGs indicates that the filesystem is either large or can handle
773 * more IO parallelism. Either way, we should try to process multiple
774 * AGs at a time in such a configuration to try to saturate the
775 * underlying storage and speed the repair process. Only do this if
776 * prefetching is enabled.
778 * Given mkfs defaults for 16AGs for "multidisk" configurations, we want
779 * to target these for an increase in thread count. Hence a stride value
780 * of 15 is chosen to ensure we get at least 2 AGs being scanned at once
781 * on such filesystems.
783 * Limit the maximum thread count based on the available CPU power that
784 * is available. If we use too many threads, we might run out of memory
785 * and CPU power before we run out of IO concurrency. We limit to 8
786 * threads/CPU as this is enough threads to saturate a CPU on fast
787 * devices, yet few enough that it will saturate but won't overload slow
790 * Multidisk filesystems can handle more IO parallelism so we should try
791 * to process multiple AGs at a time in such a configuration to try to
792 * saturate the underlying storage and speed the repair process. Only do
793 * this if prefetching is enabled.
795 if (!ag_stride
&& do_prefetch
&& is_multidisk_filesystem(mp
)) {
797 * For small agcount multidisk systems, just double the
798 * parallelism. For larger AG count filesystems (32 and above)
799 * use more parallelism, and linearly increase the parallelism
800 * with the number of AGs.
802 ag_stride
= min(glob_agcount
, XFS_MULTIDISK_AGCOUNT
/ 2) - 1;
806 int max_threads
= platform_nproc() * 8;
808 thread_count
= (glob_agcount
+ ag_stride
- 1) / ag_stride
;
809 while (thread_count
> max_threads
) {
811 thread_count
= (glob_agcount
+ ag_stride
- 1) /
814 if (thread_count
> 0)
822 if (ag_stride
&& report_interval
) {
825 do_log(_(" - reporting progress in intervals of %s\n"),
826 duration(report_interval
, msgbuf
));
831 * Adjust libxfs cache sizes based on system memory,
832 * filesystem size and inode count.
834 * We'll set the cache size based on 3/4s the memory minus
835 * space used by the inode AVL tree and block usage map.
837 * Inode AVL tree space is approximately 4 bytes per inode,
838 * block usage map is currently 1 byte for 2 blocks.
840 * We assume most blocks will be inode clusters.
842 * Calculations are done in kilobyte units.
845 if (!bhash_option_used
|| max_mem_specified
) {
846 unsigned long mem_used
;
847 unsigned long max_mem
;
850 libxfs_bcache_purge();
851 cache_destroy(libxfs_bcache
);
853 mem_used
= (mp
->m_sb
.sb_icount
>> (10 - 2)) +
854 (mp
->m_sb
.sb_dblocks
>> (10 + 1)) +
855 50000; /* rough estimate of 50MB overhead */
856 max_mem
= max_mem_specified
? max_mem_specified
* 1024 :
857 libxfs_physmem() * 3 / 4;
859 if (getrlimit(RLIMIT_AS
, &rlim
) != -1 &&
860 rlim
.rlim_cur
!= RLIM_INFINITY
) {
861 rlim
.rlim_cur
= rlim
.rlim_max
;
862 setrlimit(RLIMIT_AS
, &rlim
);
863 /* use approximately 80% of rlimit to avoid overrun */
864 max_mem
= min(max_mem
, rlim
.rlim_cur
/ 1280);
866 max_mem
= min(max_mem
, (LONG_MAX
>> 10) + 1);
870 _(" - max_mem = %lu, icount = %" PRIu64
", imem = %" PRIu64
", dblock = %" PRIu64
", dmem = %" PRIu64
"\n"),
871 max_mem
, mp
->m_sb
.sb_icount
,
872 mp
->m_sb
.sb_icount
>> (10 - 2),
874 mp
->m_sb
.sb_dblocks
>> (10 + 1));
876 if (max_mem
<= mem_used
) {
877 if (max_mem_specified
) {
879 _("Required memory for repair is greater that the maximum specified\n"
880 "with the -m option. Please increase it to at least %lu.\n"),
884 _("Memory available for repair (%luMB) may not be sufficient.\n"
885 "At least %luMB is needed to repair this filesystem efficiently\n"
886 "If repair fails due to lack of memory, please\n"),
887 max_mem
/ 1024, mem_used
/ 1024);
890 _("turn prefetching off (-P) to reduce the memory footprint.\n"));
893 _("increase system RAM and/or swap space to at least %luMB.\n"),
894 mem_used
* 2 / 1024);
900 if (max_mem
>= (1 << 30))
902 libxfs_bhash_size
= max_mem
/ (HASH_CACHE_RATIO
*
903 (igeo
->inode_cluster_size
>> 10));
904 if (libxfs_bhash_size
< 512)
905 libxfs_bhash_size
= 512;
908 do_log(_(" - block cache size set to %d entries\n"),
909 libxfs_bhash_size
* HASH_CACHE_RATIO
);
911 libxfs_bcache
= cache_init(0, libxfs_bhash_size
,
912 &libxfs_bcache_operations
);
916 * calculate what mkfs would do to this filesystem
921 * initialize block alloc map
928 /* initialize random globals now that we know the fs geometry */
929 inodes_per_block
= mp
->m_sb
.sb_inopblock
;
931 if (parse_sb_version(&mp
->m_sb
)) {
933 _("Found unsupported filesystem features. Exiting now.\n"));
937 /* make sure the per-ag freespace maps are ok so we can mount the fs */
938 phase2(mp
, phase2_threads
);
939 timestamp(PHASE_END
, 2, NULL
);
944 phase3(mp
, phase2_threads
);
945 timestamp(PHASE_END
, 3, NULL
);
948 timestamp(PHASE_END
, 4, NULL
);
951 printf(_("No modify flag set, skipping phase 5\n"));
955 timestamp(PHASE_END
, 5, NULL
);
958 * Done with the block usage maps, toss them...
963 if (!bad_ino_btree
) {
965 timestamp(PHASE_END
, 6, NULL
);
967 phase7(mp
, phase2_threads
);
968 timestamp(PHASE_END
, 7, NULL
);
971 _("Inode allocation btrees are too corrupted, skipping phases 6 and 7\n"));
974 if (lost_quotas
&& !have_uquotino
&& !have_gquotino
&& !have_pquotino
) {
977 _("Warning: no quota inodes were found. Quotas disabled.\n"));
980 _("Warning: no quota inodes were found. Quotas would be disabled.\n"));
982 } else if (lost_quotas
) {
985 _("Warning: quota inodes were cleared. Quotas disabled.\n"));
988 _("Warning: quota inodes would be cleared. Quotas would be disabled.\n"));
994 _("Warning: user quota information was cleared.\n"
995 "User quotas can not be enforced until limit information is recreated.\n"));
998 _("Warning: user quota information would be cleared.\n"
999 "User quotas could not be enforced until limit information was recreated.\n"));
1003 if (lost_gquotino
) {
1006 _("Warning: group quota information was cleared.\n"
1007 "Group quotas can not be enforced until limit information is recreated.\n"));
1010 _("Warning: group quota information would be cleared.\n"
1011 "Group quotas could not be enforced until limit information was recreated.\n"));
1015 if (lost_pquotino
) {
1018 _("Warning: project quota information was cleared.\n"
1019 "Project quotas can not be enforced until limit information is recreated.\n"));
1022 _("Warning: project quota information would be cleared.\n"
1023 "Project quotas could not be enforced until limit information was recreated.\n"));
1028 if (ag_stride
&& report_interval
)
1029 stop_progress_rpt();
1033 * Warn if the current LSN is problematic and the log requires a
1036 format_log_max_lsn(mp
);
1039 _("No modify flag set, skipping filesystem flush and exiting.\n"));
1049 * Clear the quota flags if they're on.
1051 sbp
= libxfs_getsb(mp
);
1053 do_error(_("couldn't get superblock\n"));
1055 dsb
= XFS_BUF_TO_SBP(sbp
);
1057 if (be16_to_cpu(dsb
->sb_qflags
) & XFS_ALL_QUOTA_CHKD
) {
1058 do_warn(_("Note - quota info will be regenerated on next "
1060 dsb
->sb_qflags
&= cpu_to_be16(~XFS_ALL_QUOTA_CHKD
);
1065 _("Note - stripe unit (%d) and width (%d) were copied from a backup superblock.\n"
1066 "Please reset with mount -o sunit=<value>,swidth=<value> if necessary\n"),
1067 be32_to_cpu(dsb
->sb_unit
), be32_to_cpu(dsb
->sb_width
));
1070 libxfs_writebuf(sbp
, 0);
1073 * Done. Flush all cached buffers and inodes first to ensure all
1074 * verifiers are run (where we discover the max metadata LSN), reformat
1075 * the log if necessary and unmount.
1077 libxfs_bcache_flush();
1078 format_log_max_lsn(mp
);
1082 libxfs_device_close(x
.rtdev
);
1083 if (x
.logdev
&& x
.logdev
!= x
.ddev
)
1084 libxfs_device_close(x
.logdev
);
1085 libxfs_device_close(x
.ddev
);
1090 do_log(_("done\n"));
1092 if (dangerously
&& !no_modify
)
1094 _("Repair of readonly mount complete. Immediate reboot encouraged.\n"));
1100 if (fs_is_dirty
&& report_corrected
)