void *in);
errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
ext2fs_block_bitmap *bitmap);
+errcode_t ext2fs_count_used_clusters(ext2_filsys fs, blk64_t start,
+ blk64_t end, blk64_t *out);
/* get_num_dirs.c */
extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs);
return ENOENT;
}
+
+errcode_t ext2fs_count_used_clusters(ext2_filsys fs, blk64_t start,
+ blk64_t end, blk64_t *out)
+{
+ blk64_t next;
+ blk64_t tot_set = 0;
+ errcode_t retval;
+
+ while (start < end) {
+ retval = ext2fs_find_first_set_block_bitmap2(fs->block_map,
+ start, end, &next);
+ if (retval) {
+ if (retval == ENOENT)
+ retval = 0;
+ break;
+ }
+ start = next;
+
+ retval = ext2fs_find_first_zero_block_bitmap2(fs->block_map,
+ start, end, &next);
+ if (retval == 0) {
+ tot_set += next - start;
+ start = next + 1;
+ } else if (retval == ENOENT) {
+ retval = 0;
+ tot_set += end - start + 1;
+ break;
+ } else
+ break;
+ }
+
+ if (!retval)
+ *out = EXT2FS_NUM_B2C(fs, tot_set);
+ return retval;
+}
errcode_t retval = 0;
ext2_filsys fs;
badblocks_list bb_list = 0;
+ badblocks_iterate bb_iter;
+ blk_t blk;
unsigned int journal_blocks = 0;
unsigned int i, checkinterval;
int max_mnt_count;
char opt_string[40];
char *hash_alg_str;
int itable_zeroed = 0;
+ blk64_t overhead;
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
if (!quiet)
printf("%s", _("done \n"));
+ /*
+ * Unmark bad blocks to calculate overhead, because metadata
+ * blocks and bad blocks can land on the same allocation cluster.
+ */
+ if (bb_list) {
+ retval = ext2fs_badblocks_list_iterate_begin(bb_list,
+ &bb_iter);
+ if (retval) {
+ com_err("ext2fs_badblocks_list_iterate_begin", retval,
+ "%s", _("while unmarking bad blocks"));
+ exit(1);
+ }
+ while (ext2fs_badblocks_list_iterate(bb_iter, &blk))
+ ext2fs_unmark_block_bitmap2(fs->block_map, blk);
+ ext2fs_badblocks_list_iterate_end(bb_iter);
+ }
+
retval = ext2fs_convert_subcluster_bitmap(fs, &fs->block_map);
if (retval) {
com_err(program_name, retval, "%s",
exit(1);
}
+ retval = ext2fs_count_used_clusters(fs, fs->super->s_first_data_block,
+ ext2fs_blocks_count(fs->super) - 1,
+ &overhead);
+ if (retval) {
+ com_err(program_name, retval, "%s",
+ _("while calculating overhead"));
+ exit(1);
+ }
+
+ if (bb_list) {
+ retval = ext2fs_badblocks_list_iterate_begin(bb_list,
+ &bb_iter);
+ if (retval) {
+ com_err("ext2fs_badblocks_list_iterate_begin", retval,
+ "%s", _("while marking bad blocks as used"));
+ exit(1);
+ }
+ while (ext2fs_badblocks_list_iterate(bb_iter, &blk))
+ ext2fs_mark_block_bitmap2(fs->block_map, blk);
+ ext2fs_badblocks_list_iterate_end(bb_iter);
+ }
+
if (super_only) {
check_plausibility(device_name, CHECK_FS_EXIST, NULL);
printf(_("%s may be further corrupted by superblock rewrite\n"),
free(journal_device);
} else if ((journal_size) ||
ext2fs_has_feature_journal(&fs_param)) {
+ overhead += EXT2FS_NUM_B2C(fs, journal_blocks);
if (super_only) {
printf("%s", _("Skipping journal creation in super-only mode\n"));
fs->super->s_journal_inum = EXT2_JOURNAL_INO;
fs->super->s_mmp_update_interval);
}
+ overhead += fs->super->s_first_data_block;
+ if (!super_only)
+ fs->super->s_overhead_clusters = overhead;
+
if (ext2fs_has_feature_bigalloc(&fs_param))
fix_cluster_bg_counts(fs);
if (ext2fs_has_feature_quota(&fs_param))
double percent;
ext2fs_blocks_count_set(fs->super, new_size);
+ fs->super->s_overhead_clusters = 0;
retry:
fs->group_desc_count = ext2fs_div64_ceil(ext2fs_blocks_count(fs->super) -
Change in FS metadata:
-@@ -10,7 +10,7 @@
- Inode count: 65536
+@@ -11,7 +11,7 @@
Block count: 524288
Reserved block count: 26214
+ Overhead clusters: 35246
-Free blocks: 570
+Free blocks: 567
Free inodes: 65047
First block: 1
Block size: 1024
-@@ -47,8 +47,8 @@
+@@ -48,8 +48,8 @@
Block bitmap at 262 (+261)
Inode bitmap at 278 (+277)
Inode table at 294-549 (+293)
Inode count: 128
Block count: 1024
Reserved block count: 51
+Overhead clusters: 28
Free blocks: 982
Free inodes: 117
First block: 1
Inode count: 1344
Block count: 2750000
Reserved block count: 137500
+Overhead clusters: 1286982
Free blocks: 1463011
Free inodes: 1333
First block: 0
Inode count: 16384
Block count: 32768
Reserved block count: 1638
+Overhead clusters: 1094
Free blocks: 31664
Free inodes: 16373
First block: 0
Inode count: 8192
Block count: 131072
Reserved block count: 6553
+Overhead clusters: 4284
Free blocks: 126774
Free inodes: 8181
First block: 1
Inode count: 16384
Block count: 65536
Reserved block count: 3276
+Overhead clusters: 7446
Free blocks: 58076
Free inodes: 16373
First block: 1
Inode count: 64
Block count: 16384
Reserved block count: 819
+Overhead clusters: 11
Free blocks: 16367
Free inodes: 53
First block: 0
Inode count: 32768
Block count: 131072
Reserved block count: 6553
+Overhead clusters: 4376
Free blocks: 126683
Free inodes: 32757
First block: 1
Inode count: 1024
Block count: 16384
Reserved block count: 819
+Overhead clusters: 265
Free blocks: 16065
Free inodes: 1006
First block: 1
Inode count: 65536
Block count: 65536
Reserved block count: 3276
+Overhead clusters: 2086
Free blocks: 63443
Free inodes: 65525
First block: 0
Inode count: 16384
Block count: 65536
Reserved block count: 3276
+Overhead clusters: 2081
Free blocks: 63442
Free inodes: 16373
First block: 1
Inode count: 32768
Block count: 131072
Reserved block count: 6553
+Overhead clusters: 9773
Free blocks: 121267
Free inodes: 32756
First block: 1
Inode count: 32768
Block count: 131072
Reserved block count: 6553
+Overhead clusters: 7224
Free blocks: 123834
Free inodes: 32757
First block: 1
Inode count: 960
Block count: 3840
Reserved block count: 192
+Overhead clusters: 1122
Free blocks: 2713
Free inodes: 949
First block: 0
Inode count: 128
Block count: 1024
Reserved block count: 51
+Overhead clusters: 24
Free blocks: 986
Free inodes: 117
First block: 1
Inode count: 1024
Block count: 16384
Reserved block count: 819
+Overhead clusters: 1543
Free blocks: 14786
Free inodes: 1005
First block: 1
Inode count: 16384
Block count: 65536
Reserved block count: 3276
+Overhead clusters: 3350
Free blocks: 62172
Free inodes: 16373
First block: 1
Inode count: 32768
Block count: 131072
Reserved block count: 6553
+Overhead clusters: 5677
Free blocks: 125381
Free inodes: 32757
First block: 1
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -15,7 +15,8 @@
+@@ -10,13 +10,13 @@
+ Inode count: 65536
+ Block count: 524288
+ Reserved block count: 26214
+-Overhead clusters: 35228
+ Free blocks: 589
+ Free inodes: 65048
First block: 1
Block size: 1024
Fragment size: 1024
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 1024
-@@ -40,16 +41,16 @@
+@@ -41,16 +41,16 @@
group:block:super:gdt:bbitmap:ibitmap:itable
10:81921:-1:-1:270:286:2852
11:90113:-1:-1:271:287:3108
12:98305:-1:-1:272:288:3364
-@@ -65,9 +66,9 @@
+@@ -66,9 +66,9 @@
22:180225:-1:-1:131079:131095:132641
23:188417:-1:-1:131080:131096:132897
24:196609:-1:-1:131081:131097:133153
28:229377:-1:-1:131085:131101:134177
29:237569:-1:-1:131086:131102:134433
30:245761:-1:-1:131087:131103:134689
-@@ -89,7 +90,7 @@
+@@ -90,7 +90,7 @@
46:376833:-1:-1:262159:262175:265761
47:385025:-1:-1:262160:262176:266017
48:393217:-1:-1:393217:393233:393249
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -10,11 +10,12 @@
+@@ -10,12 +10,12 @@
Inode count: 65536
Block count: 524288
Reserved block count: 26214
+-Overhead clusters: 32912
-Free blocks: 858
+Free blocks: 852
Free inodes: 65046
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 1024
-@@ -54,9 +55,9 @@
+@@ -55,9 +55,9 @@
12:98305:-1:-1:15:31:3107
13:106497:-1:-1:16:32:3363
14:114689:-1:-1:17:33:3619
18:147457:-1:-1:131075:131091:131617
19:155649:-1:-1:131076:131092:131873
20:163841:-1:-1:131077:131093:132129
-@@ -86,9 +87,9 @@
+@@ -87,9 +87,9 @@
44:360449:-1:-1:262158:262174:265250
45:368641:-1:-1:262159:262175:265506
46:376833:-1:-1:262160:262176:265762
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -10,11 +10,12 @@
+@@ -10,12 +10,12 @@
Inode count: 98304
Block count: 786432
Reserved block count: 39321
+-Overhead clusters: 41193
-Free blocks: 764
+Free blocks: 734
Free inodes: 97566
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 1024
-@@ -38,16 +39,16 @@
+@@ -39,16 +39,16 @@
group:block:super:gdt:bbitmap:ibitmap:itable
10:81921:-1:-1:81921:81922:81923
11:90113:-1:-1:90113:90114:90115
12:98305:-1:-1:98305:98306:98307
-@@ -63,9 +64,9 @@
+@@ -64,9 +64,9 @@
22:180225:-1:-1:180225:180226:180227
23:188417:-1:-1:188417:188418:188419
24:196609:-1:-1:196609:196610:196611
28:229377:-1:-1:229377:229378:229379
29:237569:-1:-1:237569:237570:237571
30:245761:-1:-1:245761:245762:245763
-@@ -87,7 +88,7 @@
+@@ -88,7 +88,7 @@
46:376833:-1:-1:376833:376834:376835
47:385025:-1:-1:385025:385026:385027
48:393217:-1:-1:393217:393218:393219
50:409601:-1:-1:409601:409602:409603
51:417793:-1:-1:417793:417794:417795
52:425985:-1:-1:425985:425986:425987
-@@ -119,7 +120,7 @@
+@@ -120,7 +120,7 @@
78:638977:-1:-1:638977:638978:638979
79:647169:-1:-1:647169:647170:647171
80:655361:-1:-1:655361:655362:655363
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -10,12 +10,11 @@
+@@ -10,13 +10,11 @@
Inode count: 65536
Block count: 524288
Reserved block count: 26214
+-Overhead clusters: 35246
-Free blocks: 571
+Free blocks: 589
Free inodes: 65048
Reserved GDT blocks: 256
Blocks per group: 8192
Fragments per group: 8192
-@@ -41,16 +40,16 @@
+@@ -42,16 +40,16 @@
group:block:super:gdt:bbitmap:ibitmap:itable
10:81921:-1:-1:272:288:2854
11:90113:-1:-1:273:289:3110
12:98305:-1:-1:274:290:3366
-@@ -66,9 +65,9 @@
+@@ -67,9 +65,9 @@
22:180225:-1:-1:131079:131095:132641
23:188417:-1:-1:131080:131096:132897
24:196609:-1:-1:131081:131097:133153
28:229377:-1:-1:131085:131101:134177
29:237569:-1:-1:131086:131102:134433
30:245761:-1:-1:131087:131103:134689
-@@ -90,7 +89,7 @@
+@@ -91,7 +89,7 @@
46:376833:-1:-1:262159:262175:265761
47:385025:-1:-1:262160:262176:266017
48:393217:-1:-1:393217:393233:393249
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -10,12 +10,11 @@
+@@ -10,13 +10,11 @@
Inode count: 65536
Block count: 524288
Reserved block count: 26214
+-Overhead clusters: 32918
-Free blocks: 852
+Free blocks: 858
Free inodes: 65046
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 1024
-@@ -55,9 +54,9 @@
+@@ -56,9 +54,9 @@
12:98305:-1:-1:15:31:3107
13:106497:-1:-1:16:32:3363
14:114689:-1:-1:17:33:3619
18:147457:-1:-1:131076:131092:131618
19:155649:-1:-1:131077:131093:131874
20:163841:-1:-1:131078:131094:132130
-@@ -87,9 +86,9 @@
+@@ -88,9 +86,9 @@
44:360449:-1:-1:262158:262174:265250
45:368641:-1:-1:262159:262175:265506
46:376833:-1:-1:262160:262176:265762
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -33,7 +33,6 @@
+@@ -34,7 +34,6 @@
Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -33,7 +33,6 @@
+@@ -34,7 +34,6 @@
Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Journal features: (none)
Journal size: 16M
Journal length: 16384
-@@ -47,18 +46,18 @@
+@@ -48,18 +47,18 @@
Block bitmap at 262 (+261)
Inode bitmap at 278 (+277)
Inode table at 294-549 (+293)
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -33,7 +33,6 @@
+@@ -34,7 +34,6 @@
Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -10,7 +10,7 @@
- Inode count: 65536
+@@ -11,7 +11,7 @@
Block count: 524288
Reserved block count: 26214
+ Overhead clusters: 35246
-Free blocks: 571
+Free blocks: 568
Free inodes: 65048
First block: 1
Block size: 1024
-@@ -33,6 +33,7 @@
+@@ -34,6 +34,7 @@
Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Journal features: (none)
Journal size: 16M
Journal length: 16384
-@@ -46,8 +47,8 @@
+@@ -47,8 +48,8 @@
Block bitmap at 262 (+261)
Inode bitmap at 278 (+277)
Inode table at 294-549 (+293)
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -29,6 +29,7 @@
+@@ -30,6 +30,7 @@
Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Journal features: (none)
Journal size: 16M
Journal length: 16384
-@@ -36,7 +37,7 @@
+@@ -37,7 +38,7 @@
Journal start: 0
Primary superblock at 1, Group descriptors at 2-3
Reserved GDT blocks at 4-259
Block bitmap at 260 (+259)
-@@ -45,7 +46,7 @@
+@@ -46,7 +47,7 @@
0 free blocks, 1013 free inodes, 2 directories
Free blocks:
Free inodes: 12-1024
Backup superblock at 8193, Group descriptors at 8194-8195
Reserved GDT blocks at 8196-8451
Block bitmap at 8452 (+259)
-@@ -54,6 +55,6 @@
+@@ -55,6 +56,6 @@
0 free blocks, 1024 free inodes, 0 directories
Free blocks:
Free inodes: 1025-2048
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
-@@ -10,7 +10,7 @@
- Inode count: 65536
+@@ -11,7 +11,7 @@
Block count: 524288
Reserved block count: 26214
+ Overhead clusters: 35246
-Free blocks: 571
+Free blocks: 568
Free inodes: 65048
First block: 1
Block size: 1024
-@@ -33,6 +33,7 @@
+@@ -34,6 +34,7 @@
Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Journal features: (none)
Journal size: 16M
Journal length: 16384
-@@ -40,24 +41,24 @@
+@@ -41,24 +42,24 @@
Journal start: 0
Setting inode size 256
Exit status is 0
Change in FS metadata:
-@@ -13 +13 @@
+@@ -14 +14 @@
-Free blocks: 12301
+Free blocks: 12
-@@ -22 +22 @@
+@@ -23 +23 @@
-Inode blocks per group: 128
+Inode blocks per group: 256
-@@ -28 +28 @@
+@@ -29 +29 @@
-Inode size: 128
+Inode size: 256
Pass 1: Checking inodes, blocks, and sizes
@@ -5 +5 @@
-Filesystem features: has_journal ext_attr dir_index filetype extent 64bit sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
+Filesystem features: has_journal ext_attr dir_index filetype extent 64bit sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
-@@ -21 +21 @@
+@@ -22 +22 @@
-Inode blocks per group: 128
+Inode blocks per group: 256
-@@ -27 +27 @@
+@@ -28 +28 @@
-Inode size: 128
+Inode size: 256
-@@ -30,0 +31 @@
+@@ -31,0 +32 @@
+Checksum type: crc32c
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure