git: a1aa26b7db2c - main - tests/sys/posixshm/posixshm_test.c::accounting fix after st_size changes

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 21 Aug 2026 01:32:25 UTC
The branch main has been updated by kib:

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

commit a1aa26b7db2c774b1da5eecb5505efd412ea7a23
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-08-19 21:53:55 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-08-21 01:31:50 +0000

    tests/sys/posixshm/posixshm_test.c::accounting fix after st_size changes
    
    st_blksize is defined by POSIX as the 'preferred I/O block size for this
    object.' It is wrong to use st_blksize as the unit for st_blocks and
    expect it to be equal to the object size regardless of the change of
    st_blksize.
    
    Fixes:  3a1bf59d195c ("shmfd: consistently return size in 512 byte blocks for fstat(2) st_blocks")
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D59014
---
 tests/sys/posixshm/posixshm_test.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/sys/posixshm/posixshm_test.c b/tests/sys/posixshm/posixshm_test.c
index e4b57dec6311..08af63ac4a34 100644
--- a/tests/sys/posixshm/posixshm_test.c
+++ b/tests/sys/posixshm/posixshm_test.c
@@ -1189,7 +1189,9 @@ ATF_TC_BODY(accounting, tc)
 
 	ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0);
 	ATF_REQUIRE(fstat(fd, &st) == 0);
-	ATF_REQUIRE(st.st_blksize * st.st_blocks == (blkcnt_t)shm_sz);
+	printf("blocks %jd shm_sz %jd\n", (uintmax_t)st.st_blocks,
+	    (uintmax_t)shm_sz);
+	ATF_CHECK_EQ(DEV_BSIZE * st.st_blocks, (blkcnt_t)shm_sz);
 
 	range.r_offset = page_size;
 	range.r_len = len = (shm_max_pages - 1) * page_size -
@@ -1197,7 +1199,9 @@ ATF_TC_BODY(accounting, tc)
 	ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0,
 	    "SPACECTL_DEALLOC failed; errno=%d", errno);
 	ATF_REQUIRE(fstat(fd, &st) == 0);
-	ATF_REQUIRE(st.st_blksize * st.st_blocks == (blkcnt_t)(shm_sz - len));
+	printf("blocks %jd shm_sz %jd len %jd\n", (uintmax_t)st.st_blocks,
+	    (uintmax_t)shm_sz, (uintmax_t)len);
+	ATF_CHECK_EQ(DEV_BSIZE * st.st_blocks, (blkcnt_t)(shm_sz - len));
 
 	ATF_REQUIRE(close(fd) == 0);
 }