summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2020-12-18 23:28:27 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2020-12-18 23:28:27 +0000
commit7180f1ab40e22f3f6b8d50d05c6ae186de54e90a (patch)
tree42194631eb560d0174334c567a397b741f6557ac
parent673e2dd652156342009930cf1f7d15623e4a543a (diff)
downloadsrc-test2-7180f1ab40e22f3f6b8d50d05c6ae186de54e90a.tar.gz
src-test2-7180f1ab40e22f3f6b8d50d05c6ae186de54e90a.zip
Rename pass4check() to freeblock() and move from pass4.c to inode.c.
The new name more accurately describes what it does and the file move puts it with other similar functions. Done in preparation for future cleanups. No functional differences intended. Sponsored by: Netflix Historic Footnote: my last FreeBSD svn commit
Notes
Notes: svn path=/head/; revision=368773
-rw-r--r--sbin/fsck_ffs/dir.c8
-rw-r--r--sbin/fsck_ffs/fsck.h3
-rw-r--r--sbin/fsck_ffs/fsutil.c13
-rw-r--r--sbin/fsck_ffs/inode.c33
-rw-r--r--sbin/fsck_ffs/pass4.c31
5 files changed, 41 insertions, 47 deletions
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c
index 831cf448527b..3cf56d872b72 100644
--- a/sbin/fsck_ffs/dir.c
+++ b/sbin/fsck_ffs/dir.c
@@ -532,7 +532,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
}
inodirty(dp);
idesc.id_type = ADDR;
- idesc.id_func = pass4check;
+ idesc.id_func = freeblock;
idesc.id_number = oldlfdir;
adjust(&idesc, inoinfo(oldlfdir)->ino_linkcnt + 1);
inoinfo(oldlfdir)->ino_linkcnt = 0;
@@ -635,6 +635,7 @@ expanddir(union dinode *dp, char *name)
{
ufs2_daddr_t lastbn, newblk;
struct bufarea *bp;
+ struct inodesc idesc;
char *cp, firstblk[DIRBLKSIZ];
lastbn = lblkno(&sblock, DIP(dp, di_size));
@@ -679,7 +680,10 @@ bad:
DIP_SET(dp, di_db[lastbn + 1], 0);
DIP_SET(dp, di_size, DIP(dp, di_size) - sblock.fs_bsize);
DIP_SET(dp, di_blocks, DIP(dp, di_blocks) - btodb(sblock.fs_bsize));
- freeblk(newblk, sblock.fs_frag);
+ /* Free the block we allocated above */
+ idesc.id_blkno = newblk;
+ idesc.id_numfrags = sblock.fs_frag;
+ (void)freeblock(&idesc);
return (0);
}
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 38a4e13888bc..8c7fe6d693c9 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -438,7 +438,7 @@ void finalIOstats(void);
int findino(struct inodesc *);
int findname(struct inodesc *);
void flush(int fd, struct bufarea *bp);
-void freeblk(ufs2_daddr_t blkno, long frags);
+int freeblock(struct inodesc *);
void freeino(ino_t ino);
void freeinodebuf(void);
void fsutilinit(void);
@@ -465,7 +465,6 @@ int pass1check(struct inodesc *);
void pass2(void);
void pass3(void);
void pass4(void);
-int pass4check(struct inodesc *);
void pass5(void);
void pfatal(const char *fmt, ...) __printflike(1, 2);
void propagate(void);
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index 94ea2cf792bf..11d2ebd598fd 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -800,20 +800,9 @@ allocblk(long frags)
}
/*
- * Free a previously allocated block
+ * Slow down IO so as to leave some disk bandwidth for other processes
*/
void
-freeblk(ufs2_daddr_t blkno, long frags)
-{
- struct inodesc idesc;
-
- idesc.id_blkno = blkno;
- idesc.id_numfrags = frags;
- (void)pass4check(&idesc);
-}
-
-/* Slow down IO so as to leave some disk bandwidth for other processes */
-void
slowio_start()
{
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index d930f2f81998..2fcc6414918b 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -641,6 +641,37 @@ clearentry(struct inodesc *idesc)
return (STOP|FOUND|ALTERED);
}
+int
+freeblock(struct inodesc *idesc)
+{
+ struct dups *dlp;
+ ufs2_daddr_t blkno;
+ long nfrags, res;
+
+ res = KEEPON;
+ blkno = idesc->id_blkno;
+ for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
+ if (chkrange(blkno, 1)) {
+ res = SKIP;
+ } else if (testbmap(blkno)) {
+ for (dlp = duplist; dlp; dlp = dlp->next) {
+ if (dlp->dup != blkno)
+ continue;
+ dlp->dup = duplist->dup;
+ dlp = duplist;
+ duplist = duplist->next;
+ free((char *)dlp);
+ break;
+ }
+ if (dlp == NULL) {
+ clrbmap(blkno);
+ n_blks--;
+ }
+ }
+ }
+ return (res);
+}
+
void
prtinode(ino_t ino, union dinode *dp)
{
@@ -767,7 +798,7 @@ freeino(ino_t ino)
memset(&idesc, 0, sizeof(struct inodesc));
idesc.id_type = ADDR;
- idesc.id_func = pass4check;
+ idesc.id_func = freeblock;
idesc.id_number = ino;
dp = ginode(ino);
(void)ckinode(dp, &idesc);
diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c
index f48bc041af10..925be9f4fb4a 100644
--- a/sbin/fsck_ffs/pass4.c
+++ b/sbin/fsck_ffs/pass4.c
@@ -58,7 +58,7 @@ pass4(void)
memset(&idesc, 0, sizeof(struct inodesc));
idesc.id_type = ADDR;
- idesc.id_func = pass4check;
+ idesc.id_func = freeblock;
for (cg = 0; cg < sblock.fs_ncg; cg++) {
if (got_siginfo) {
printf("%s: phase 4: cyl group %d of %d (%d%%)\n",
@@ -124,32 +124,3 @@ pass4(void)
}
}
}
-
-int
-pass4check(struct inodesc *idesc)
-{
- struct dups *dlp;
- int nfrags, res = KEEPON;
- ufs2_daddr_t blkno = idesc->id_blkno;
-
- for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
- if (chkrange(blkno, 1)) {
- res = SKIP;
- } else if (testbmap(blkno)) {
- for (dlp = duplist; dlp; dlp = dlp->next) {
- if (dlp->dup != blkno)
- continue;
- dlp->dup = duplist->dup;
- dlp = duplist;
- duplist = duplist->next;
- free((char *)dlp);
- break;
- }
- if (dlp == NULL) {
- clrbmap(blkno);
- n_blks--;
- }
- }
- }
- return (res);
-}