E2fsck now prints ranges in pass 5 when printing deltas in

the block and inode bitmaps.
bitmap-optimize
Theodore Ts'o 2002-03-07 02:47:07 -05:00
parent 045cf87226
commit f122632e6b
21 changed files with 151 additions and 34 deletions

View File

@ -1,3 +1,12 @@
2002-03-06 <tytso@snap.thunk.org>
* problem.h, problem.c: PR_5_BLOCK_RANGE_UNUSED,
PR_5_BLOCK_RANGE_USED, PR_5_INODE_RANGE_UNUSED,
PR_5_INODE_RANGE_USED: Add new problem codes.
* pass5.c (check_block_bitmaps, check_inode_bitmaps): Collapse
reporting of adjacent blocks and inodes into a range.
2002-03-04 Philipp Thomas <pthomas@suse.de>
* unix.c (main): Newer libintl needs LC_CTYPE to be set in

View File

@ -72,6 +72,42 @@ void e2fsck_pass5(e2fsck_t ctx)
#endif
}
#define NO_BLK ((blk_t) -1)
static print_bitmap_problem(e2fsck_t ctx, int problem,
struct problem_context *pctx)
{
switch (problem) {
case PR_5_BLOCK_UNUSED:
if (pctx->blk == pctx->blk2)
pctx->blk2 = 0;
else
problem = PR_5_BLOCK_RANGE_UNUSED;
break;
case PR_5_BLOCK_USED:
if (pctx->blk == pctx->blk2)
pctx->blk2 = 0;
else
problem = PR_5_BLOCK_RANGE_USED;
break;
case PR_5_INODE_UNUSED:
if (pctx->ino == pctx->ino2)
pctx->ino2 = 0;
else
problem = PR_5_INODE_RANGE_UNUSED;
break;
case PR_5_INODE_USED:
if (pctx->ino == pctx->ino2)
pctx->ino2 = 0;
else
problem = PR_5_INODE_RANGE_USED;
break;
}
fix_problem(ctx, problem, pctx);
pctx->blk = pctx->blk2 = NO_BLK;
pctx->ino = pctx->ino2 = 0;
}
static void check_block_bitmaps(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
@ -83,7 +119,7 @@ static void check_block_bitmaps(e2fsck_t ctx)
int group_free = 0;
int actual, bitmap;
struct problem_context pctx;
int problem, fixit, had_problem;
int problem, save_problem, fixit, had_problem;
errcode_t retval;
clear_problem_context(&pctx);
@ -122,6 +158,8 @@ static void check_block_bitmaps(e2fsck_t ctx)
redo_counts:
had_problem = 0;
save_problem = 0;
pctx.blk = pctx.blk2 = NO_BLK;
for (i = fs->super->s_first_data_block;
i < fs->super->s_blocks_count;
i++) {
@ -135,15 +173,26 @@ redo_counts:
/*
* Block not used, but marked in use in the bitmap.
*/
problem = PR_5_UNUSED_BLOCK;
problem = PR_5_BLOCK_UNUSED;
} else {
/*
* Block used, but not marked in use in the bitmap.
*/
problem = PR_5_BLOCK_USED;
}
pctx.blk = i;
fix_problem(ctx, problem, &pctx);
if (pctx.blk == NO_BLK) {
pctx.blk = pctx.blk2 = i;
save_problem = problem;
} else {
if ((problem == save_problem) &&
(pctx.blk2 == i-1))
pctx.blk2++;
else {
print_bitmap_problem(ctx, save_problem, &pctx);
pctx.blk = pctx.blk2 = i;
save_problem = problem;
}
}
ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
had_problem++;
@ -165,8 +214,10 @@ redo_counts:
return;
}
}
if (pctx.blk != NO_BLK)
print_bitmap_problem(ctx, save_problem, &pctx);
if (had_problem)
fixit = end_problem_latch(ctx, PR_LATCH_BBITMAP);
fixit = end_problem_latch(ctx, PR_LATCH_BBITMAP);
else
fixit = -1;
ctx->flags &= ~E2F_FLAG_PROG_SUPPRESS;
@ -234,7 +285,7 @@ static void check_inode_bitmaps(e2fsck_t ctx)
int actual, bitmap;
errcode_t retval;
struct problem_context pctx;
int problem, fixit, had_problem;
int problem, save_problem, fixit, had_problem;
clear_problem_context(&pctx);
free_array = (int *) e2fsck_allocate_memory(ctx,
@ -272,6 +323,8 @@ static void check_inode_bitmaps(e2fsck_t ctx)
redo_counts:
had_problem = 0;
save_problem = 0;
pctx.ino = pctx.ino2 = 0;
for (i = 1; i <= fs->super->s_inodes_count; i++) {
actual = ext2fs_fast_test_inode_bitmap(ctx->inode_used_map, i);
bitmap = ext2fs_fast_test_inode_bitmap(fs->inode_map, i);
@ -283,15 +336,26 @@ redo_counts:
/*
* Inode wasn't used, but marked in bitmap
*/
problem = PR_5_UNUSED_INODE;
problem = PR_5_INODE_UNUSED;
} else /* if (actual && !bitmap) */ {
/*
* Inode used, but not in bitmap
*/
problem = PR_5_INODE_USED;
}
pctx.ino = i;
fix_problem(ctx, problem, &pctx);
if (pctx.ino == 0) {
pctx.ino = pctx.ino2 = i;
save_problem = problem;
} else {
if ((problem == save_problem) &&
(pctx.ino2 == i-1))
pctx.ino2++;
else {
print_bitmap_problem(ctx, save_problem, &pctx);
pctx.ino = pctx.ino2 = i;
save_problem = problem;
}
}
ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
had_problem++;
@ -319,6 +383,9 @@ do_counts:
return;
}
}
if (pctx.ino)
print_bitmap_problem(ctx, save_problem, &pctx);
if (had_problem)
fixit = end_problem_latch(ctx, PR_LATCH_IBITMAP);
else

