Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Dec 2022 00:38:17 GMT
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 9183ec42dd44 - stable/13 - Correct calculation of inode location in getnextino cache.
Message-ID:  <202212110038.2BB0cHrF003898@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=9183ec42dd447e366039b0088bdcb70b356010b4

commit 9183ec42dd447e366039b0088bdcb70b356010b4
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-08-29 06:08:49 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-12-11 00:37:17 +0000

    Correct calculation of inode location in getnextino cache.
    
    (cherry picked from commit 2e4da012d57edab9d71dc7a67dc706b6a9b7800d)
    
    Sponsored by: The FreeBSD Foundation
---
 sbin/fsck_ffs/fsutil.c | 2 +-
 sbin/fsck_ffs/inode.c  | 8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index f2d198fa294a..923a945fc104 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -464,7 +464,7 @@ flush(int fd, struct bufarea *bp)
 			struct ufs2_dinode *dp = bp->b_un.b_dinode2;
 			int i;
 
-			for (i = 0; i < INOPB(&sblock); dp++, i++) {
+			for (i = 0; i < bp->b_size; dp++, i += sizeof(*dp)) {
 				if (ffs_verify_dinode_ckhash(&sblock, dp) == 0)
 					continue;
 				pwarn("flush: INODE CHECK-HASH FAILED");
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index ae7124784415..1d65ec667d44 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -425,7 +425,6 @@ void
 ginode(ino_t inumber, struct inode *ip)
 {
 	ufs2_daddr_t iblk;
-	ino_t numinodes;
 
 	if (inumber < UFS_ROOTINO || inumber > maxino)
 		errx(EEXIT, "bad inode number %ju to ginode",
@@ -436,14 +435,12 @@ ginode(ino_t inumber, struct inode *ip)
 		ip->i_bp = &inobuf;
 		inobuf.b_refcnt++;
 		inobuf.b_index = firstinum;
-		numinodes = lastinum - firstinum;
 	} else if (icachebp != NULL &&
 	    inumber >= icachebp->b_index &&
 	    inumber < icachebp->b_index + INOPB(&sblock)) {
 		/* take an additional reference for the returned inode */
 		icachebp->b_refcnt++;
 		ip->i_bp = icachebp;
-		numinodes = INOPB(&sblock);
 	} else {
 		iblk = ino_to_fsba(&sblock, inumber);
 		/* release our cache-hold reference on old icachebp */
@@ -460,15 +457,14 @@ ginode(ino_t inumber, struct inode *ip)
 		icachebp->b_refcnt++;
 		icachebp->b_index = rounddown(inumber, INOPB(&sblock));
 		ip->i_bp = icachebp;
-		numinodes = INOPB(&sblock);
 	}
 	if (sblock.fs_magic == FS_UFS1_MAGIC) {
 		ip->i_dp = (union dinode *)
-		    &ip->i_bp->b_un.b_dinode1[inumber % numinodes];
+		    &ip->i_bp->b_un.b_dinode1[inumber - firstinum];
 		return;
 	}
 	ip->i_dp = (union dinode *)
-	    &ip->i_bp->b_un.b_dinode2[inumber % numinodes];
+	    &ip->i_bp->b_un.b_dinode2[inumber - firstinum];
 	if (ffs_verify_dinode_ckhash(&sblock, (struct ufs2_dinode *)ip->i_dp)) {
 		pwarn("INODE CHECK-HASH FAILED");
 		prtinode(ip);



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