diff options
author | Julian Elischer <julian@FreeBSD.org> | 1999-09-03 05:16:59 +0000 |
---|---|---|
committer | Julian Elischer <julian@FreeBSD.org> | 1999-09-03 05:16:59 +0000 |
commit | 7012bab98808944e9803bbe0df1924b86e1d2671 (patch) | |
tree | ecf83d057dcdf0e242facb3f5a6d706cb558521e | |
parent | 2a0434714fab4769fa3a5680eb336e88b3255458 (diff) | |
download | src-7012bab98808944e9803bbe0df1924b86e1d2671.tar.gz src-7012bab98808944e9803bbe0df1924b86e1d2671.zip |
Revert a bunch of contraversial changes by PHK. After
a quick think and discussion among various people some form of some of
these changes will probably be recommitted.
The reversion requested was requested by dg while discussions proceed.
PHK has indicated that he can live with this, and it has been agreed
that some form of some of these changes may return shortly after further
discussion.
Notes
Notes:
svn path=/head/; revision=50830
-rw-r--r-- | sys/conf/NOTES | 3 | ||||
-rw-r--r-- | sys/conf/options | 3 | ||||
-rw-r--r-- | sys/dev/ccd/ccd.c | 1 | ||||
-rw-r--r-- | sys/dev/fdc/fdc.c | 1 | ||||
-rw-r--r-- | sys/dev/vinum/vinum.c | 1 | ||||
-rw-r--r-- | sys/dev/vn/vn.c | 5 | ||||
-rw-r--r-- | sys/fs/specfs/spec_vnops.c | 77 | ||||
-rw-r--r-- | sys/geom/geom_ccd.c | 1 | ||||
-rw-r--r-- | sys/i386/conf/LINT | 3 | ||||
-rw-r--r-- | sys/i386/conf/NOTES | 3 | ||||
-rw-r--r-- | sys/isa/fd.c | 1 | ||||
-rw-r--r-- | sys/kern/subr_diskslice.c | 1 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 34 | ||||
-rw-r--r-- | sys/miscfs/specfs/spec_vnops.c | 77 | ||||
-rw-r--r-- | sys/sys/conf.h | 2 | ||||
-rw-r--r-- | sys/sys/linedisc.h | 2 | ||||
-rw-r--r-- | sys/ufs/mfs/mfs_vfsops.c | 2 |
17 files changed, 95 insertions, 122 deletions
diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 7868bd87153c..544b2f402858 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -625,9 +625,6 @@ pseudo-device vcoda 4 #coda minicache <-> venus comm. # options EXT2FS -# -# Only set this if you positively know why you should never do that. -options ALLOW_BDEV_ACCESS # enable bdev access ##################################################################### diff --git a/sys/conf/options b/sys/conf/options index 2146ffe6f8f5..ba04359ad8f8 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -126,9 +126,6 @@ CD9660_ROOTDELAY opt_cd9660.h # hidden yet. UNION -# Options for all filesystems -ALLOW_BDEV_ACCESS opt_fs.h - # Options used only in param.c. HZ opt_param.h MAXFILES opt_param.h diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c index c4a0a8e79450..7badacb7d7c0 100644 --- a/sys/dev/ccd/ccd.c +++ b/sys/dev/ccd/ccd.c @@ -634,6 +634,7 @@ ccdopen(dev, flags, fmt, p) pmask = (1 << part); dev->si_bsize_phys = DEV_BSIZE; + dev->si_bsize_best = BLKDEV_IOSIZE; dev->si_bsize_max = MAXBSIZE; /* diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index 539569dff362..7704cca01998 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -1227,6 +1227,7 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p) fdc_p fdc; dev->si_bsize_phys = DEV_BSIZE; + dev->si_bsize_best = BLKDEV_IOSIZE; dev->si_bsize_max = MAXBSIZE; /* check bounds */ if ((fd = devclass_get_softc(fd_devclass, fdu)) == 0) diff --git a/sys/dev/vinum/vinum.c b/sys/dev/vinum/vinum.c index 46ff86a3330f..2482185d7aba 100644 --- a/sys/dev/vinum/vinum.c +++ b/sys/dev/vinum/vinum.c @@ -269,6 +269,7 @@ vinumopen(dev_t dev, devminor = minor(dev); dev->si_bsize_phys = DEV_BSIZE; + dev->si_bsize_best = VINUM_BSIZE_BEST; /* kludge until we track drive block sizes */ dev->si_bsize_max = MAXBSIZE; error = 0; /* First, decide what we're looking at */ diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c index 199c8046d460..f51efca8ed75 100644 --- a/sys/dev/vn/vn.c +++ b/sys/dev/vn/vn.c @@ -510,7 +510,10 @@ vniocattach_file(vn, vio, dev, flag, p) (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); return(error); } - dev->si_bsize_phys = vn->sc_secsize; + if (dev->si_bsize_phys < vn->sc_secsize) + dev->si_bsize_phys = vn->sc_secsize; + if (dev->si_bsize_best < vn->sc_secsize) + dev->si_bsize_best = vn->sc_secsize; vn->sc_flags |= VNF_INITED; if (flags == FREAD) vn->sc_flags |= VNF_READONLY; diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index 8fd4539a825d..1afc40017da4 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -34,7 +34,6 @@ * $FreeBSD$ */ -#include "opt_fs.h" #include <sys/param.h> #include <sys/proc.h> #include <sys/systm.h> @@ -47,7 +46,6 @@ #include <sys/fcntl.h> #include <sys/disklabel.h> #include <sys/vmmeter.h> -#include <sys/sysctl.h> #include <vm/vm.h> #include <vm/vm_prot.h> @@ -235,15 +233,6 @@ spec_open(ap) return (0); } -#ifdef ALLOW_BDEV_ACCESS -static int bdev_access = 1; -#else -static int bdev_access; -#endif - -SYSCTL_INT(_vfs, OID_AUTO, bdev_access, CTLFLAG_RW, &bdev_access, 0, - "allow block device access"); - /* * Vnode op for read */ @@ -257,8 +246,8 @@ spec_read(ap) struct ucred *a_cred; } */ *ap; { - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; + register struct vnode *vp = ap->a_vp; + register struct uio *uio = ap->a_uio; struct proc *p = uio->uio_procp; struct buf *bp; daddr_t bn, nextbn; @@ -269,8 +258,6 @@ spec_read(ap) int error = 0; dev_t dev; - dev = vp->v_rdev; - #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_READ) panic("spec_read mode"); @@ -282,14 +269,24 @@ spec_read(ap) switch (vp->v_type) { + case VCHR: + VOP_UNLOCK(vp, 0, p); + error = (*devsw(vp->v_rdev)->d_read) + (vp->v_rdev, uio, ap->a_ioflag); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + return (error); + case VBLK: -if (bdev_access) { if (uio->uio_offset < 0) return (EINVAL); + dev = vp->v_rdev; - bsize = dev->si_bsize_phys; - if (bsize < BLKDEV_IOSIZE) - bsize = BLKDEV_IOSIZE; + /* + * Calculate block size for block device. The block size must + * be larger then the physical minimum. + */ + + bsize = vp->v_rdev->si_bsize_best; if ((ioctl = devsw(dev)->d_ioctl) != NULL && (*ioctl)(dev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0 && @@ -317,12 +314,6 @@ if (bdev_access) { brelse(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); return (error); -} - case VCHR: - VOP_UNLOCK(vp, 0, p); - error = (*devsw(dev)->d_read) (dev, uio, ap->a_ioflag); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - return (error); default: panic("spec_read type"); @@ -343,8 +334,8 @@ spec_write(ap) struct ucred *a_cred; } */ *ap; { - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; + register struct vnode *vp = ap->a_vp; + register struct uio *uio = ap->a_uio; struct proc *p = uio->uio_procp; struct buf *bp; daddr_t bn; @@ -352,30 +343,36 @@ spec_write(ap) struct partinfo dpart; register int n, on; int error = 0; - dev_t dev; - dev = vp->v_rdev; #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_WRITE) panic("spec_write mode"); if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc) panic("spec_write proc"); #endif - if (uio->uio_resid == 0) - return (0); switch (vp->v_type) { + case VCHR: + VOP_UNLOCK(vp, 0, p); + error = (*devsw(vp->v_rdev)->d_write) + (vp->v_rdev, uio, ap->a_ioflag); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + return (error); + case VBLK: -if (bdev_access) { + if (uio->uio_resid == 0) + return (0); if (uio->uio_offset < 0) return (EINVAL); - bsize = dev->si_bsize_phys; - if (bsize < BLKDEV_IOSIZE) - bsize = BLKDEV_IOSIZE; + /* + * Calculate block size for block device. The block size must + * be larger then the physical minimum. + */ + bsize = vp->v_rdev->si_bsize_best; - if ((*devsw(dev)->d_ioctl)(dev, DIOCGPART, + if ((*devsw(vp->v_rdev)->d_ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) { if (dpart.part->p_fstype == FS_BSDFFS && dpart.part->p_frag != 0 && dpart.part->p_fsize != 0) @@ -403,14 +400,6 @@ if (bdev_access) { bdwrite(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); return (error); -} - - case VCHR: - VOP_UNLOCK(vp, 0, p); - error = (*devsw(dev)->d_write) - (dev, uio, ap->a_ioflag); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - return (error); default: panic("spec_write type"); diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index c4a0a8e79450..7badacb7d7c0 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -634,6 +634,7 @@ ccdopen(dev, flags, fmt, p) pmask = (1 << part); dev->si_bsize_phys = DEV_BSIZE; + dev->si_bsize_best = BLKDEV_IOSIZE; dev->si_bsize_max = MAXBSIZE; /* diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index 7868bd87153c..544b2f402858 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -625,9 +625,6 @@ pseudo-device vcoda 4 #coda minicache <-> venus comm. # options EXT2FS -# -# Only set this if you positively know why you should never do that. -options ALLOW_BDEV_ACCESS # enable bdev access ##################################################################### diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 7868bd87153c..544b2f402858 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -625,9 +625,6 @@ pseudo-device vcoda 4 #coda minicache <-> venus comm. # options EXT2FS -# -# Only set this if you positively know why you should never do that. -options ALLOW_BDEV_ACCESS # enable bdev access ##################################################################### diff --git a/sys/isa/fd.c b/sys/isa/fd.c index 539569dff362..7704cca01998 100644 --- a/sys/isa/fd.c +++ b/sys/isa/fd.c @@ -1227,6 +1227,7 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p) fdc_p fdc; dev->si_bsize_phys = DEV_BSIZE; + dev->si_bsize_best = BLKDEV_IOSIZE; dev->si_bsize_max = MAXBSIZE; /* check bounds */ if ((fd = devclass_get_softc(fd_devclass, fdu)) == 0) diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index d8dda7221d93..df187ef67b65 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -716,6 +716,7 @@ dsopen(dev, mode, flags, sspp, lp) int unit; dev->si_bsize_phys = lp->d_secsize; + dev->si_bsize_best = BLKDEV_IOSIZE; dev->si_bsize_max = MAXBSIZE; unit = dkunit(dev); diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index c64a77e55280..0a08938ae24b 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -429,31 +429,23 @@ vn_stat(vp, sb, p) sb->st_atimespec = vap->va_atime; sb->st_mtimespec = vap->va_mtime; sb->st_ctimespec = vap->va_ctime; - /* - * According to www.opengroup.org, the meaning of st_blksize is - * "a filesystem-specific preferred I/O block size for this - * object. In some filesystem types, this may vary from file - * to file" - * Default to zero to catch bogus uses of this field. + * For block and char device nodes we don't really care + * about what the filesystem told us, we want to know + * what the device told us */ - sb->st_blksize = 0; - - if (vp->v_type == VREG) - sb->st_blksize = vap->va_blocksize; - - /* - * For disks we can say something sensible. We report the max - * size because we prefer few big transfers than many small. - * XXX: Only reliable if the disk is opened. - * XXX: Use vn_isdisk when it allows VCHR too - */ - if ((vp->v_type == VBLK || vp->v_type == VCHR) && - devsw(vp->v_rdev) && (devsw(vp->v_rdev)->d_flags & D_DISK)) + switch (vap->va_type) { + case VBLK: + sb->st_blksize = vp->v_rdev->si_bsize_best; + break; + case VCHR: sb->st_blksize = vp->v_rdev->si_bsize_max; - + break; + default: + sb->st_blksize = vap->va_blocksize; + break; + } sb->st_flags = vap->va_flags; - if (suser_xxx(p->p_ucred, 0, 0)) sb->st_gen = 0; else diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index 8fd4539a825d..1afc40017da4 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -34,7 +34,6 @@ * $FreeBSD$ */ -#include "opt_fs.h" #include <sys/param.h> #include <sys/proc.h> #include <sys/systm.h> @@ -47,7 +46,6 @@ #include <sys/fcntl.h> #include <sys/disklabel.h> #include <sys/vmmeter.h> -#include <sys/sysctl.h> #include <vm/vm.h> #include <vm/vm_prot.h> @@ -235,15 +233,6 @@ spec_open(ap) return (0); } -#ifdef ALLOW_BDEV_ACCESS -static int bdev_access = 1; -#else -static int bdev_access; -#endif - -SYSCTL_INT(_vfs, OID_AUTO, bdev_access, CTLFLAG_RW, &bdev_access, 0, - "allow block device access"); - /* * Vnode op for read */ @@ -257,8 +246,8 @@ spec_read(ap) struct ucred *a_cred; } */ *ap; { - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; + register struct vnode *vp = ap->a_vp; + register struct uio *uio = ap->a_uio; struct proc *p = uio->uio_procp; struct buf *bp; daddr_t bn, nextbn; @@ -269,8 +258,6 @@ spec_read(ap) int error = 0; dev_t dev; - dev = vp->v_rdev; - #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_READ) panic("spec_read mode"); @@ -282,14 +269,24 @@ spec_read(ap) switch (vp->v_type) { + case VCHR: + VOP_UNLOCK(vp, 0, p); + error = (*devsw(vp->v_rdev)->d_read) + (vp->v_rdev, uio, ap->a_ioflag); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + return (error); + case VBLK: -if (bdev_access) { if (uio->uio_offset < 0) return (EINVAL); + dev = vp->v_rdev; - bsize = dev->si_bsize_phys; - if (bsize < BLKDEV_IOSIZE) - bsize = BLKDEV_IOSIZE; + /* + * Calculate block size for block device. The block size must + * be larger then the physical minimum. + */ + + bsize = vp->v_rdev->si_bsize_best; if ((ioctl = devsw(dev)->d_ioctl) != NULL && (*ioctl)(dev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0 && @@ -317,12 +314,6 @@ if (bdev_access) { brelse(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); return (error); -} - case VCHR: - VOP_UNLOCK(vp, 0, p); - error = (*devsw(dev)->d_read) (dev, uio, ap->a_ioflag); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - return (error); default: panic("spec_read type"); @@ -343,8 +334,8 @@ spec_write(ap) struct ucred *a_cred; } */ *ap; { - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; + register struct vnode *vp = ap->a_vp; + register struct uio *uio = ap->a_uio; struct proc *p = uio->uio_procp; struct buf *bp; daddr_t bn; @@ -352,30 +343,36 @@ spec_write(ap) struct partinfo dpart; register int n, on; int error = 0; - dev_t dev; - dev = vp->v_rdev; #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_WRITE) panic("spec_write mode"); if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc) panic("spec_write proc"); #endif - if (uio->uio_resid == 0) - return (0); switch (vp->v_type) { + case VCHR: + VOP_UNLOCK(vp, 0, p); + error = (*devsw(vp->v_rdev)->d_write) + (vp->v_rdev, uio, ap->a_ioflag); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + return (error); + case VBLK: -if (bdev_access) { + if (uio->uio_resid == 0) + return (0); if (uio->uio_offset < 0) return (EINVAL); - bsize = dev->si_bsize_phys; - if (bsize < BLKDEV_IOSIZE) - bsize = BLKDEV_IOSIZE; + /* + * Calculate block size for block device. The block size must + * be larger then the physical minimum. + */ + bsize = vp->v_rdev->si_bsize_best; - if ((*devsw(dev)->d_ioctl)(dev, DIOCGPART, + if ((*devsw(vp->v_rdev)->d_ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) { if (dpart.part->p_fstype == FS_BSDFFS && dpart.part->p_frag != 0 && dpart.part->p_fsize != 0) @@ -403,14 +400,6 @@ if (bdev_access) { bdwrite(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); return (error); -} - - case VCHR: - VOP_UNLOCK(vp, 0, p); - error = (*devsw(dev)->d_write) - (dev, uio, ap->a_ioflag); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - return (error); default: panic("spec_write type"); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 7232781ddc08..ddf4c68137b3 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -69,6 +69,7 @@ struct specinfo { struct disk *__sid_disk; struct mount *__sid_mountpoint; int __sid_bsize_phys; /* min physical block size */ + int __sid_bsize_best; /* optimal block size */ int __sid_bsize_max; /* maximum block size */ } __si_disk; } __si_u; @@ -78,6 +79,7 @@ struct specinfo { #define si_disk __si_u.__si_disk.__sid_disk #define si_mountpoint __si_u.__si_disk.__sid_mountpoint #define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys +#define si_bsize_best __si_u.__si_disk.__sid_bsize_best #define si_bsize_max __si_u.__si_disk.__sid_bsize_max /* diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 7232781ddc08..ddf4c68137b3 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -69,6 +69,7 @@ struct specinfo { struct disk *__sid_disk; struct mount *__sid_mountpoint; int __sid_bsize_phys; /* min physical block size */ + int __sid_bsize_best; /* optimal block size */ int __sid_bsize_max; /* maximum block size */ } __si_disk; } __si_u; @@ -78,6 +79,7 @@ struct specinfo { #define si_disk __si_u.__si_disk.__sid_disk #define si_mountpoint __si_u.__si_disk.__sid_mountpoint #define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys +#define si_bsize_best __si_u.__si_disk.__sid_bsize_best #define si_bsize_max __si_u.__si_disk.__sid_bsize_max /* diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c index 4f8c9f684e3c..044bf634390d 100644 --- a/sys/ufs/mfs/mfs_vfsops.c +++ b/sys/ufs/mfs/mfs_vfsops.c @@ -333,6 +333,7 @@ mfs_mount(mp, path, data, ndp, p) devvp->v_type = VBLK; dev = make_dev(&mfs_cdevsw, mfs_minor, 0, 0, 0, "MFS%d", mfs_minor); dev->si_bsize_phys = DEV_BSIZE; + dev->si_bsize_best = BLKDEV_IOSIZE; dev->si_bsize_max = MAXBSIZE; addaliasu(devvp, makeudev(253, mfs_minor++)); devvp->v_data = mfsp; @@ -494,6 +495,7 @@ mfs_init(vfsp) rootdev = make_dev(&mfs_cdevsw, mfs_minor, 0, 0, 0, "MFS%d", mfs_minor); rootdev->si_bsize_phys = DEV_BSIZE; + rootdev->si_bsize_best = BLKDEV_IOSIZE; rootdev->si_bsize_max = MAXBSIZE; mfs_minor++; } else if (bootverbose) |