View File

@ -1138,7 +1138,7 @@ static const struct e2fsck_problem problem_table[] = {
PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG},
/* Block not used, but marked in bitmap */
{ PR_5_UNUSED_BLOCK,
{ PR_5_BLOCK_UNUSED,
" -%b",
PROMPT_NONE, PR_LATCH_BBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
@ -1158,7 +1158,7 @@ static const struct e2fsck_problem problem_table[] = {
PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG },
/* Inode not used, but marked in bitmap */
{ PR_5_UNUSED_INODE,
{ PR_5_INODE_UNUSED,
" -%i",
PROMPT_NONE, PR_LATCH_IBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
@ -1218,6 +1218,26 @@ static const struct e2fsck_problem problem_table[] = {
"Error copying in replacement @b @B: %m\n",
PROMPT_NONE, PR_FATAL },
/* Block range not used, but marked in bitmap */
{ PR_5_BLOCK_RANGE_UNUSED,
" -(%b--%c)",
PROMPT_NONE, PR_LATCH_BBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
/* Block range used, but not marked used in bitmap */
{ PR_5_BLOCK_RANGE_USED,
" +(%b--%c)",
PROMPT_NONE, PR_LATCH_BBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
/* Inode range not used, but marked in bitmap */
{ PR_5_INODE_RANGE_UNUSED,
" -(%i--%j)",
PROMPT_NONE, PR_LATCH_IBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
/* Inode range used, but not marked used in bitmap */
{ PR_5_INODE_RANGE_USED,
" +(%i--%j)",
PROMPT_NONE, PR_LATCH_IBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
{ 0 }
};
@ -1317,7 +1337,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
ptr = find_problem(code);
if (!ptr) {
printf(_("Unhandled error code (%d)!\n"), code);
printf(_("Unhandled error code (0x%x)!\n"), code);
return 0;
}
def_yn = 1;

View File

@ -683,7 +683,7 @@ struct problem_context {
#define PR_5_BLOCK_BITMAP_HEADER 0x050003
/* Block not used, but marked in bitmap */
#define PR_5_UNUSED_BLOCK 0x050004
#define PR_5_BLOCK_UNUSED 0x050004
/* Block used, but not marked used in bitmap */
#define PR_5_BLOCK_USED 0x050005
@ -695,7 +695,7 @@ struct problem_context {
#define PR_5_INODE_BITMAP_HEADER 0x050007
/* Inode not used, but marked in bitmap */
#define PR_5_UNUSED_INODE 0x050008
#define PR_5_INODE_UNUSED 0x050008
/* Inode used, but not marked used in bitmap */
#define PR_5_INODE_USED 0x050009
@ -730,6 +730,18 @@ struct problem_context {
/* Error copying in replacement block bitmap */
#define PR_5_COPY_BBITMAP_ERROR 0x050013
/* Block range not used, but marked in bitmap */
#define PR_5_BLOCK_RANGE_UNUSED 0x050014
/* Block range used, but not marked used in bitmap */
#define PR_5_BLOCK_RANGE_USED 0x050015
/* Inode range not used, but marked in bitmap */
#define PR_5_INODE_RANGE_UNUSED 0x050016
/* Inode rangeused, but not marked used in bitmap */
#define PR_5_INODE_RANGE_USED 0x050017
/*
* Function declarations
*/

View File

@ -1,3 +1,12 @@
2002-03-06 <tytso@snap.thunk.org>
* f_badorphan, f_badtable, f_bbinode, f_dupsuper, f_expand,
f_illbbitmap, f_illibitmap, f_illitable, f_imagic,
f_imagic_fs, f_lotsbad, f_lpf, f_messy_inode,
f_miss_blk_bmap, f_misstable, f_overfsblks: Adjust expect
files to deal with the fact that e2fsck is now reporting
ranges during pass 5.
2002-02-12 Theodore Tso <tytso@mit.edu>
* run_e2fsck (status): Use separate sed invocations for greater

View File

@ -48,7 +48,7 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -1363 -1364 -1365 -1366 -1367 -1368 -1369 -1370 -1371 -1372 -1373 -1374 -1375 -1376 -1377 -1378 -1379 -1380 -1381 -1382 -1383 -1384 -1385 -1386 -1387 -1388 -1389 -1390 -1391 -1392 -1393 -1394 -1395 -1396 -1397 -1398 -1399 -1401 -1402 -1403 -1404 -1405 -1461 -1505 -1506 -1507 -1508 -1509 -1510 -1511 -1512 -1513 -1514 -1515 -1516 -1517 -1518 -1519 -1520 -1521 -1522 -1523 -1524 -1525 -1526 -1527 -1528 -1529 -1530 -1531 -1532 -1533 -1538 -1539 -1540 -1566 -1567 -1568 -1569 -1570 -1571 -1572 -1573 -1574 -1593 -1594 -1595 -1596 -1597 -1598 -1599 -1600 -1604 -1605 -1654 -1656 -1657 -1658 -1659 -1660 -1661 -1662 -1663 -1664 -1665 -1666 -1667 -1668 -1669 -1670 -1671 -1672 -1673 -1674 -1675 -1676 -1677 -1678 -1679 -1680 -1681 -1682 -1683 -1684 -1685 -1686 -1687 -1688 -1689 -1690 -1691 -1692 -1693 -1694 -1695 -1696 -1697 -1698 -1699 -1700 -1701 -1702 -1703 -1706 -1707 -1708 -1709 -1710 -1711 -1712 -1713 -1714 -1715 -1716 -1717 -1718 -1719 -1720 -1721 -1722 -1723 -1724 -1725 -1726 -1728 -1803 -1804 -1913 -2286 -2287 -2288 -2289 -2290 -2291 -2292 -2293 -2294 -2295 -2392 -2960 -2961 -2962 -2963 -2964 -2965 -2966 -2967 -2968 -2969 -2970 -2971 -2972 -2973 -3118 -3119 -3120 -3121 -3122 -3123 -3124 -3125 -3126 -3127 -3128 -3129 -3130 -3131 -3132 -3133 -3134 -3135 -3136 -3137 -3138 -3139 -3140 -3141 -3142 -3143 -3144 -3145 -3146 -3147 -3148 -3149 -3150 -3151 -3152 -3153 -3154 -3345 -3451 -3452 -3569 -3748 -3749 -4409 -4411 -4412 -4413 -4414 -4435 -4436 -4437 -4438 -4439 -4440 -4441 -4442 -4443 -4444 -4445 -4446 -4447 -4448 -4449 -4450 -4451 -4452 -4453 -4454 -4455 -4456 -4720 -4721 -4722 -4723 -4724 -4725 -4929 -4967 -4968 -4969 -4970 -4971 -4972 -4973 -4974 -4975 -4976 -4977 -4978 -4979 -4980 -4981 -4982 -4983 -4984 -5258 -5259 -5260 -5261 -5262 -5263 -5264 -5265 -5266 -5267 -5268 -5269 -5270 -5271 -5272 -5273 -5274 -5275 -5352 -5353 -5354 -5412 -5413 -5414 -5415 -5416 -5417 -5418 -5419 -5420 -5421 -5422 -5423 -5424 -5425 -5493 -5620 -5621 -5622 -5623 -5624 -5625 -5626 -5627 -5628 -5629 -5630 -5631 -5632 -5633 -5634 -5635 -5636 -5637 -5638 -5639 -5640 -5641 -5642 -5643 -5644 -5645 -5646 -5647 -5676 -5677 -5720 -5721 -5722 -5723 -5724 -5725 -5726 -5727 -5728 -5729 -5730 -5731 -5732 -5733 -5734 -5735 -5736 -5737 -5738 -5739 -5740 -5741 -5742 -5743 -5744 -5760 -5761 -5762 -5763 -5764 -5765 -5766 -5767 -5768 -5769 -5770 -5771 -5772 -5773 -5774 -5775 -5776 -5777 -5778 -5779 -5780 -5781 -5782 -5783 -5784 -5785 -5786 -5787 -5788 -6013
Block bitmap differences: -(1363--1399) -(1401--1405) -1461 -(1505--1533) -(1538--1540) -(1566--1574) -(1593--1600) -(1604--1605) -1654 -(1656--1703) -(1706--1726) -1728 -(1803--1804) -1913 -(2286--2295) -2392 -(2960--2973) -(3118--3154) -3345 -(3451--3452) -3569 -(3748--3749) -4409 -(4411--4414) -(4435--4456) -(4720--4725) -4929 -(4967--4984) -(5258--5275) -(5352--5354) -(5412--5425) -5493 -(5620--5647) -(5676--5677) -(5720--5744) -(5760--5788) -6013
Fix? yes
Free blocks count wrong for group #0 (5801, counted=6210).
@ -57,7 +57,7 @@ Fix? yes
Free blocks count wrong (5801, counted=6210).
Fix? yes
Inode bitmap differences: -13 -17 -18 -19 -22 -23 -24 -25 -26 -27 -28 -30 -33 -36 -38 -43 -44 -46 -47 -51 -53 -56 -61 -65 -70 -71 -75 -77 -83 -84 -85 -87 -91 -93 -96 -97 -99 -109
Inode bitmap differences: -13 -(17--19) -(22--28) -30 -33 -36 -38 -(43--44) -(46--47) -51 -53 -56 -61 -65 -(70--71) -75 -77 -(83--85) -87 -91 -93 -(96--97) -99 -109
Fix? yes
Free inodes count wrong for group #0 (1951, counted=1989).

View File

@ -18,7 +18,7 @@ Pass 4: Checking reference counts
Inode 2 ref count is 4, should be 3. Fix? yes
Pass 5: Checking group summary information
Block bitmap differences: -12 -13 -14 -15 -16 -17 -18 -19 -20
Block bitmap differences: -(12--20)
Fix? yes
Free blocks count wrong for group #0 (78, counted=87).
@ -27,7 +27,7 @@ Fix? yes
Free blocks count wrong (78, counted=87).
Fix? yes
Inode bitmap differences: +12 +13 +14 +15 +16 +25 +26 +27 +28 +29 +30 +31 +32
Inode bitmap differences: +(12--16) +(25--32)
Fix? yes
Free inodes count wrong for group #0 (21, counted=7).

View File

@ -36,7 +36,7 @@ Fix? yes
Free blocks count wrong (1962, counted=1965).
Fix? yes
Inode bitmap differences: +41 +42 +43 +44 +45 +46 +47 +48
Inode bitmap differences: +(41--48)
Fix? yes
Free inodes count wrong for group #0 (485, counted=477).

View File

@ -17,7 +17,7 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -29 -30 -31
Block bitmap differences: -(29--31)
Fix? yes

View File

@ -11458,7 +11458,7 @@ Connect to /lost+found? yes
Inode 5109 ref count is 2, should be 1. Fix? yes
Pass 5: Checking group summary information
Block bitmap differences: -776 -777 -778 -779 -780 -781 -782 -783 -784 -785 -786
Block bitmap differences: -(776--786)
Fix? yes
Free blocks count wrong for group #0 (86, counted=97).

View File

@ -16,10 +16,10 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21
Block bitmap differences: +(1--21)
Fix? yes
Inode bitmap differences: -12 -13 -14 -15 -16 -17 -18 -19 -20 -21
Inode bitmap differences: -(12--21)
Fix? yes

View File

@ -16,7 +16,7 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Inode bitmap differences: +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11
Inode bitmap differences: +(1--11)
Fix? yes

View File

@ -25,7 +25,7 @@ Root inode not allocated. Allocate? yes
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21
Block bitmap differences: -(11--21)
Fix? yes
Free blocks count wrong for group #0 (78, counted=89).

View File

@ -23,7 +23,7 @@ Connect to /lost+found? yes
Inode 14 ref count is 2, should be 1. Fix? yes
Pass 5: Checking group summary information
Block bitmap differences: -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19
Block bitmap differences: -(9--19)
Fix? yes
Free blocks count wrong for group #0 (76, counted=87).

View File

@ -7,7 +7,7 @@ Pass 4: Checking reference counts
Inode 2 ref count is 4, should be 3. Fix? yes
Pass 5: Checking group summary information
Block bitmap differences: -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19
Block bitmap differences: -(9--19)
Fix? yes
Free blocks count wrong for group #0 (76, counted=87).

View File

@ -25,7 +25,7 @@ Entry 'termcap' in / (2) has deleted/unused inode 12. Clear? yes
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -44 -45
Block bitmap differences: -(27--41) -(44--45)
Fix? yes
Free blocks count wrong for group #0 (41, counted=58).

View File

@ -24,7 +24,7 @@ Connect to /lost+found? yes
Inode 15 ref count is 2, should be 1. Fix? yes
Pass 5: Checking group summary information
Block bitmap differences: +22 +23 +49 +57 +58
Block bitmap differences: +(22--23) +49 +(57--58)
Fix? yes
Free blocks count wrong for group #0 (25, counted=33).

View File

@ -23,7 +23,7 @@ Clear? yes
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -43 -44 -45 -46 -47 -48 -49
Block bitmap differences: -(43--49)
Fix? yes
Free blocks count wrong for group #0 (68, counted=75).

View File

@ -4,7 +4,7 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10
Block bitmap differences: +(0--10)
Fix? yes
Free blocks count wrong for group #0 (90, counted=89).

View File

@ -21,7 +21,7 @@ Pass 4: Checking reference counts
Inode 2 ref count is 8, should be 4. Fix? yes
Pass 5: Checking group summary information
Block bitmap differences: -8385 -8386 -8387 -8388 -8389 -8390 -8391 -8392 -8393 -8394 -8395 -8396 -8397 -8398 -8399 -8400 -8401 -8402 -8403 -8404 -8405
Block bitmap differences: -(8385--8405)
Fix? yes
Free blocks count wrong for group #0 (7987, counted=7984).
@ -30,7 +30,7 @@ Fix? yes
Free blocks count wrong (11602, counted=11599).
Fix? yes
Inode bitmap differences: -1505 -1506 -1507 -1508 -1509 -1510 -1511 -1512 -1513 -1514 -1515 -1516
Inode bitmap differences: -(1505--1516)
Fix? yes
Free inodes count wrong for group #0 (1493, counted=1489).

View File

@ -9,7 +9,7 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Inode bitmap differences: -12 -13 -14 -15 -16 -17 -18 -19 -20 -21
Inode bitmap differences: -(12--21)
Fix? yes