From c5d648069488265be80ddfe1babb151d97489d2d Mon Sep 17 00:00:00 2001 From: Julian Elischer Date: Fri, 3 Sep 1999 08:26:46 +0000 Subject: [PATCH] Add a catchall to set default blocksize values for disk like devices. Submitted by: phk@freebsd.org --- sys/fs/specfs/spec_vnops.c | 18 +++++++++++++----- sys/miscfs/specfs/spec_vnops.c | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index 1afc40017da4..44c23ba20563 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -203,8 +203,7 @@ spec_open(ap) VOP_UNLOCK(vp, 0, p); error = (*dsw->d_open)(dev, ap->a_mode, S_IFCHR, p); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - return (error); - /* NOT REACHED */ + break; case VBLK: dsw = devsw(dev); if ( (dsw == NULL) || (dsw->d_open == NULL)) @@ -225,12 +224,21 @@ spec_open(ap) error = vfs_mountedon(vp); if (error) return (error); - return ((*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p)); - /* NOT REACHED */ + error = (*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p); + break; default: break; } - return (0); + + if (vn_isdisk(vp)) { + if (!dev->si_bsize_phys) + dev->si_bsize_phys = DEV_BSIZE; + if (dev->si_bsize_best < dev->si_bsize_phys) + dev->si_bsize_best = BLKDEV_IOSIZE; + if (!dev->si_bsize_max) + dev->si_bsize_max = MAXBSIZE; + } + return (error); } /* diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index 1afc40017da4..44c23ba20563 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -203,8 +203,7 @@ spec_open(ap) VOP_UNLOCK(vp, 0, p); error = (*dsw->d_open)(dev, ap->a_mode, S_IFCHR, p); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - return (error); - /* NOT REACHED */ + break; case VBLK: dsw = devsw(dev); if ( (dsw == NULL) || (dsw->d_open == NULL)) @@ -225,12 +224,21 @@ spec_open(ap) error = vfs_mountedon(vp); if (error) return (error); - return ((*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p)); - /* NOT REACHED */ + error = (*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p); + break; default: break; } - return (0); + + if (vn_isdisk(vp)) { + if (!dev->si_bsize_phys) + dev->si_bsize_phys = DEV_BSIZE; + if (dev->si_bsize_best < dev->si_bsize_phys) + dev->si_bsize_best = BLKDEV_IOSIZE; + if (!dev->si_bsize_max) + dev->si_bsize_max = MAXBSIZE; + } + return (error); } /*