git: 5bd21cbbd1df - main - vfs: fix vfs_bio_clrbuf() for PAGE_SIZE > block size
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Jun 2022 00:59:41 UTC
The branch main has been updated by chs: URL: https://cgit.FreeBSD.org/src/commit/?id=5bd21cbbd1df837ccc9fe7834f43636fd20d8792 commit 5bd21cbbd1df837ccc9fe7834f43636fd20d8792 Author: Chuck Silvers <chs@FreeBSD.org> AuthorDate: 2022-06-22 00:58:52 +0000 Commit: Chuck Silvers <chs@FreeBSD.org> CommitDate: 2022-06-22 00:58:52 +0000 vfs: fix vfs_bio_clrbuf() for PAGE_SIZE > block size Calculate the desired page valid mask using math that will not overflow the types used. Sponsored by: Netflix Reviewed by: mckusick, kib, markj Differential Revision: https://reviews.freebsd.org/D34837 --- sys/kern/vfs_bio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 9082147b6034..7724e66f7bad 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -4852,7 +4852,8 @@ vfs_bio_set_valid(struct buf *bp, int base, int size) void vfs_bio_clrbuf(struct buf *bp) { - int i, j, mask, sa, ea, slide; + int i, j, sa, ea, slide, zbits; + vm_page_bits_t mask; if ((bp->b_flags & (B_VMIO | B_MALLOC)) != B_VMIO) { clrbuf(bp); @@ -4871,7 +4872,9 @@ vfs_bio_clrbuf(struct buf *bp) if (bp->b_pages[i] == bogus_page) continue; j = sa / DEV_BSIZE; - mask = ((1 << ((ea - sa) / DEV_BSIZE)) - 1) << j; + zbits = (sizeof(vm_page_bits_t) * NBBY) - + (ea - sa) / DEV_BSIZE; + mask = (VM_PAGE_BITS_ALL >> zbits) << j; if ((bp->b_pages[i]->valid & mask) == mask) continue; if ((bp->b_pages[i]->valid & mask) == 0)