pass5.c revision 224059
1/*
2 * Copyright (c) 1980, 1986, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#if 0
31#ifndef lint
32static const char sccsid[] = "@(#)pass5.c	8.9 (Berkeley) 4/28/95";
33#endif /* not lint */
34#endif
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sbin/fsck_ffs/pass5.c 224059 2011-07-15 15:43:40Z mckusick $");
37
38#include <sys/param.h>
39#include <sys/sysctl.h>
40
41#include <ufs/ufs/dinode.h>
42#include <ufs/ffs/fs.h>
43
44#include <err.h>
45#include <inttypes.h>
46#include <limits.h>
47#include <string.h>
48#include <libufs.h>
49
50#include "fsck.h"
51
52static void check_maps(u_char *, u_char *, int, ufs2_daddr_t, const char *,
53			int *, int, int, int);
54static void clear_blocks(ufs2_daddr_t start, ufs2_daddr_t end);
55
56void
57pass5(void)
58{
59	int c, i, j, blk, frags, basesize, mapsize;
60	int inomapsize, blkmapsize;
61	struct fs *fs = &sblock;
62	struct cg *cg = &cgrp;
63	ufs2_daddr_t d, dbase, dmax, start;
64	int rewritecg = 0;
65	struct csum *cs;
66	struct csum_total cstotal;
67	struct inodesc idesc[3];
68	char buf[MAXBSIZE];
69	struct cg *newcg = (struct cg *)buf;
70
71	inoinfo(WINO)->ino_state = USTATE;
72	memset(newcg, 0, (size_t)fs->fs_cgsize);
73	newcg->cg_niblk = fs->fs_ipg;
74	if (cvtlevel >= 3) {
75		if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) {
76			if (preen)
77				pwarn("DELETING CLUSTERING MAPS\n");
78			if (preen || reply("DELETE CLUSTERING MAPS")) {
79				fs->fs_contigsumsize = 0;
80				rewritecg = 1;
81				sbdirty();
82			}
83		}
84		if (fs->fs_maxcontig > 1) {
85			const char *doit = 0;
86
87			if (fs->fs_contigsumsize < 1) {
88				doit = "CREAT";
89			} else if (fs->fs_contigsumsize < fs->fs_maxcontig &&
90				   fs->fs_contigsumsize < FS_MAXCONTIG) {
91				doit = "EXPAND";
92			}
93			if (doit) {
94				i = fs->fs_contigsumsize;
95				fs->fs_contigsumsize =
96				    MIN(fs->fs_maxcontig, FS_MAXCONTIG);
97				if (CGSIZE(fs) > (u_int)fs->fs_bsize) {
98					pwarn("CANNOT %s CLUSTER MAPS\n", doit);
99					fs->fs_contigsumsize = i;
100				} else if (preen ||
101				    reply("CREATE CLUSTER MAPS")) {
102					if (preen)
103						pwarn("%sING CLUSTER MAPS\n",
104						    doit);
105					fs->fs_cgsize =
106					    fragroundup(fs, CGSIZE(fs));
107					rewritecg = 1;
108					sbdirty();
109				}
110			}
111		}
112	}
113	basesize = &newcg->cg_space[0] - (u_char *)(&newcg->cg_firstfield);
114	if (sblock.fs_magic == FS_UFS2_MAGIC) {
115		newcg->cg_iusedoff = basesize;
116	} else {
117		/*
118		 * We reserve the space for the old rotation summary
119		 * tables for the benefit of old kernels, but do not
120		 * maintain them in modern kernels. In time, they can
121		 * go away.
122		 */
123		newcg->cg_old_btotoff = basesize;
124		newcg->cg_old_boff = newcg->cg_old_btotoff +
125		    fs->fs_old_cpg * sizeof(int32_t);
126		newcg->cg_iusedoff = newcg->cg_old_boff +
127		    fs->fs_old_cpg * fs->fs_old_nrpos * sizeof(u_int16_t);
128		memset(&newcg->cg_space[0], 0, newcg->cg_iusedoff - basesize);
129	}
130	inomapsize = howmany(fs->fs_ipg, CHAR_BIT);
131	newcg->cg_freeoff = newcg->cg_iusedoff + inomapsize;
132	blkmapsize = howmany(fs->fs_fpg, CHAR_BIT);
133	newcg->cg_nextfreeoff = newcg->cg_freeoff + blkmapsize;
134	if (fs->fs_contigsumsize > 0) {
135		newcg->cg_clustersumoff = newcg->cg_nextfreeoff -
136		    sizeof(u_int32_t);
137		newcg->cg_clustersumoff =
138		    roundup(newcg->cg_clustersumoff, sizeof(u_int32_t));
139		newcg->cg_clusteroff = newcg->cg_clustersumoff +
140		    (fs->fs_contigsumsize + 1) * sizeof(u_int32_t);
141		newcg->cg_nextfreeoff = newcg->cg_clusteroff +
142		    howmany(fragstoblks(fs, fs->fs_fpg), CHAR_BIT);
143	}
144	newcg->cg_magic = CG_MAGIC;
145	mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff;
146	memset(&idesc[0], 0, sizeof idesc);
147	for (i = 0; i < 3; i++)
148		idesc[i].id_type = ADDR;
149	memset(&cstotal, 0, sizeof(struct csum_total));
150	dmax = blknum(fs, fs->fs_size + fs->fs_frag - 1);
151	for (d = fs->fs_size; d < dmax; d++)
152		setbmap(d);
153	for (c = 0; c < fs->fs_ncg; c++) {
154		if (got_siginfo) {
155			printf("%s: phase 5: cyl group %d of %d (%d%%)\n",
156			    cdevname, c, sblock.fs_ncg,
157			    c * 100 / sblock.fs_ncg);
158			got_siginfo = 0;
159		}
160		if (got_sigalarm) {
161			setproctitle("%s p5 %d%%", cdevname,
162			    c * 100 / sblock.fs_ncg);
163			got_sigalarm = 0;
164		}
165		getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
166		if (!cg_chkmagic(cg))
167			pfatal("CG %d: BAD MAGIC NUMBER\n", c);
168		newcg->cg_time = cg->cg_time;
169		newcg->cg_old_time = cg->cg_old_time;
170		newcg->cg_unrefs = cg->cg_unrefs;
171		newcg->cg_cgx = c;
172		dbase = cgbase(fs, c);
173		dmax = dbase + fs->fs_fpg;
174		if (dmax > fs->fs_size)
175			dmax = fs->fs_size;
176		newcg->cg_ndblk = dmax - dbase;
177		if (fs->fs_magic == FS_UFS1_MAGIC) {
178			if (c == fs->fs_ncg - 1)
179				newcg->cg_old_ncyl = howmany(newcg->cg_ndblk,
180				    fs->fs_fpg / fs->fs_old_cpg);
181			else
182				newcg->cg_old_ncyl = fs->fs_old_cpg;
183			newcg->cg_old_niblk = fs->fs_ipg;
184			newcg->cg_niblk = 0;
185		}
186		if (fs->fs_contigsumsize > 0)
187			newcg->cg_nclusterblks = newcg->cg_ndblk / fs->fs_frag;
188		newcg->cg_cs.cs_ndir = 0;
189		newcg->cg_cs.cs_nffree = 0;
190		newcg->cg_cs.cs_nbfree = 0;
191		newcg->cg_cs.cs_nifree = fs->fs_ipg;
192		if (cg->cg_rotor >= 0 && cg->cg_rotor < newcg->cg_ndblk)
193			newcg->cg_rotor = cg->cg_rotor;
194		else
195			newcg->cg_rotor = 0;
196		if (cg->cg_frotor >= 0 && cg->cg_frotor < newcg->cg_ndblk)
197			newcg->cg_frotor = cg->cg_frotor;
198		else
199			newcg->cg_frotor = 0;
200		if (cg->cg_irotor >= 0 && cg->cg_irotor < fs->fs_ipg)
201			newcg->cg_irotor = cg->cg_irotor;
202		else
203			newcg->cg_irotor = 0;
204		if (fs->fs_magic == FS_UFS1_MAGIC) {
205			newcg->cg_initediblk = 0;
206		} else {
207			if ((unsigned)cg->cg_initediblk > fs->fs_ipg)
208				newcg->cg_initediblk = fs->fs_ipg;
209			else
210				newcg->cg_initediblk = cg->cg_initediblk;
211		}
212		memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum);
213		memset(cg_inosused(newcg), 0, (size_t)(mapsize));
214		j = fs->fs_ipg * c;
215		for (i = 0; i < inostathead[c].il_numalloced; j++, i++) {
216			switch (inoinfo(j)->ino_state) {
217
218			case USTATE:
219				break;
220
221			case DSTATE:
222			case DCLEAR:
223			case DFOUND:
224			case DZLINK:
225				newcg->cg_cs.cs_ndir++;
226				/* FALLTHROUGH */
227
228			case FSTATE:
229			case FCLEAR:
230			case FZLINK:
231				newcg->cg_cs.cs_nifree--;
232				setbit(cg_inosused(newcg), i);
233				break;
234
235			default:
236				if (j < (int)ROOTINO)
237					break;
238				errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
239				    inoinfo(j)->ino_state, j);
240			}
241		}
242		if (c == 0)
243			for (i = 0; i < (int)ROOTINO; i++) {
244				setbit(cg_inosused(newcg), i);
245				newcg->cg_cs.cs_nifree--;
246			}
247		start = -1;
248		for (i = 0, d = dbase;
249		     d < dmax;
250		     d += fs->fs_frag, i += fs->fs_frag) {
251			frags = 0;
252			for (j = 0; j < fs->fs_frag; j++) {
253				if (testbmap(d + j)) {
254					if (Eflag && start != -1) {
255						clear_blocks(start, d + j - 1);
256						start = -1;
257					}
258					continue;
259				}
260				if (start == -1)
261					start = d + j;
262				setbit(cg_blksfree(newcg), i + j);
263				frags++;
264			}
265			if (frags == fs->fs_frag) {
266				newcg->cg_cs.cs_nbfree++;
267				if (fs->fs_contigsumsize > 0)
268					setbit(cg_clustersfree(newcg),
269					    i / fs->fs_frag);
270			} else if (frags > 0) {
271				newcg->cg_cs.cs_nffree += frags;
272				blk = blkmap(fs, cg_blksfree(newcg), i);
273				ffs_fragacct(fs, blk, newcg->cg_frsum, 1);
274			}
275		}
276		if (Eflag && start != -1)
277			clear_blocks(start, d - 1);
278		if (fs->fs_contigsumsize > 0) {
279			int32_t *sump = cg_clustersum(newcg);
280			u_char *mapp = cg_clustersfree(newcg);
281			int map = *mapp++;
282			int bit = 1;
283			int run = 0;
284
285			for (i = 0; i < newcg->cg_nclusterblks; i++) {
286				if ((map & bit) != 0) {
287					run++;
288				} else if (run != 0) {
289					if (run > fs->fs_contigsumsize)
290						run = fs->fs_contigsumsize;
291					sump[run]++;
292					run = 0;
293				}
294				if ((i & (CHAR_BIT - 1)) != (CHAR_BIT - 1)) {
295					bit <<= 1;
296				} else {
297					map = *mapp++;
298					bit = 1;
299				}
300			}
301			if (run != 0) {
302				if (run > fs->fs_contigsumsize)
303					run = fs->fs_contigsumsize;
304				sump[run]++;
305			}
306		}
307		if (bkgrdflag != 0) {
308			cstotal.cs_nffree += cg->cg_cs.cs_nffree;
309			cstotal.cs_nbfree += cg->cg_cs.cs_nbfree;
310			cstotal.cs_nifree += cg->cg_cs.cs_nifree;
311			cstotal.cs_ndir += cg->cg_cs.cs_ndir;
312		} else {
313			cstotal.cs_nffree += newcg->cg_cs.cs_nffree;
314			cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree;
315			cstotal.cs_nifree += newcg->cg_cs.cs_nifree;
316			cstotal.cs_ndir += newcg->cg_cs.cs_ndir;
317		}
318		cs = &fs->fs_cs(fs, c);
319		if (cursnapshot == 0 &&
320		    memcmp(&newcg->cg_cs, cs, sizeof *cs) != 0 &&
321		    dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
322			memmove(cs, &newcg->cg_cs, sizeof *cs);
323			sbdirty();
324		}
325		if (rewritecg) {
326			memmove(cg, newcg, (size_t)fs->fs_cgsize);
327			cgdirty();
328			continue;
329		}
330		if (cursnapshot == 0 &&
331		    memcmp(newcg, cg, basesize) != 0 &&
332		    dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
333			memmove(cg, newcg, (size_t)basesize);
334			cgdirty();
335		}
336		if (bkgrdflag != 0 || usedsoftdep || debug)
337			update_maps(cg, newcg, bkgrdflag);
338		if (cursnapshot == 0 &&
339		    memcmp(cg_inosused(newcg), cg_inosused(cg), mapsize) != 0 &&
340		    dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
341			memmove(cg_inosused(cg), cg_inosused(newcg),
342			      (size_t)mapsize);
343			cgdirty();
344		}
345	}
346	if (cursnapshot == 0 &&
347	    memcmp(&cstotal, &fs->fs_cstotal, sizeof cstotal) != 0
348	    && dofix(&idesc[0], "SUMMARY BLK COUNT(S) WRONG IN SUPERBLK")) {
349		memmove(&fs->fs_cstotal, &cstotal, sizeof cstotal);
350		fs->fs_ronly = 0;
351		fs->fs_fmod = 0;
352		sbdirty();
353	}
354
355	/*
356	 * When doing background fsck on a snapshot, figure out whether
357	 * the superblock summary is inaccurate and correct it when
358	 * necessary.
359	 */
360	if (cursnapshot != 0) {
361		cmd.size = 1;
362
363		cmd.value = cstotal.cs_ndir - fs->fs_cstotal.cs_ndir;
364		if (cmd.value != 0) {
365			if (debug)
366				printf("adjndir by %+" PRIi64 "\n", cmd.value);
367			if (bkgrdsumadj == 0 || sysctl(adjndir, MIBSIZE, 0, 0,
368			    &cmd, sizeof cmd) == -1)
369				rwerror("ADJUST NUMBER OF DIRECTORIES", cmd.value);
370		}
371
372		cmd.value = cstotal.cs_nbfree - fs->fs_cstotal.cs_nbfree;
373		if (cmd.value != 0) {
374			if (debug)
375				printf("adjnbfree by %+" PRIi64 "\n", cmd.value);
376			if (bkgrdsumadj == 0 || sysctl(adjnbfree, MIBSIZE, 0, 0,
377			    &cmd, sizeof cmd) == -1)
378				rwerror("ADJUST NUMBER OF FREE BLOCKS", cmd.value);
379		}
380
381		cmd.value = cstotal.cs_nifree - fs->fs_cstotal.cs_nifree;
382		if (cmd.value != 0) {
383			if (debug)
384				printf("adjnifree by %+" PRIi64 "\n", cmd.value);
385			if (bkgrdsumadj == 0 || sysctl(adjnifree, MIBSIZE, 0, 0,
386			    &cmd, sizeof cmd) == -1)
387				rwerror("ADJUST NUMBER OF FREE INODES", cmd.value);
388		}
389
390		cmd.value = cstotal.cs_nffree - fs->fs_cstotal.cs_nffree;
391		if (cmd.value != 0) {
392			if (debug)
393				printf("adjnffree by %+" PRIi64 "\n", cmd.value);
394			if (bkgrdsumadj == 0 || sysctl(adjnffree, MIBSIZE, 0, 0,
395			    &cmd, sizeof cmd) == -1)
396				rwerror("ADJUST NUMBER OF FREE FRAGS", cmd.value);
397		}
398
399		cmd.value = cstotal.cs_numclusters - fs->fs_cstotal.cs_numclusters;
400		if (cmd.value != 0) {
401			if (debug)
402				printf("adjnumclusters by %+" PRIi64 "\n", cmd.value);
403			if (bkgrdsumadj == 0 || sysctl(adjnumclusters, MIBSIZE, 0, 0,
404			    &cmd, sizeof cmd) == -1)
405				rwerror("ADJUST NUMBER OF FREE CLUSTERS", cmd.value);
406		}
407	}
408}
409
410/*
411 * Compare the original cylinder group inode and block bitmaps with the
412 * updated cylinder group inode and block bitmaps. Free inodes and blocks
413 * that have been added. Complain if any previously freed inodes blocks
414 * are now allocated.
415 */
416void
417update_maps(
418	struct cg *oldcg,	/* cylinder group of claimed allocations */
419	struct cg *newcg,	/* cylinder group of determined allocations */
420	int usesysctl)		/* 1 => use sysctl interface to update maps */
421{
422	int inomapsize, excessdirs;
423	struct fs *fs = &sblock;
424
425	inomapsize = howmany(fs->fs_ipg, CHAR_BIT);
426	excessdirs = oldcg->cg_cs.cs_ndir - newcg->cg_cs.cs_ndir;
427	if (excessdirs < 0) {
428		pfatal("LOST %d DIRECTORIES\n", -excessdirs);
429		excessdirs = 0;
430	}
431	if (excessdirs > 0)
432		check_maps(cg_inosused(newcg), cg_inosused(oldcg), inomapsize,
433		    oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_ipg, "DIR", freedirs,
434		    0, excessdirs, usesysctl);
435	check_maps(cg_inosused(newcg), cg_inosused(oldcg), inomapsize,
436	    oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_ipg, "FILE", freefiles,
437	    excessdirs, fs->fs_ipg, usesysctl);
438	check_maps(cg_blksfree(oldcg), cg_blksfree(newcg),
439	    howmany(fs->fs_fpg, CHAR_BIT),
440	    oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_fpg, "FRAG",
441	    freeblks, 0, fs->fs_fpg, usesysctl);
442}
443
444static void
445check_maps(
446	u_char *map1,	/* map of claimed allocations */
447	u_char *map2,	/* map of determined allocations */
448	int mapsize,	/* size of above two maps */
449	ufs2_daddr_t startvalue, /* resource value for first element in map */
450	const char *name,	/* name of resource found in maps */
451	int *opcode,	/* sysctl opcode to free resource */
452	int skip,	/* number of entries to skip before starting to free */
453	int limit,	/* limit on number of entries to free */
454	int usesysctl)	/* 1 => use sysctl interface to update maps */
455{
456#	define BUFSIZE 16
457	char buf[BUFSIZE];
458	long i, j, k, l, m, size;
459	ufs2_daddr_t n, astart, aend, ustart, uend;
460	void (*msg)(const char *fmt, ...);
461
462	if (usesysctl)
463		msg = pfatal;
464	else
465		msg = pwarn;
466	astart = ustart = aend = uend = -1;
467	for (i = 0; i < mapsize; i++) {
468		j = *map1++;
469		k = *map2++;
470		if (j == k)
471			continue;
472		for (m = 0, l = 1; m < CHAR_BIT; m++, l <<= 1) {
473			if ((j & l) == (k & l))
474				continue;
475			n = startvalue + i * CHAR_BIT + m;
476			if ((j & l) != 0) {
477				if (astart == -1) {
478					astart = aend = n;
479					continue;
480				}
481				if (aend + 1 == n) {
482					aend = n;
483					continue;
484				}
485				if (astart == aend)
486					(*msg)("ALLOCATED %s %" PRId64
487					    " MARKED FREE\n",
488					    name, astart);
489				else
490					(*msg)("%s %sS %" PRId64 "-%" PRId64
491					    " MARKED FREE\n",
492					    "ALLOCATED", name, astart, aend);
493				astart = aend = n;
494			} else {
495				if (ustart == -1) {
496					ustart = uend = n;
497					continue;
498				}
499				if (uend + 1 == n) {
500					uend = n;
501					continue;
502				}
503				size = uend - ustart + 1;
504				if (size <= skip) {
505					skip -= size;
506					ustart = uend = n;
507					continue;
508				}
509				if (skip > 0) {
510					ustart += skip;
511					size -= skip;
512					skip = 0;
513				}
514				if (size > limit)
515					size = limit;
516				if (debug && size == 1)
517					pwarn("%s %s %" PRId64
518					    " MARKED USED\n",
519					    "UNALLOCATED", name, ustart);
520				else if (debug)
521					pwarn("%s %sS %" PRId64 "-%" PRId64
522					    " MARKED USED\n",
523					    "UNALLOCATED", name, ustart,
524					    ustart + size - 1);
525				if (usesysctl != 0) {
526					cmd.value = ustart;
527					cmd.size = size;
528					if (sysctl(opcode, MIBSIZE, 0, 0,
529					    &cmd, sizeof cmd) == -1) {
530						snprintf(buf, BUFSIZE,
531						    "FREE %s", name);
532						rwerror(buf, cmd.value);
533					}
534				}
535				limit -= size;
536				if (limit <= 0)
537					return;
538				ustart = uend = n;
539			}
540		}
541	}
542	if (astart != -1) {
543		if (astart == aend)
544			(*msg)("ALLOCATED %s %" PRId64
545			    " MARKED FREE\n", name, astart);
546		else
547			(*msg)("ALLOCATED %sS %" PRId64 "-%" PRId64
548			    " MARKED FREE\n",
549			    name, astart, aend);
550	}
551	if (ustart != -1) {
552		size = uend - ustart + 1;
553		if (size <= skip)
554			return;
555		if (skip > 0) {
556			ustart += skip;
557			size -= skip;
558		}
559		if (size > limit)
560			size = limit;
561		if (debug) {
562			if (size == 1)
563				pwarn("UNALLOCATED %s %" PRId64
564				    " MARKED USED\n",
565				    name, ustart);
566			else
567				pwarn("UNALLOCATED %sS %" PRId64 "-%" PRId64
568				    " MARKED USED\n",
569				    name, ustart, ustart + size - 1);
570		}
571		if (usesysctl != 0) {
572			cmd.value = ustart;
573			cmd.size = size;
574			if (sysctl(opcode, MIBSIZE, 0, 0, &cmd,
575			    sizeof cmd) == -1) {
576				snprintf(buf, BUFSIZE, "FREE %s", name);
577				rwerror(buf, cmd.value);
578			}
579		}
580	}
581}
582
583static void clear_blocks(ufs2_daddr_t start, ufs2_daddr_t end)
584{
585
586	if (debug)
587		printf("Zero frags %jd to %jd\n", start, end);
588	blerase(fswritefd, fsbtodb(&sblock, start),
589	    lfragtosize(&sblock, end - start + 1));
590}
591