Lines Matching +full:cs +full:- +full:value +full:- +full:bit

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
58 struct csum *cs; in pass5() local
65 inoinfo(UFS_WINO)->ino_state = USTATE; in pass5()
66 memset(newcg, 0, (size_t)fs->fs_cgsize); in pass5()
67 newcg->cg_niblk = fs->fs_ipg; in pass5()
72 if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) { in pass5()
76 fs->fs_contigsumsize = 0; in pass5()
81 if (fs->fs_maxcontig > 1) { in pass5()
84 if (fs->fs_contigsumsize < 1) { in pass5()
86 } else if (fs->fs_contigsumsize < fs->fs_maxcontig && in pass5()
87 fs->fs_contigsumsize < FS_MAXCONTIG) { in pass5()
91 i = fs->fs_contigsumsize; in pass5()
92 fs->fs_contigsumsize = in pass5()
93 MIN(fs->fs_maxcontig, FS_MAXCONTIG); in pass5()
94 if (CGSIZE(fs) > (u_int)fs->fs_bsize) { in pass5()
96 fs->fs_contigsumsize = i; in pass5()
102 fs->fs_cgsize = in pass5()
112 newcg->cg_iusedoff = basesize; in pass5()
120 newcg->cg_old_btotoff = basesize; in pass5()
121 newcg->cg_old_boff = newcg->cg_old_btotoff + in pass5()
122 fs->fs_old_cpg * sizeof(int32_t); in pass5()
123 newcg->cg_iusedoff = newcg->cg_old_boff + in pass5()
124 fs->fs_old_cpg * fs->fs_old_nrpos * sizeof(u_int16_t); in pass5()
125 memset(&newcg[1], 0, newcg->cg_iusedoff - basesize); in pass5()
127 inomapsize = howmany(fs->fs_ipg, CHAR_BIT); in pass5()
128 newcg->cg_freeoff = newcg->cg_iusedoff + inomapsize; in pass5()
129 blkmapsize = howmany(fs->fs_fpg, CHAR_BIT); in pass5()
130 newcg->cg_nextfreeoff = newcg->cg_freeoff + blkmapsize; in pass5()
131 if (fs->fs_contigsumsize > 0) { in pass5()
132 newcg->cg_clustersumoff = newcg->cg_nextfreeoff - in pass5()
134 newcg->cg_clustersumoff = in pass5()
135 roundup(newcg->cg_clustersumoff, sizeof(u_int32_t)); in pass5()
136 newcg->cg_clusteroff = newcg->cg_clustersumoff + in pass5()
137 (fs->fs_contigsumsize + 1) * sizeof(u_int32_t); in pass5()
138 newcg->cg_nextfreeoff = newcg->cg_clusteroff + in pass5()
139 howmany(fragstoblks(fs, fs->fs_fpg), CHAR_BIT); in pass5()
141 newcg->cg_magic = CG_MAGIC; in pass5()
142 mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff; in pass5()
147 dmax = blknum(fs, fs->fs_size + fs->fs_frag - 1); in pass5()
148 for (d = fs->fs_size; d < dmax; d++) in pass5()
150 for (c = 0; c < fs->fs_ncg; c++) { in pass5()
163 cg = cgbp->b_un.b_cg; in pass5()
170 if ((fs->fs_metackhash & CK_CYLGRP) != 0 && in pass5()
174 ckhash = cg->cg_ckhash; in pass5()
175 cg->cg_ckhash = 0; in pass5()
176 thishash = calculate_crc32c(~0L, cg, fs->fs_cgsize); in pass5()
178 cg->cg_ckhash = ckhash; in pass5()
180 pwarn("CG %d: BAD CHECK-HASH %#x vs %#x\n", in pass5()
182 cg->cg_ckhash = thishash; in pass5()
186 newcg->cg_time = cg->cg_time; in pass5()
187 newcg->cg_old_time = cg->cg_old_time; in pass5()
188 newcg->cg_unrefs = cg->cg_unrefs; in pass5()
189 newcg->cg_ckhash = cg->cg_ckhash; in pass5()
190 newcg->cg_cgx = c; in pass5()
192 dmax = dbase + fs->fs_fpg; in pass5()
193 if (dmax > fs->fs_size) in pass5()
194 dmax = fs->fs_size; in pass5()
195 newcg->cg_ndblk = dmax - dbase; in pass5()
196 if (fs->fs_magic == FS_UFS1_MAGIC) { in pass5()
197 if (c == fs->fs_ncg - 1) in pass5()
198 newcg->cg_old_ncyl = howmany(newcg->cg_ndblk, in pass5()
199 fs->fs_fpg / fs->fs_old_cpg); in pass5()
201 newcg->cg_old_ncyl = fs->fs_old_cpg; in pass5()
202 newcg->cg_old_niblk = fs->fs_ipg; in pass5()
203 newcg->cg_niblk = 0; in pass5()
205 if (fs->fs_contigsumsize > 0) in pass5()
206 newcg->cg_nclusterblks = newcg->cg_ndblk / fs->fs_frag; in pass5()
207 newcg->cg_cs.cs_ndir = 0; in pass5()
208 newcg->cg_cs.cs_nffree = 0; in pass5()
209 newcg->cg_cs.cs_nbfree = 0; in pass5()
210 newcg->cg_cs.cs_nifree = fs->fs_ipg; in pass5()
211 if (cg->cg_rotor >= 0 && cg->cg_rotor < newcg->cg_ndblk) in pass5()
212 newcg->cg_rotor = cg->cg_rotor; in pass5()
214 newcg->cg_rotor = 0; in pass5()
215 if (cg->cg_frotor >= 0 && cg->cg_frotor < newcg->cg_ndblk) in pass5()
216 newcg->cg_frotor = cg->cg_frotor; in pass5()
218 newcg->cg_frotor = 0; in pass5()
219 if (cg->cg_irotor >= 0 && cg->cg_irotor < fs->fs_ipg) in pass5()
220 newcg->cg_irotor = cg->cg_irotor; in pass5()
222 newcg->cg_irotor = 0; in pass5()
223 if (fs->fs_magic == FS_UFS1_MAGIC) { in pass5()
224 newcg->cg_initediblk = 0; in pass5()
226 if ((unsigned)cg->cg_initediblk > fs->fs_ipg) in pass5()
227 newcg->cg_initediblk = fs->fs_ipg; in pass5()
229 newcg->cg_initediblk = cg->cg_initediblk; in pass5()
231 memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum); in pass5()
233 inum = fs->fs_ipg * c; in pass5()
235 switch (inoinfo(inum)->ino_state) { in pass5()
244 newcg->cg_cs.cs_ndir++; in pass5()
250 newcg->cg_cs.cs_nifree--; in pass5()
258 inoinfo(inum)->ino_state, (uintmax_t)inum); in pass5()
264 newcg->cg_cs.cs_nifree--; in pass5()
266 start = -1; in pass5()
269 d += fs->fs_frag, i += fs->fs_frag) { in pass5()
271 for (j = 0; j < fs->fs_frag; j++) { in pass5()
273 if ((Eflag || Zflag) && start != -1) { in pass5()
274 clear_blocks(start, d + j - 1); in pass5()
275 start = -1; in pass5()
279 if (start == -1) in pass5()
284 if (frags == fs->fs_frag) { in pass5()
285 newcg->cg_cs.cs_nbfree++; in pass5()
286 if (fs->fs_contigsumsize > 0) in pass5()
288 i / fs->fs_frag); in pass5()
290 newcg->cg_cs.cs_nffree += frags; in pass5()
292 ffs_fragacct(fs, blk, newcg->cg_frsum, 1); in pass5()
295 if ((Eflag || Zflag) && start != -1) in pass5()
296 clear_blocks(start, d - 1); in pass5()
297 if (fs->fs_contigsumsize > 0) { in pass5()
301 int bit = 1; in pass5() local
304 for (i = 0; i < newcg->cg_nclusterblks; i++) { in pass5()
305 if ((map & bit) != 0) { in pass5()
308 if (run > fs->fs_contigsumsize) in pass5()
309 run = fs->fs_contigsumsize; in pass5()
313 if ((i & (CHAR_BIT - 1)) != (CHAR_BIT - 1)) { in pass5()
314 bit <<= 1; in pass5()
317 bit = 1; in pass5()
321 if (run > fs->fs_contigsumsize) in pass5()
322 run = fs->fs_contigsumsize; in pass5()
328 cstotal.cs_nffree += cg->cg_cs.cs_nffree; in pass5()
329 cstotal.cs_nbfree += cg->cg_cs.cs_nbfree; in pass5()
330 cstotal.cs_nifree += cg->cg_cs.cs_nifree; in pass5()
331 cstotal.cs_ndir += cg->cg_cs.cs_ndir; in pass5()
333 cstotal.cs_nffree += newcg->cg_cs.cs_nffree; in pass5()
334 cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree; in pass5()
335 cstotal.cs_nifree += newcg->cg_cs.cs_nifree; in pass5()
336 cstotal.cs_ndir += newcg->cg_cs.cs_ndir; in pass5()
338 cs = &fs->fs_cs(fs, c); in pass5()
340 memcmp(&newcg->cg_cs, cs, sizeof *cs) != 0 && in pass5()
342 memmove(cs, &newcg->cg_cs, sizeof *cs); in pass5()
346 memmove(cg, newcg, (size_t)fs->fs_cgsize); in pass5()
360 dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) { in pass5()
367 memcmp(&cstotal, &fs->fs_cstotal, sizeof cstotal) != 0 in pass5()
372 (intmax_t)fs->fs_cstotal.cs_ndir, in pass5()
373 (intmax_t)fs->fs_cstotal.cs_nbfree, in pass5()
374 (intmax_t)fs->fs_cstotal.cs_nffree, in pass5()
375 (intmax_t)fs->fs_cstotal.cs_nifree, in pass5()
376 (intmax_t)fs->fs_cstotal.cs_numclusters); in pass5()
385 memmove(&fs->fs_cstotal, &cstotal, sizeof cstotal); in pass5()
386 fs->fs_ronly = 0; in pass5()
387 fs->fs_fmod = 0; in pass5()
399 cmd.value = cstotal.cs_ndir - fs->fs_cstotal.cs_ndir; in pass5()
400 if (cmd.value != 0) { in pass5()
402 printf("adjndir by %+" PRIi64 "\n", cmd.value); in pass5()
404 &cmd, sizeof cmd) == -1) in pass5()
406 cmd.value); in pass5()
409 cmd.value = cstotal.cs_nbfree - fs->fs_cstotal.cs_nbfree; in pass5()
410 if (cmd.value != 0) { in pass5()
413 cmd.value); in pass5()
415 &cmd, sizeof cmd) == -1) in pass5()
417 cmd.value); in pass5()
420 cmd.value = cstotal.cs_nifree - fs->fs_cstotal.cs_nifree; in pass5()
421 if (cmd.value != 0) { in pass5()
424 cmd.value); in pass5()
426 &cmd, sizeof cmd) == -1) in pass5()
428 cmd.value); in pass5()
431 cmd.value = cstotal.cs_nffree - fs->fs_cstotal.cs_nffree; in pass5()
432 if (cmd.value != 0) { in pass5()
435 cmd.value); in pass5()
437 &cmd, sizeof cmd) == -1) in pass5()
439 cmd.value); in pass5()
442 cmd.value = cstotal.cs_numclusters - in pass5()
443 fs->fs_cstotal.cs_numclusters; in pass5()
444 if (cmd.value != 0) { in pass5()
447 cmd.value); in pass5()
449 0, 0, &cmd, sizeof cmd) == -1) in pass5()
451 cmd.value); in pass5()
471 inomapsize = howmany(fs->fs_ipg, CHAR_BIT); in update_maps()
472 excessdirs = oldcg->cg_cs.cs_ndir - newcg->cg_cs.cs_ndir; in update_maps()
474 pfatal("LOST %d DIRECTORIES\n", -excessdirs); in update_maps()
479 oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_ipg, "DIR", freedirs, in update_maps()
482 oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_ipg, "FILE", freefiles, in update_maps()
483 excessdirs, fs->fs_ipg, usesysctl); in update_maps()
485 howmany(fs->fs_fpg, CHAR_BIT), in update_maps()
486 oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_fpg, "FRAG", in update_maps()
487 freeblks, 0, fs->fs_fpg, usesysctl); in update_maps()
495 ufs2_daddr_t startvalue, /* resource value for first element in map */ in check_maps()
512 astart = ustart = aend = uend = -1; in check_maps()
523 if (astart == -1) { in check_maps()
536 (*msg)("%s %sS %" PRId64 "-%" PRId64 in check_maps()
541 if (ustart == -1) { in check_maps()
549 size = uend - ustart + 1; in check_maps()
551 skip -= size; in check_maps()
557 size -= skip; in check_maps()
567 pwarn("%s %sS %" PRId64 "-%" PRId64 in check_maps()
570 ustart + size - 1); in check_maps()
572 cmd.value = ustart; in check_maps()
575 &cmd, sizeof cmd) == -1) { in check_maps()
578 rwerror(buf, cmd.value); in check_maps()
581 limit -= size; in check_maps()
588 if (astart != -1) { in check_maps()
593 (*msg)("ALLOCATED %sS %" PRId64 "-%" PRId64 in check_maps()
597 if (ustart != -1) { in check_maps()
598 size = uend - ustart + 1; in check_maps()
603 size -= skip; in check_maps()
613 pwarn("UNALLOCATED %sS %" PRId64 "-%" PRId64 in check_maps()
615 name, ustart, ustart + size - 1); in check_maps()
618 cmd.value = ustart; in check_maps()
621 sizeof cmd) == -1) { in check_maps()
623 rwerror(buf, cmd.value); in check_maps()
637 lfragtosize(&sblock, end - start + 1)); in clear_blocks()
640 lfragtosize(&sblock, end - start + 1)); in clear_blocks()