Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Apr 2023 23:14:00 GMT
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 18746531a881 - main - Bug fixes for fsck_ffs(8).
Message-ID:  <202304182314.33INE0eh095388@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=18746531a881356ed24b6ef2fdc9e50707642163

commit 18746531a881356ed24b6ef2fdc9e50707642163
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-04-18 06:03:30 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-04-18 23:13:26 +0000

    Bug fixes for fsck_ffs(8).
    
    Increment a reference count when returning a zero'ed out buffer
    after a failed read.
    
    Zero out a structure before using it.
    
    Only dirty a buffer that has been modified.
    
    Submitted by: Chuck Silvers
    Sponsored by: Netflix
    MFC after:    1 week
---
 sbin/fsck_ffs/fsutil.c |  4 +++-
 sbin/fsck_ffs/inode.c  | 10 ++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index d58527231240..2b915d28aa26 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -320,8 +320,10 @@ getdatablk(ufs2_daddr_t blkno, long size, int type)
 	 * Skip check for inodes because chkrange() considers
 	 * metadata areas invalid to write data.
 	 */
-	if (type != BT_INODES && chkrange(blkno, size / sblock.fs_fsize))
+	if (type != BT_INODES && chkrange(blkno, size / sblock.fs_fsize)) {
+		failedbuf.b_refcnt++;
 		return (&failedbuf);
+	}
 	bhdp = &bufhashhd[HASH(blkno)];
 	LIST_FOREACH(bp, bhdp, b_hash)
 		if (bp->b_bno == fsbtodb(&sblock, blkno)) {
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index a46fea0607a0..37b0f9ebc1b1 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -747,6 +747,7 @@ snapremove(ino_t inum)
 		bzero(&snaplist[i - 1], sizeof(struct inode));
 		snapcnt--;
 	}
+	memset(&idesc, 0, sizeof(struct inodesc));
 	idesc.id_type = SNAP;
 	idesc.id_func = snapclean;
 	idesc.id_number = inum;
@@ -767,14 +768,15 @@ snapclean(struct inodesc *idesc)
 	if (blkno == 0)
 		return (KEEPON);
 
-	bp = idesc->id_bp;
 	dp = idesc->id_dp;
 	if (blkno == BLK_NOCOPY || blkno == BLK_SNAP) {
-		if (idesc->id_lbn < UFS_NDADDR)
+		if (idesc->id_lbn < UFS_NDADDR) {
 			DIP_SET(dp, di_db[idesc->id_lbn], 0);
-		else
+		} else {
+			bp = idesc->id_bp;
 			IBLK_SET(bp, bp->b_index, 0);
-		dirty(bp);
+			dirty(bp);
+		}
 	}
 	return (KEEPON);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304182314.33INE0eh095388>