svn commit: r368773 - head/sbin/fsck_ffs

Kirk McKusick mckusick at FreeBSD.org
Fri Dec 18 23:28:28 UTC 2020


Author: mckusick
Date: Fri Dec 18 23:28:27 2020
New Revision: 368773
URL: https://svnweb.freebsd.org/changeset/base/368773

Log:
  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

Modified:
  head/sbin/fsck_ffs/dir.c
  head/sbin/fsck_ffs/fsck.h
  head/sbin/fsck_ffs/fsutil.c
  head/sbin/fsck_ffs/inode.c
  head/sbin/fsck_ffs/pass4.c

Modified: head/sbin/fsck_ffs/dir.c
==============================================================================
--- head/sbin/fsck_ffs/dir.c	Fri Dec 18 23:14:39 2020	(r368772)
+++ head/sbin/fsck_ffs/dir.c	Fri Dec 18 23:28:27 2020	(r368773)
@@ -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);
 }
 

Modified: head/sbin/fsck_ffs/fsck.h
==============================================================================
--- head/sbin/fsck_ffs/fsck.h	Fri Dec 18 23:14:39 2020	(r368772)
+++ head/sbin/fsck_ffs/fsck.h	Fri Dec 18 23:28:27 2020	(r368773)
@@ -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);

Modified: head/sbin/fsck_ffs/fsutil.c
==============================================================================
--- head/sbin/fsck_ffs/fsutil.c	Fri Dec 18 23:14:39 2020	(r368772)
+++ head/sbin/fsck_ffs/fsutil.c	Fri Dec 18 23:28:27 2020	(r368773)
@@ -800,19 +800,8 @@ 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()
 {

Modified: head/sbin/fsck_ffs/inode.c
==============================================================================
--- head/sbin/fsck_ffs/inode.c	Fri Dec 18 23:14:39 2020	(r368772)
+++ head/sbin/fsck_ffs/inode.c	Fri Dec 18 23:28:27 2020	(r368773)
@@ -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);

Modified: head/sbin/fsck_ffs/pass4.c
==============================================================================
--- head/sbin/fsck_ffs/pass4.c	Fri Dec 18 23:14:39 2020	(r368772)
+++ head/sbin/fsck_ffs/pass4.c	Fri Dec 18 23:28:27 2020	(r368773)
@@ -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",
@@ -123,33 +123,4 @@ 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);
 }


More information about the svn-src-head mailing list