]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - e2fsck/super.c
e2fsck: adjust quota counters when clearing orphaned inodes
[thirdparty/e2fsprogs.git] / e2fsck / super.c
1 /*
2 * e2fsck.c - superblock checks
3 *
4 * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
10 */
11
12 #include "config.h"
13 #ifdef HAVE_ERRNO_H
14 #include <errno.h>
15 #endif
16
17 #ifndef EXT2_SKIP_UUID
18 #include "uuid/uuid.h"
19 #endif
20 #include "e2fsck.h"
21 #include "problem.h"
22
23 #define MIN_CHECK 1
24 #define MAX_CHECK 2
25 #define LOG2_CHECK 4
26
27 static void check_super_value(e2fsck_t ctx, const char *descr,
28 unsigned long value, int flags,
29 unsigned long min_val, unsigned long max_val)
30 {
31 struct problem_context pctx;
32
33 if ((flags & MIN_CHECK && value < min_val) ||
34 (flags & MAX_CHECK && value > max_val) ||
35 (flags & LOG2_CHECK && (value & (value - 1)) != 0)) {
36 clear_problem_context(&pctx);
37 pctx.num = value;
38 pctx.str = descr;
39 fix_problem(ctx, PR_0_MISC_CORRUPT_SUPER, &pctx);
40 ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
41 }
42 }
43
44 static void check_super_value64(e2fsck_t ctx, const char *descr,
45 __u64 value, int flags,
46 __u64 min_val, __u64 max_val)
47 {
48 struct problem_context pctx;
49
50 if ((flags & MIN_CHECK && value < min_val) ||
51 (flags & MAX_CHECK && value > max_val) ||
52 (flags & LOG2_CHECK && (value & (value - 1)) != 0)) {
53 clear_problem_context(&pctx);
54 pctx.num = value;
55 pctx.str = descr;
56 fix_problem(ctx, PR_0_MISC_CORRUPT_SUPER, &pctx);
57 ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
58 }
59 }
60
61 /*
62 * helper function to release an inode
63 */
64 struct process_block_struct {
65 e2fsck_t ctx;
66 char *buf;
67 struct problem_context *pctx;
68 int truncating;
69 int truncate_offset;
70 e2_blkcnt_t truncate_block;
71 int truncated_blocks;
72 int abort;
73 errcode_t errcode;
74 blk64_t last_cluster;
75 struct ext2_inode_large *inode;
76 };
77
78 static int release_inode_block(ext2_filsys fs,
79 blk64_t *block_nr,
80 e2_blkcnt_t blockcnt,
81 blk64_t ref_blk EXT2FS_ATTR((unused)),
82 int ref_offset EXT2FS_ATTR((unused)),
83 void *priv_data)
84 {
85 struct process_block_struct *pb;
86 e2fsck_t ctx;
87 struct problem_context *pctx;
88 blk64_t blk = *block_nr;
89 blk64_t cluster = EXT2FS_B2C(fs, *block_nr);
90 int retval = 0;
91
92 pb = (struct process_block_struct *) priv_data;
93 ctx = pb->ctx;
94 pctx = pb->pctx;
95
96 pctx->blk = blk;
97 pctx->blkcount = blockcnt;
98
99 if (blk == 0)
100 return 0;
101
102 if (pb->last_cluster == cluster)
103 return 0;
104
105 pb->last_cluster = cluster;
106
107 if ((blk < fs->super->s_first_data_block) ||
108 (blk >= ext2fs_blocks_count(fs->super))) {
109 fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_BLOCK_NUM, pctx);
110 return_abort:
111 pb->abort = 1;
112 return BLOCK_ABORT;
113 }
114
115 if (!ext2fs_test_block_bitmap2(fs->block_map, blk)) {
116 fix_problem(ctx, PR_0_ORPHAN_ALREADY_CLEARED_BLOCK, pctx);
117 goto return_abort;
118 }
119
120 /*
121 * If we are deleting an orphan, then we leave the fields alone.
122 * If we are truncating an orphan, then update the inode fields
123 * and clean up any partial block data.
124 */
125 if (pb->truncating) {
126 /*
127 * We only remove indirect blocks if they are
128 * completely empty.
129 */
130 if (blockcnt < 0) {
131 int i, limit;
132 blk_t *bp;
133
134 pb->errcode = io_channel_read_blk64(fs->io, blk, 1,
135 pb->buf);
136 if (pb->errcode)
137 goto return_abort;
138
139 limit = fs->blocksize >> 2;
140 for (i = 0, bp = (blk_t *) pb->buf;
141 i < limit; i++, bp++)
142 if (*bp)
143 return 0;
144 }
145 /*
146 * We don't remove direct blocks until we've reached
147 * the truncation block.
148 */
149 if (blockcnt >= 0 && blockcnt < pb->truncate_block)
150 return 0;
151 /*
152 * If part of the last block needs truncating, we do
153 * it here.
154 */
155 if ((blockcnt == pb->truncate_block) && pb->truncate_offset) {
156 pb->errcode = io_channel_read_blk64(fs->io, blk, 1,
157 pb->buf);
158 if (pb->errcode)
159 goto return_abort;
160 memset(pb->buf + pb->truncate_offset, 0,
161 fs->blocksize - pb->truncate_offset);
162 pb->errcode = io_channel_write_blk64(fs->io, blk, 1,
163 pb->buf);
164 if (pb->errcode)
165 goto return_abort;
166 }
167 pb->truncated_blocks++;
168 *block_nr = 0;
169 retval |= BLOCK_CHANGED;
170 }
171
172 if (ctx->qctx)
173 quota_data_sub(ctx->qctx, pb->inode, 0, ctx->fs->blocksize);
174 ext2fs_block_alloc_stats2(fs, blk, -1);
175 ctx->free_blocks++;
176 return retval;
177 }
178
179 /*
180 * This function releases an inode. Returns 1 if an inconsistency was
181 * found. If the inode has a link count, then it is being truncated and
182 * not deleted.
183 */
184 static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
185 struct ext2_inode_large *inode, char *block_buf,
186 struct problem_context *pctx)
187 {
188 struct process_block_struct pb;
189 ext2_filsys fs = ctx->fs;
190 blk64_t blk;
191 errcode_t retval;
192 __u32 count;
193
194 if (!ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(inode)))
195 return 0;
196
197 pb.buf = block_buf + 3 * ctx->fs->blocksize;
198 pb.ctx = ctx;
199 pb.abort = 0;
200 pb.errcode = 0;
201 pb.pctx = pctx;
202 pb.last_cluster = 0;
203 pb.inode = inode;
204 if (inode->i_links_count) {
205 pb.truncating = 1;
206 pb.truncate_block = (e2_blkcnt_t)
207 ((EXT2_I_SIZE(inode) + fs->blocksize - 1) /
208 fs->blocksize);
209 pb.truncate_offset = inode->i_size % fs->blocksize;
210 } else {
211 pb.truncating = 0;
212 pb.truncate_block = 0;
213 pb.truncate_offset = 0;
214 }
215 pb.truncated_blocks = 0;
216 retval = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
217 block_buf, release_inode_block, &pb);
218 if (retval) {
219 com_err("release_inode_blocks", retval,
220 _("while calling ext2fs_block_iterate for inode %u"),
221 ino);
222 return 1;
223 }
224 if (pb.abort)
225 return 1;
226
227 /* Refresh the inode since ext2fs_block_iterate may have changed it */
228 e2fsck_read_inode_full(ctx, ino, EXT2_INODE(inode), sizeof(*inode),
229 "release_inode_blocks");
230
231 if (pb.truncated_blocks)
232 ext2fs_iblk_sub_blocks(fs, EXT2_INODE(inode),
233 pb.truncated_blocks);
234
235 blk = ext2fs_file_acl_block(fs, EXT2_INODE(inode));
236 if (blk) {
237 retval = ext2fs_adjust_ea_refcount3(fs, blk, block_buf, -1,
238 &count, ino);
239 if (retval == EXT2_ET_BAD_EA_BLOCK_NUM) {
240 retval = 0;
241 count = 1;
242 }
243 if (retval) {
244 com_err("release_inode_blocks", retval,
245 _("while calling ext2fs_adjust_ea_refcount2 for inode %u"),
246 ino);
247 return 1;
248 }
249 if (count == 0) {
250 if (ctx->qctx)
251 quota_data_sub(ctx->qctx, inode, 0,
252 ctx->fs->blocksize);
253 ext2fs_block_alloc_stats2(fs, blk, -1);
254 ctx->free_blocks++;
255 }
256 ext2fs_file_acl_block_set(fs, EXT2_INODE(inode), 0);
257 }
258 return 0;
259 }
260
261 /* Load all quota data in preparation for orphan clearing. */
262 static errcode_t e2fsck_read_all_quotas(e2fsck_t ctx)
263 {
264 ext2_ino_t qf_ino;
265 enum quota_type qtype;
266 errcode_t retval = 0;
267
268 if (!ext2fs_has_feature_quota(ctx->fs->super))
269 return retval;
270
271 retval = quota_init_context(&ctx->qctx, ctx->fs, 0);
272 if (retval)
273 return retval;
274
275 for (qtype = 0 ; qtype < MAXQUOTAS; qtype++) {
276 qf_ino = *quota_sb_inump(ctx->fs->super, qtype);
277 if (qf_ino == 0)
278 continue;
279
280 retval = quota_update_limits(ctx->qctx, qf_ino, qtype);
281 if (retval)
282 break;
283 }
284 if (retval)
285 quota_release_context(&ctx->qctx);
286 return retval;
287 }
288
289 /* Write all the quota info to disk. */
290 static errcode_t e2fsck_write_all_quotas(e2fsck_t ctx)
291 {
292 struct problem_context pctx;
293 enum quota_type qtype;
294
295 if (!ext2fs_has_feature_quota(ctx->fs->super))
296 return 0;
297
298 clear_problem_context(&pctx);
299 for (qtype = 0 ; qtype < MAXQUOTAS; qtype++) {
300 pctx.num = qtype;
301 pctx.errcode = quota_write_inode(ctx->qctx, 1 << qtype);
302 if (pctx.errcode) {
303 fix_problem(ctx, PR_6_WRITE_QUOTAS, &pctx);
304 break;
305 }
306 }
307
308 quota_release_context(&ctx->qctx);
309 return pctx.errcode;
310 }
311
312 /*
313 * This function releases all of the orphan inodes. It returns 1 if
314 * it hit some error, and 0 on success.
315 */
316 static int release_orphan_inodes(e2fsck_t ctx)
317 {
318 ext2_filsys fs = ctx->fs;
319 ext2_ino_t ino, next_ino;
320 struct ext2_inode_large inode;
321 struct problem_context pctx;
322 char *block_buf;
323
324 if ((ino = fs->super->s_last_orphan) == 0)
325 return 0;
326
327 clear_problem_context(&pctx);
328 pctx.errcode = e2fsck_read_all_quotas(ctx);
329 if (pctx.errcode) {
330 fix_problem(ctx, PR_0_QUOTA_INIT_CTX, &pctx);
331 return 1;
332 }
333
334 /*
335 * Win or lose, we won't be using the head of the orphan inode
336 * list again.
337 */
338 fs->super->s_last_orphan = 0;
339 ext2fs_mark_super_dirty(fs);
340
341 /*
342 * If the filesystem contains errors, don't run the orphan
343 * list, since the orphan list can't be trusted; and we're
344 * going to be running a full e2fsck run anyway...
345 */
346 if (fs->super->s_state & EXT2_ERROR_FS) {
347 if (ctx->qctx)
348 quota_release_context(&ctx->qctx);
349 return 0;
350 }
351
352 if ((ino < EXT2_FIRST_INODE(fs->super)) ||
353 (ino > fs->super->s_inodes_count)) {
354 clear_problem_context(&pctx);
355 pctx.ino = ino;
356 fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_HEAD_INODE, &pctx);
357 goto err_qctx;
358 }
359
360 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4,
361 "block iterate buffer");
362 e2fsck_read_bitmaps(ctx);
363
364 while (ino) {
365 e2fsck_read_inode_full(ctx, ino, EXT2_INODE(&inode),
366 sizeof(inode), "release_orphan_inodes");
367 clear_problem_context(&pctx);
368 pctx.ino = ino;
369 pctx.inode = EXT2_INODE(&inode);
370 pctx.str = inode.i_links_count ? _("Truncating") :
371 _("Clearing");
372
373 fix_problem(ctx, PR_0_ORPHAN_CLEAR_INODE, &pctx);
374
375 next_ino = inode.i_dtime;
376 if (next_ino &&
377 ((next_ino < EXT2_FIRST_INODE(fs->super)) ||
378 (next_ino > fs->super->s_inodes_count))) {
379 pctx.ino = next_ino;
380 fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_INODE, &pctx);
381 goto err_buf;
382 }
383
384 if (release_inode_blocks(ctx, ino, &inode, block_buf, &pctx))
385 goto err_buf;
386
387 if (!inode.i_links_count) {
388 if (ctx->qctx)
389 quota_data_inodes(ctx->qctx, &inode, ino, -1);
390 ext2fs_inode_alloc_stats2(fs, ino, -1,
391 LINUX_S_ISDIR(inode.i_mode));
392 ctx->free_inodes++;
393 inode.i_dtime = ctx->now;
394 } else {
395 inode.i_dtime = 0;
396 }
397 e2fsck_write_inode_full(ctx, ino, EXT2_INODE(&inode),
398 sizeof(inode), "delete_file");
399 ino = next_ino;
400 }
401 ext2fs_free_mem(&block_buf);
402 pctx.errcode = e2fsck_write_all_quotas(ctx);
403 if (pctx.errcode)
404 goto err;
405 return 0;
406 err_buf:
407 ext2fs_free_mem(&block_buf);
408 err_qctx:
409 if (ctx->qctx)
410 quota_release_context(&ctx->qctx);
411 err:
412 return 1;
413 }
414
415 /*
416 * Check the resize inode to make sure it is sane. We check both for
417 * the case where on-line resizing is not enabled (in which case the
418 * resize inode should be cleared) as well as the case where on-line
419 * resizing is enabled.
420 */
421 void check_resize_inode(e2fsck_t ctx)
422 {
423 ext2_filsys fs = ctx->fs;
424 struct ext2_inode inode;
425 struct problem_context pctx;
426 int i, gdt_off, ind_off;
427 dgrp_t j;
428 blk_t blk, pblk;
429 blk_t expect; /* for resize inode, which is 32-bit only */
430 __u32 *dind_buf = 0, *ind_buf;
431 errcode_t retval;
432
433 clear_problem_context(&pctx);
434
435 /*
436 * If the resize inode feature isn't set, then
437 * s_reserved_gdt_blocks must be zero.
438 */
439 if (!ext2fs_has_feature_resize_inode(fs->super)) {
440 if (fs->super->s_reserved_gdt_blocks) {
441 pctx.num = fs->super->s_reserved_gdt_blocks;
442 if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS,
443 &pctx)) {
444 fs->super->s_reserved_gdt_blocks = 0;
445 ext2fs_mark_super_dirty(fs);
446 }
447 }
448 }
449
450 /* Read the resize inode */
451 pctx.ino = EXT2_RESIZE_INO;
452 retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
453 if (retval) {
454 if (ext2fs_has_feature_resize_inode(fs->super))
455 ctx->flags |= E2F_FLAG_RESIZE_INODE;
456 return;
457 }
458
459 /*
460 * If the resize inode feature isn't set, check to make sure
461 * the resize inode is cleared; then we're done.
462 */
463 if (!ext2fs_has_feature_resize_inode(fs->super)) {
464 for (i=0; i < EXT2_N_BLOCKS; i++) {
465 if (inode.i_block[i])
466 break;
467 }
468 if ((i < EXT2_N_BLOCKS) &&
469 fix_problem(ctx, PR_0_CLEAR_RESIZE_INODE, &pctx)) {
470 memset(&inode, 0, sizeof(inode));
471 e2fsck_write_inode(ctx, EXT2_RESIZE_INO, &inode,
472 "clear_resize");
473 }
474 return;
475 }
476
477 /*
478 * The resize inode feature is enabled; check to make sure the
479 * only block in use is the double indirect block
480 */
481 blk = inode.i_block[EXT2_DIND_BLOCK];
482 for (i=0; i < EXT2_N_BLOCKS; i++) {
483 if (i != EXT2_DIND_BLOCK && inode.i_block[i])
484 break;
485 }
486 if ((i < EXT2_N_BLOCKS) || !blk || !inode.i_links_count ||
487 !(inode.i_mode & LINUX_S_IFREG) ||
488 (blk < fs->super->s_first_data_block ||
489 blk >= ext2fs_blocks_count(fs->super))) {
490 resize_inode_invalid:
491 if (fix_problem(ctx, PR_0_RESIZE_INODE_INVALID, &pctx)) {
492 memset(&inode, 0, sizeof(inode));
493 e2fsck_write_inode(ctx, EXT2_RESIZE_INO, &inode,
494 "clear_resize");
495 ctx->flags |= E2F_FLAG_RESIZE_INODE;
496 }
497 if (!(ctx->options & E2F_OPT_READONLY)) {
498 fs->super->s_state &= ~EXT2_VALID_FS;
499 ext2fs_mark_super_dirty(fs);
500 }
501 goto cleanup;
502 }
503 dind_buf = (__u32 *) e2fsck_allocate_memory(ctx, fs->blocksize * 2,
504 "resize dind buffer");
505 ind_buf = (__u32 *) ((char *) dind_buf + fs->blocksize);
506
507 retval = ext2fs_read_ind_block(fs, blk, dind_buf);
508 if (retval)
509 goto resize_inode_invalid;
510
511 gdt_off = fs->desc_blocks;
512 pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks;
513 if (fs->blocksize == 1024 && fs->super->s_first_data_block == 0)
514 pblk++; /* Deal with 1024 blocksize bigalloc fs */
515 for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4;
516 i++, gdt_off++, pblk++) {
517 gdt_off %= fs->blocksize/4;
518 if (dind_buf[gdt_off] != pblk)
519 goto resize_inode_invalid;
520 retval = ext2fs_read_ind_block(fs, pblk, ind_buf);
521 if (retval)
522 goto resize_inode_invalid;
523 ind_off = 0;
524 for (j = 1; j < fs->group_desc_count; j++) {
525 if (!ext2fs_bg_has_super(fs, j))
526 continue;
527 expect = pblk + EXT2_GROUPS_TO_BLOCKS(fs->super, j);
528 if (ind_buf[ind_off] != expect)
529 goto resize_inode_invalid;
530 ind_off++;
531 }
532 }
533
534 cleanup:
535 if (dind_buf)
536 ext2fs_free_mem(&dind_buf);
537
538 }
539
540 /*
541 * This function checks the dirhash signed/unsigned hint if necessary.
542 */
543 static void e2fsck_fix_dirhash_hint(e2fsck_t ctx)
544 {
545 struct ext2_super_block *sb = ctx->fs->super;
546 struct problem_context pctx;
547 char c;
548
549 if ((ctx->options & E2F_OPT_READONLY) ||
550 !ext2fs_has_feature_dir_index(sb) ||
551 (sb->s_flags & (EXT2_FLAGS_SIGNED_HASH|EXT2_FLAGS_UNSIGNED_HASH)))
552 return;
553
554 c = (char) 255;
555
556 clear_problem_context(&pctx);
557 if (fix_problem(ctx, PR_0_DIRHASH_HINT, &pctx)) {
558 if (((int) c) == -1) {
559 sb->s_flags |= EXT2_FLAGS_SIGNED_HASH;
560 } else {
561 sb->s_flags |= EXT2_FLAGS_UNSIGNED_HASH;
562 }
563 ext2fs_mark_super_dirty(ctx->fs);
564 }
565 }
566
567
568 void check_super_block(e2fsck_t ctx)
569 {
570 ext2_filsys fs = ctx->fs;
571 blk64_t first_block, last_block;
572 struct ext2_super_block *sb = fs->super;
573 unsigned int ipg_max;
574 problem_t problem;
575 blk64_t blocks_per_group = fs->super->s_blocks_per_group;
576 __u32 bpg_max, cpg_max;
577 __u64 blks_max;
578 int inodes_per_block;
579 int inode_size;
580 int accept_time_fudge;
581 int broken_system_clock;
582 dgrp_t i;
583 blk64_t should_be;
584 struct problem_context pctx;
585 blk64_t free_blocks = 0;
586 ino_t free_inodes = 0;
587 int csum_flag, clear_test_fs_flag;
588
589 inodes_per_block = EXT2_INODES_PER_BLOCK(fs->super);
590 ipg_max = inodes_per_block * (blocks_per_group - 4);
591 if (ipg_max > EXT2_MAX_INODES_PER_GROUP(sb))
592 ipg_max = EXT2_MAX_INODES_PER_GROUP(sb);
593 cpg_max = 8 * EXT2_BLOCK_SIZE(sb);
594 if (cpg_max > EXT2_MAX_CLUSTERS_PER_GROUP(sb))
595 cpg_max = EXT2_MAX_CLUSTERS_PER_GROUP(sb);
596 bpg_max = 8 * EXT2_BLOCK_SIZE(sb) * EXT2FS_CLUSTER_RATIO(fs);
597 if (bpg_max > EXT2_MAX_BLOCKS_PER_GROUP(sb))
598 bpg_max = EXT2_MAX_BLOCKS_PER_GROUP(sb);
599
600 ctx->invalid_inode_bitmap_flag = (int *) e2fsck_allocate_memory(ctx,
601 sizeof(int) * fs->group_desc_count, "invalid_inode_bitmap");
602 ctx->invalid_block_bitmap_flag = (int *) e2fsck_allocate_memory(ctx,
603 sizeof(int) * fs->group_desc_count, "invalid_block_bitmap");
604 ctx->invalid_inode_table_flag = (int *) e2fsck_allocate_memory(ctx,
605 sizeof(int) * fs->group_desc_count, "invalid_inode_table");
606
607 blks_max = (1ULL << 32) * EXT2_MAX_BLOCKS_PER_GROUP(fs->super);
608 if (ext2fs_has_feature_64bit(fs->super)) {
609 if (blks_max > ((1ULL << 48) - 1))
610 blks_max = (1ULL << 48) - 1;
611 } else {
612 if (blks_max > ((1ULL << 32) - 1))
613 blks_max = (1ULL << 32) - 1;
614 }
615
616 clear_problem_context(&pctx);
617
618 /*
619 * Verify the super block constants...
620 */
621 check_super_value(ctx, "inodes_count", sb->s_inodes_count,
622 MIN_CHECK, 1, 0);
623 check_super_value64(ctx, "blocks_count", ext2fs_blocks_count(sb),
624 MIN_CHECK | MAX_CHECK, 1, blks_max);
625 check_super_value(ctx, "first_data_block", sb->s_first_data_block,
626 MAX_CHECK, 0, ext2fs_blocks_count(sb));
627 check_super_value(ctx, "log_block_size", sb->s_log_block_size,
628 MIN_CHECK | MAX_CHECK, 0,
629 EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE);
630 check_super_value(ctx, "log_cluster_size",
631 sb->s_log_cluster_size,
632 MIN_CHECK | MAX_CHECK, sb->s_log_block_size,
633 (EXT2_MAX_CLUSTER_LOG_SIZE -
634 EXT2_MIN_CLUSTER_LOG_SIZE));
635 check_super_value(ctx, "clusters_per_group", sb->s_clusters_per_group,
636 MIN_CHECK | MAX_CHECK, 8, cpg_max);
637 check_super_value(ctx, "blocks_per_group", sb->s_blocks_per_group,
638 MIN_CHECK | MAX_CHECK, 8, bpg_max);
639 check_super_value(ctx, "inodes_per_group", sb->s_inodes_per_group,
640 MIN_CHECK | MAX_CHECK, inodes_per_block, ipg_max);
641 check_super_value(ctx, "r_blocks_count", ext2fs_r_blocks_count(sb),
642 MAX_CHECK, 0, ext2fs_blocks_count(sb) / 2);
643 check_super_value(ctx, "reserved_gdt_blocks",
644 sb->s_reserved_gdt_blocks, MAX_CHECK, 0,
645 fs->blocksize / sizeof(__u32));
646 check_super_value(ctx, "desc_size",
647 sb->s_desc_size, MAX_CHECK | LOG2_CHECK, 0,
648 EXT2_MAX_DESC_SIZE);
649 if (sb->s_rev_level > EXT2_GOOD_OLD_REV)
650 check_super_value(ctx, "first_ino", sb->s_first_ino,
651 MIN_CHECK | MAX_CHECK,
652 EXT2_GOOD_OLD_FIRST_INO, sb->s_inodes_count);
653 inode_size = EXT2_INODE_SIZE(sb);
654 check_super_value(ctx, "inode_size",
655 inode_size, MIN_CHECK | MAX_CHECK | LOG2_CHECK,
656 EXT2_GOOD_OLD_INODE_SIZE, fs->blocksize);
657 if (sb->s_blocks_per_group != (sb->s_clusters_per_group *
658 EXT2FS_CLUSTER_RATIO(fs))) {
659 pctx.num = sb->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs);
660 pctx.str = "block_size";
661 fix_problem(ctx, PR_0_MISC_CORRUPT_SUPER, &pctx);
662 ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
663 return;
664 }
665
666 if ((ctx->flags & E2F_FLAG_GOT_DEVSIZE) &&
667 (ctx->num_blocks < ext2fs_blocks_count(sb))) {
668 pctx.blk = ext2fs_blocks_count(sb);
669 pctx.blk2 = ctx->num_blocks;
670 if (fix_problem(ctx, PR_0_FS_SIZE_WRONG, &pctx)) {
671 ctx->flags |= E2F_FLAG_ABORT;
672 return;
673 }
674 }
675
676 should_be = (sb->s_log_block_size == 0 &&
677 EXT2FS_CLUSTER_RATIO(fs) == 1) ? 1 : 0;
678 if (sb->s_first_data_block != should_be) {
679 pctx.blk = sb->s_first_data_block;
680 pctx.blk2 = should_be;
681 fix_problem(ctx, PR_0_FIRST_DATA_BLOCK, &pctx);
682 ctx->flags |= E2F_FLAG_ABORT;
683 return;
684 }
685
686 should_be = (blk64_t)sb->s_inodes_per_group * fs->group_desc_count;
687 if (should_be > UINT_MAX)
688 should_be = UINT_MAX;
689 if (sb->s_inodes_count != should_be) {
690 pctx.ino = sb->s_inodes_count;
691 pctx.ino2 = should_be;
692 if (fix_problem(ctx, PR_0_INODE_COUNT_WRONG, &pctx)) {
693 sb->s_inodes_count = should_be;
694 ext2fs_mark_super_dirty(fs);
695 }
696 }
697 if (EXT2_INODE_SIZE(sb) > EXT2_GOOD_OLD_INODE_SIZE) {
698 unsigned min =
699 sizeof(((struct ext2_inode_large *) 0)->i_extra_isize) +
700 sizeof(((struct ext2_inode_large *) 0)->i_checksum_hi);
701 unsigned max = EXT2_INODE_SIZE(sb) - EXT2_GOOD_OLD_INODE_SIZE;
702 pctx.num = sb->s_min_extra_isize;
703 if (sb->s_min_extra_isize &&
704 (sb->s_min_extra_isize < min ||
705 sb->s_min_extra_isize > max ||
706 sb->s_min_extra_isize & 3) &&
707 fix_problem(ctx, PR_0_BAD_MIN_EXTRA_ISIZE, &pctx)) {
708 sb->s_min_extra_isize =
709 (sizeof(struct ext2_inode_large) -
710 EXT2_GOOD_OLD_INODE_SIZE);
711 ext2fs_mark_super_dirty(fs);
712 }
713 pctx.num = sb->s_want_extra_isize;
714 if (sb->s_want_extra_isize &&
715 (sb->s_want_extra_isize < min ||
716 sb->s_want_extra_isize > max ||
717 sb->s_want_extra_isize & 3) &&
718 fix_problem(ctx, PR_0_BAD_WANT_EXTRA_ISIZE, &pctx)) {
719 sb->s_want_extra_isize =
720 (sizeof(struct ext2_inode_large) -
721 EXT2_GOOD_OLD_INODE_SIZE);
722 ext2fs_mark_super_dirty(fs);
723 }
724 }
725
726 /* Are metadata_csum and uninit_bg both set? */
727 if (ext2fs_has_feature_metadata_csum(fs->super) &&
728 ext2fs_has_feature_gdt_csum(fs->super) &&
729 fix_problem(ctx, PR_0_META_AND_GDT_CSUM_SET, &pctx)) {
730 ext2fs_clear_feature_gdt_csum(fs->super);
731 ext2fs_mark_super_dirty(fs);
732 for (i = 0; i < fs->group_desc_count; i++)
733 ext2fs_group_desc_csum_set(fs, i);
734 }
735
736 /* We can't have ^metadata_csum,metadata_csum_seed */
737 if (!ext2fs_has_feature_metadata_csum(fs->super) &&
738 ext2fs_has_feature_csum_seed(fs->super) &&
739 fix_problem(ctx, PR_0_CSUM_SEED_WITHOUT_META_CSUM, &pctx)) {
740 ext2fs_clear_feature_csum_seed(fs->super);
741 fs->super->s_checksum_seed = 0;
742 ext2fs_mark_super_dirty(fs);
743 }
744
745 /* Is 64bit set and extents unset? */
746 if (ext2fs_has_feature_64bit(fs->super) &&
747 !ext2fs_has_feature_extents(fs->super) &&
748 fix_problem(ctx, PR_0_64BIT_WITHOUT_EXTENTS, &pctx)) {
749 ext2fs_set_feature_extents(fs->super);
750 ext2fs_mark_super_dirty(fs);
751 }
752
753 /* Did user ask us to convert files to extents? */
754 if (ctx->options & E2F_OPT_CONVERT_BMAP) {
755 ext2fs_set_feature_extents(fs->super);
756 ext2fs_mark_super_dirty(fs);
757 }
758
759 if (ext2fs_has_feature_meta_bg(fs->super) &&
760 (fs->super->s_first_meta_bg > fs->desc_blocks)) {
761 pctx.group = fs->desc_blocks;
762 pctx.num = fs->super->s_first_meta_bg;
763 if (fix_problem(ctx, PR_0_FIRST_META_BG_TOO_BIG, &pctx)) {
764 ext2fs_clear_feature_meta_bg(fs->super);
765 fs->super->s_first_meta_bg = 0;
766 ext2fs_mark_super_dirty(fs);
767 }
768 }
769
770 /*
771 * Verify the group descriptors....
772 */
773 first_block = sb->s_first_data_block;
774 last_block = ext2fs_blocks_count(sb)-1;
775
776 csum_flag = ext2fs_has_group_desc_csum(fs);
777 for (i = 0; i < fs->group_desc_count; i++) {
778 pctx.group = i;
779
780 if (!ext2fs_has_feature_flex_bg(fs->super)) {
781 first_block = ext2fs_group_first_block2(fs, i);
782 last_block = ext2fs_group_last_block2(fs, i);
783 }
784
785 if ((ext2fs_block_bitmap_loc(fs, i) < first_block) ||
786 (ext2fs_block_bitmap_loc(fs, i) > last_block)) {
787 pctx.blk = ext2fs_block_bitmap_loc(fs, i);
788 if (fix_problem(ctx, PR_0_BB_NOT_GROUP, &pctx))
789 ext2fs_block_bitmap_loc_set(fs, i, 0);
790 }
791 if (ext2fs_block_bitmap_loc(fs, i) == 0) {
792 ctx->invalid_block_bitmap_flag[i]++;
793 ctx->invalid_bitmaps++;
794 }
795 if ((ext2fs_inode_bitmap_loc(fs, i) < first_block) ||
796 (ext2fs_inode_bitmap_loc(fs, i) > last_block)) {
797 pctx.blk = ext2fs_inode_bitmap_loc(fs, i);
798 if (fix_problem(ctx, PR_0_IB_NOT_GROUP, &pctx))
799 ext2fs_inode_bitmap_loc_set(fs, i, 0);
800 }
801 if (ext2fs_inode_bitmap_loc(fs, i) == 0) {
802 ctx->invalid_inode_bitmap_flag[i]++;
803 ctx->invalid_bitmaps++;
804 }
805 if ((ext2fs_inode_table_loc(fs, i) < first_block) ||
806 ((ext2fs_inode_table_loc(fs, i) +
807 fs->inode_blocks_per_group - 1) > last_block)) {
808 pctx.blk = ext2fs_inode_table_loc(fs, i);
809 if (fix_problem(ctx, PR_0_ITABLE_NOT_GROUP, &pctx))
810 ext2fs_inode_table_loc_set(fs, i, 0);
811 }
812 if (ext2fs_inode_table_loc(fs, i) == 0) {
813 ctx->invalid_inode_table_flag[i]++;
814 ctx->invalid_bitmaps++;
815 }
816 free_blocks += ext2fs_bg_free_blocks_count(fs, i);
817 free_inodes += ext2fs_bg_free_inodes_count(fs, i);
818
819 if ((ext2fs_bg_free_blocks_count(fs, i) > sb->s_blocks_per_group) ||
820 (ext2fs_bg_free_inodes_count(fs, i) > sb->s_inodes_per_group) ||
821 (ext2fs_bg_used_dirs_count(fs, i) > sb->s_inodes_per_group))
822 ext2fs_unmark_valid(fs);
823
824 should_be = 0;
825 if (!ext2fs_group_desc_csum_verify(fs, i)) {
826 pctx.csum1 = ext2fs_bg_checksum(fs, i);
827 pctx.csum2 = ext2fs_group_desc_csum(fs, i);
828 if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) {
829 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
830 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
831 ext2fs_bg_itable_unused_set(fs, i, 0);
832 should_be = 1;
833 }
834 ext2fs_unmark_valid(fs);
835 }
836
837 if (!csum_flag &&
838 (ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) ||
839 ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) ||
840 ext2fs_bg_itable_unused(fs, i) != 0)) {
841 if (fix_problem(ctx, PR_0_GDT_UNINIT, &pctx)) {
842 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
843 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
844 ext2fs_bg_itable_unused_set(fs, i, 0);
845 should_be = 1;
846 }
847 ext2fs_unmark_valid(fs);
848 }
849
850 if (i == fs->group_desc_count - 1 &&
851 ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT)) {
852 if (fix_problem(ctx, PR_0_BB_UNINIT_LAST, &pctx)) {
853 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
854 should_be = 1;
855 }
856 ext2fs_unmark_valid(fs);
857 }
858
859 if (csum_flag &&
860 (ext2fs_bg_itable_unused(fs, i) > ext2fs_bg_free_inodes_count(fs, i) ||
861 ext2fs_bg_itable_unused(fs, i) > sb->s_inodes_per_group)) {
862 pctx.blk = ext2fs_bg_itable_unused(fs, i);
863 if (fix_problem(ctx, PR_0_GDT_ITABLE_UNUSED, &pctx)) {
864 ext2fs_bg_itable_unused_set(fs, i, 0);
865 should_be = 1;
866 }
867 ext2fs_unmark_valid(fs);
868 }
869
870 if (should_be)
871 ext2fs_group_desc_csum_set(fs, i);
872 /* If the user aborts e2fsck by typing ^C, stop right away */
873 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
874 return;
875 }
876
877 ctx->free_blocks = EXT2FS_C2B(fs, free_blocks);
878 ctx->free_inodes = free_inodes;
879
880 if ((ext2fs_free_blocks_count(sb) > ext2fs_blocks_count(sb)) ||
881 (sb->s_free_inodes_count > sb->s_inodes_count))
882 ext2fs_unmark_valid(fs);
883
884
885 /*
886 * If we have invalid bitmaps, set the error state of the
887 * filesystem.
888 */
889 if (ctx->invalid_bitmaps && !(ctx->options & E2F_OPT_READONLY)) {
890 sb->s_state &= ~EXT2_VALID_FS;
891 ext2fs_mark_super_dirty(fs);
892 }
893
894 clear_problem_context(&pctx);
895
896 #ifndef EXT2_SKIP_UUID
897 /*
898 * If the UUID field isn't assigned, assign it.
899 * Skip if checksums are enabled and the filesystem is mounted,
900 * if the id changes under the kernel remounting rw may fail.
901 */
902 if (!(ctx->options & E2F_OPT_READONLY) && uuid_is_null(sb->s_uuid) &&
903 !ext2fs_has_feature_metadata_csum(ctx->fs->super) &&
904 (!csum_flag || !(ctx->mount_flags & EXT2_MF_MOUNTED))) {
905 if (fix_problem(ctx, PR_0_ADD_UUID, &pctx)) {
906 uuid_generate(sb->s_uuid);
907 ext2fs_init_csum_seed(fs);
908 fs->flags |= EXT2_FLAG_DIRTY;
909 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
910 }
911 }
912 #endif
913
914 /*
915 * Check to see if we should disable the test_fs flag
916 */
917 profile_get_boolean(ctx->profile, "options",
918 "clear_test_fs_flag", 0, 1,
919 &clear_test_fs_flag);
920 if (!(ctx->options & E2F_OPT_READONLY) &&
921 clear_test_fs_flag &&
922 (fs->super->s_flags & EXT2_FLAGS_TEST_FILESYS) &&
923 (fs_proc_check("ext4") || check_for_modules("ext4"))) {
924 if (fix_problem(ctx, PR_0_CLEAR_TESTFS_FLAG, &pctx)) {
925 fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS;
926 fs->flags |= EXT2_FLAG_DIRTY;
927 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
928 }
929 }
930
931 /*
932 * For the Hurd, check to see if the filetype option is set,
933 * since it doesn't support it.
934 */
935 if (!(ctx->options & E2F_OPT_READONLY) &&
936 fs->super->s_creator_os == EXT2_OS_HURD &&
937 ext2fs_has_feature_filetype(fs->super)) {
938 if (fix_problem(ctx, PR_0_HURD_CLEAR_FILETYPE, &pctx)) {
939 ext2fs_clear_feature_filetype(fs->super);
940 ext2fs_mark_super_dirty(fs);
941 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
942 }
943 }
944
945 /*
946 * If we have any of the compatibility flags set, we need to have a
947 * revision 1 filesystem. Most kernels will not check the flags on
948 * a rev 0 filesystem and we may have corruption issues because of
949 * the incompatible changes to the filesystem.
950 */
951 if (!(ctx->options & E2F_OPT_READONLY) &&
952 fs->super->s_rev_level == EXT2_GOOD_OLD_REV &&
953 (fs->super->s_feature_compat ||
954 fs->super->s_feature_ro_compat ||
955 fs->super->s_feature_incompat) &&
956 fix_problem(ctx, PR_0_FS_REV_LEVEL, &pctx)) {
957 ext2fs_update_dynamic_rev(fs);
958 ext2fs_mark_super_dirty(fs);
959 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
960 }
961
962 /*
963 * Clean up any orphan inodes, if present.
964 */
965 if (!(ctx->options & E2F_OPT_READONLY) && release_orphan_inodes(ctx)) {
966 fs->super->s_state &= ~EXT2_VALID_FS;
967 ext2fs_mark_super_dirty(fs);
968 }
969
970 /*
971 * Unfortunately, due to Windows' unfortunate design decision
972 * to configure the hardware clock to tick localtime, instead
973 * of the more proper and less error-prone UTC time, many
974 * users end up in the situation where the system clock is
975 * incorrectly set at the time when e2fsck is run.
976 *
977 * Historically this was usually due to some distributions
978 * having buggy init scripts and/or installers that didn't
979 * correctly detect this case and take appropriate
980 * countermeasures. However, it's still possible, despite the
981 * best efforts of init script and installer authors to not be
982 * able to detect this misconfiguration, usually due to a
983 * buggy or misconfigured virtualization manager or the
984 * installer not having access to a network time server during
985 * the installation process. So by default, we allow the
986 * superblock times to be fudged by up to 24 hours. This can
987 * be disabled by setting options.accept_time_fudge to the
988 * boolean value of false in e2fsck.conf. We also support
989 * options.buggy_init_scripts for backwards compatibility.
990 */
991 profile_get_boolean(ctx->profile, "options", "accept_time_fudge",
992 0, 1, &accept_time_fudge);
993 profile_get_boolean(ctx->profile, "options", "buggy_init_scripts",
994 0, accept_time_fudge, &accept_time_fudge);
995 ctx->time_fudge = accept_time_fudge ? 86400 : 0;
996
997 profile_get_boolean(ctx->profile, "options", "broken_system_clock",
998 0, 0, &broken_system_clock);
999
1000 /*
1001 * Check to see if the superblock last mount time or last
1002 * write time is in the future.
1003 */
1004 if (!broken_system_clock &&
1005 !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
1006 fs->super->s_mtime > (__u32) ctx->now) {
1007 pctx.num = fs->super->s_mtime;
1008 problem = PR_0_FUTURE_SB_LAST_MOUNT;
1009 if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge)
1010 problem = PR_0_FUTURE_SB_LAST_MOUNT_FUDGED;
1011 if (fix_problem(ctx, problem, &pctx)) {
1012 fs->super->s_mtime = ctx->now;
1013 fs->flags |= EXT2_FLAG_DIRTY;
1014 }
1015 }
1016 if (!broken_system_clock &&
1017 !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
1018 fs->super->s_wtime > (__u32) ctx->now) {
1019 pctx.num = fs->super->s_wtime;
1020 problem = PR_0_FUTURE_SB_LAST_WRITE;
1021 if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge)
1022 problem = PR_0_FUTURE_SB_LAST_WRITE_FUDGED;
1023 if (fix_problem(ctx, problem, &pctx)) {
1024 fs->super->s_wtime = ctx->now;
1025 fs->flags |= EXT2_FLAG_DIRTY;
1026 }
1027 }
1028
1029 e2fsck_validate_quota_inodes(ctx);
1030
1031 /*
1032 * Move the ext3 journal file, if necessary.
1033 */
1034 e2fsck_move_ext3_journal(ctx);
1035
1036 /*
1037 * Fix journal hint, if necessary
1038 */
1039 e2fsck_fix_ext3_journal_hint(ctx);
1040
1041 /*
1042 * Add dirhash hint if necessary
1043 */
1044 e2fsck_fix_dirhash_hint(ctx);
1045
1046 /*
1047 * Hide quota inodes if necessary.
1048 */
1049 e2fsck_hide_quota(ctx);
1050
1051 return;
1052 }
1053
1054 /*
1055 * Check to see if we should backup the master sb to the backup super
1056 * blocks. Returns non-zero if the sb should be backed up.
1057 */
1058
1059 /*
1060 * A few flags are set on the fly by the kernel, but only in the
1061 * primary superblock. This is actually a bad thing, and we should
1062 * try to discourage it in the future. In particular, for the newer
1063 * ext4 files, especially EXT4_FEATURE_RO_COMPAT_DIR_NLINK and
1064 * EXT3_FEATURE_INCOMPAT_EXTENTS. So some of these may go away in the
1065 * future. EXT3_FEATURE_INCOMPAT_RECOVER may also get set when
1066 * copying the primary superblock during online resize.
1067 *
1068 * The kernel will set EXT2_FEATURE_COMPAT_EXT_ATTR, but
1069 * unfortunately, we shouldn't ignore it since if it's not set in the
1070 * backup, the extended attributes in the filesystem will be stripped
1071 * away.
1072 */
1073 #define FEATURE_RO_COMPAT_IGNORE (EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
1074 EXT4_FEATURE_RO_COMPAT_DIR_NLINK)
1075 #define FEATURE_INCOMPAT_IGNORE (EXT3_FEATURE_INCOMPAT_EXTENTS| \
1076 EXT3_FEATURE_INCOMPAT_RECOVER)
1077
1078 int check_backup_super_block(e2fsck_t ctx)
1079 {
1080 ext2_filsys fs = ctx->fs;
1081 errcode_t retval;
1082 dgrp_t g;
1083 blk64_t sb;
1084 int ret = 0;
1085 char buf[SUPERBLOCK_SIZE];
1086 struct ext2_super_block *backup_sb;
1087
1088 /*
1089 * If we are already writing out the backup blocks, then we
1090 * don't need to test. Also, if the filesystem is invalid, or
1091 * the check was aborted or cancelled, we also don't want to
1092 * do the backup. If the filesystem was opened read-only then
1093 * we can't do the backup.
1094 */
1095 if (((fs->flags & EXT2_FLAG_MASTER_SB_ONLY) == 0) ||
1096 !ext2fs_test_valid(fs) ||
1097 (fs->super->s_state & EXT2_ERROR_FS) ||
1098 (ctx->flags & (E2F_FLAG_ABORT | E2F_FLAG_CANCEL)) ||
1099 (ctx->options & E2F_OPT_READONLY))
1100 return 0;
1101
1102 for (g = 1; g < fs->group_desc_count; g++) {
1103 if (!ext2fs_bg_has_super(fs, g))
1104 continue;
1105
1106 sb = ext2fs_group_first_block2(fs, g);
1107
1108 retval = io_channel_read_blk(fs->io, sb, -SUPERBLOCK_SIZE,
1109 buf);
1110 if (retval)
1111 continue;
1112 backup_sb = (struct ext2_super_block *) buf;
1113 #ifdef WORDS_BIGENDIAN
1114 ext2fs_swap_super(backup_sb);
1115 #endif
1116 if ((backup_sb->s_magic != EXT2_SUPER_MAGIC) ||
1117 (backup_sb->s_rev_level > EXT2_LIB_CURRENT_REV) ||
1118 ((backup_sb->s_log_block_size + EXT2_MIN_BLOCK_LOG_SIZE) >
1119 EXT2_MAX_BLOCK_LOG_SIZE) ||
1120 (EXT2_INODE_SIZE(backup_sb) < EXT2_GOOD_OLD_INODE_SIZE))
1121 continue;
1122
1123 #define SUPER_INCOMPAT_DIFFERENT(x) \
1124 ((fs->super->x & ~FEATURE_INCOMPAT_IGNORE) != \
1125 (backup_sb->x & ~FEATURE_INCOMPAT_IGNORE))
1126 #define SUPER_RO_COMPAT_DIFFERENT(x) \
1127 ((fs->super->x & ~FEATURE_RO_COMPAT_IGNORE) != \
1128 (backup_sb->x & ~FEATURE_RO_COMPAT_IGNORE))
1129 #define SUPER_DIFFERENT(x) \
1130 (fs->super->x != backup_sb->x)
1131
1132 if (SUPER_DIFFERENT(s_feature_compat) ||
1133 SUPER_INCOMPAT_DIFFERENT(s_feature_incompat) ||
1134 SUPER_RO_COMPAT_DIFFERENT(s_feature_ro_compat) ||
1135 SUPER_DIFFERENT(s_blocks_count) ||
1136 SUPER_DIFFERENT(s_blocks_count_hi) ||
1137 SUPER_DIFFERENT(s_inodes_count) ||
1138 memcmp(fs->super->s_uuid, backup_sb->s_uuid,
1139 sizeof(fs->super->s_uuid)))
1140 ret = 1;
1141 break;
1142 }
1143 return ret;
1144 }