when determining I/O block size for VBLK device, only use pi_bsize

returned by DIOCGPARTINFO if it's bigger than DEV_BSIZE and less
than MAXBSIZE (MAXPHYS)

fixes panic "buf mem pool index 8" in buf_mempoolidx() when the
disklabel contains bsize 128KB and something reads the block device -
buffer cache can't allocate bufs bigger than MAXPHYS
This commit is contained in:
jdolecek 2020-04-13 20:02:27 +00:00
parent 23bf88000c
commit 5dec3f0781

View File

@ -1,4 +1,4 @@
/* $NetBSD: spec_vnops.c,v 1.176 2019/09/22 22:59:39 christos Exp $ */
/* $NetBSD: spec_vnops.c,v 1.177 2020/04/13 20:02:27 jdolecek Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.176 2019/09/22 22:59:39 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.177 2020/04/13 20:02:27 jdolecek Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -717,7 +717,7 @@ spec_read(void *v)
return (EINVAL);
if (bdev_ioctl(vp->v_rdev, DIOCGPARTINFO, &pi, FREAD, l) == 0)
bsize = pi.pi_bsize;
bsize = imin(imax(pi.pi_bsize, DEV_BSIZE), MAXBSIZE);
else
bsize = BLKDEV_IOSIZE;
@ -786,7 +786,7 @@ spec_write(void *v)
return (EINVAL);
if (bdev_ioctl(vp->v_rdev, DIOCGPARTINFO, &pi, FREAD, l) == 0)
bsize = pi.pi_bsize;
bsize = imin(imax(pi.pi_bsize, DEV_BSIZE), MAXBSIZE);
else
bsize = BLKDEV_IOSIZE;