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.
This commit is contained in:
Julian Elischer 1999-09-03 05:16:59 +00:00
parent 2a0434714f
commit 7012bab988
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=50830
17 changed files with 95 additions and 122 deletions

View file

@ -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
#####################################################################

View file

@ -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

View file

@ -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;
/*

View file

@ -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)

View file

@ -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 */

View file

@ -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;

View file

@ -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");

View file

@ -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;
/*

View file

@ -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
#####################################################################

View file

@ -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
#####################################################################

View file

@ -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)

View file

@ -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);

View file

@ -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

View file

@ -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");

View file

@ -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
/*

View file

@ -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
/*

View file

@ -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)