Changes to centralise the default blocksize behaviour.
More likely to follow. Submitted by: phk@freebsd.org
This commit is contained in:
parent
3113e9d141
commit
85a219d201
@ -633,10 +633,6 @@ ccdopen(dev, flags, fmt, p)
|
||||
part = ccdpart(dev);
|
||||
pmask = (1 << part);
|
||||
|
||||
dev->si_bsize_phys = DEV_BSIZE;
|
||||
dev->si_bsize_best = BLKDEV_IOSIZE;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
|
||||
/*
|
||||
* If we're initialized, check to see if there are any other
|
||||
* open partitions. If not, then it's safe to update
|
||||
|
@ -1279,9 +1279,6 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p)
|
||||
fd_p fd;
|
||||
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)
|
||||
return (ENXIO);
|
||||
|
@ -296,8 +296,6 @@ int mcdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
if (!(cd->flags & MCDVALID) && cd->openflags)
|
||||
return ENXIO;
|
||||
|
||||
dev->si_bsize_phys = 2048;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
if (mcd_getstat(unit,1) == -1)
|
||||
return EIO;
|
||||
|
||||
@ -352,6 +350,8 @@ int mcdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
MCD_TRACE("open: partition=%d, disksize = %ld, blksize=%d\n",
|
||||
part, cd->disksize, cd->blksize);
|
||||
|
||||
dev->si_bsize_phys = cd->blksize;
|
||||
|
||||
if (part == RAW_PART ||
|
||||
(part < cd->dlabel.d_npartitions &&
|
||||
cd->dlabel.d_partitions[part].p_fstype != FS_UNUSED)) {
|
||||
|
@ -258,8 +258,6 @@ scdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
|
||||
XDEBUG(1,("scd%d: DEBUG: status = 0x%x\n", unit, inb(cd->iobase+IREG_STATUS)));
|
||||
|
||||
dev->si_bsize_phys = 2048;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
if ((rc = spin_up(unit)) != 0) {
|
||||
print_error(unit, rc);
|
||||
return EIO;
|
||||
@ -281,6 +279,8 @@ scdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
}
|
||||
|
||||
dev->si_bsize_phys = cd->blksize;
|
||||
|
||||
cd->openflag = 1;
|
||||
cd->flags |= SCDVALID;
|
||||
|
||||
|
@ -268,9 +268,6 @@ vinumopen(dev_t dev,
|
||||
int devminor; /* minor number */
|
||||
|
||||
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 */
|
||||
switch (DEVTYPE(dev)) {
|
||||
|
@ -510,10 +510,7 @@ vniocattach_file(vn, vio, dev, flag, p)
|
||||
(void) vn_close(nd.ni_vp, flags, p->p_ucred, p);
|
||||
return(error);
|
||||
}
|
||||
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;
|
||||
dev->si_bsize_phys = vn->sc_secsize;
|
||||
vn->sc_flags |= VNF_INITED;
|
||||
if (flags == FREAD)
|
||||
vn->sc_flags |= VNF_READONLY;
|
||||
|
@ -234,8 +234,6 @@ spec_open(ap)
|
||||
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;
|
||||
}
|
||||
@ -296,6 +294,10 @@ spec_read(ap)
|
||||
*/
|
||||
|
||||
bsize = vp->v_rdev->si_bsize_best;
|
||||
if (bsize < vp->v_rdev->si_bsize_phys)
|
||||
bsize = vp->v_rdev->si_bsize_phys;
|
||||
if (bsize < BLKDEV_IOSIZE)
|
||||
bsize = BLKDEV_IOSIZE;
|
||||
|
||||
if ((ioctl = devsw(dev)->d_ioctl) != NULL &&
|
||||
(*ioctl)(dev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0 &&
|
||||
@ -380,6 +382,10 @@ spec_write(ap)
|
||||
* be larger then the physical minimum.
|
||||
*/
|
||||
bsize = vp->v_rdev->si_bsize_best;
|
||||
if (bsize < vp->v_rdev->si_bsize_phys)
|
||||
bsize = vp->v_rdev->si_bsize_phys;
|
||||
if (bsize < BLKDEV_IOSIZE)
|
||||
bsize = BLKDEV_IOSIZE;
|
||||
|
||||
if ((*devsw(vp->v_rdev)->d_ioctl)(vp->v_rdev, DIOCGPART,
|
||||
(caddr_t)&dpart, FREAD, p) == 0) {
|
||||
|
@ -633,10 +633,6 @@ ccdopen(dev, flags, fmt, p)
|
||||
part = ccdpart(dev);
|
||||
pmask = (1 << part);
|
||||
|
||||
dev->si_bsize_phys = DEV_BSIZE;
|
||||
dev->si_bsize_best = BLKDEV_IOSIZE;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
|
||||
/*
|
||||
* If we're initialized, check to see if there are any other
|
||||
* open partitions. If not, then it's safe to update
|
||||
|
@ -399,8 +399,6 @@ acdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
return ENXIO;
|
||||
cdp = acdtab[lun];
|
||||
|
||||
dev->si_bsize_phys = 2048;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) {
|
||||
/* Prevent user eject */
|
||||
acd_request_wait(cdp, ATAPI_PREVENT_ALLOW,
|
||||
@ -411,7 +409,7 @@ acdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
cdp->flags |= F_BOPEN;
|
||||
else
|
||||
++cdp->refcnt;
|
||||
|
||||
dev->si_bsize_phys = cdp->block_size;
|
||||
if (!(flags & O_NONBLOCK) && acd_read_toc(cdp) && !(flags & FWRITE))
|
||||
printf("acd%d: read_toc failed\n", lun);
|
||||
return 0;
|
||||
|
@ -623,9 +623,6 @@ int matcdopen(dev_t dev, int flags, int fmt,
|
||||
|
||||
if (ldrive >= TOTALDRIVES) return(ENXIO);
|
||||
|
||||
dev->si_bsize_phys = 2048;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
|
||||
#ifdef DEBUGOPEN
|
||||
printf("matcd%d: Open: dev %x partition %x controller %x flags %x cdrive %x\n",
|
||||
ldrive,(int)dev,partition,controller,cd->flags,
|
||||
@ -696,7 +693,6 @@ int matcdopen(dev_t dev, int flags, int fmt,
|
||||
if ((cd->flags & MATCDLABEL)==0) {
|
||||
bzero(&cd->dlabel,sizeof(struct disklabel));
|
||||
|
||||
|
||||
/* Now we query the drive for the actual size of the media.
|
||||
This is where we find out of there is any media or if the
|
||||
media isn't a Mode 1 or Mode 2/XA disc.
|
||||
@ -749,6 +745,8 @@ int matcdopen(dev_t dev, int flags, int fmt,
|
||||
cd->flags |= MATCDLABEL; /*Mark drive as having TOC*/
|
||||
}
|
||||
|
||||
dev->si_bsize_phys = cd->blksize;
|
||||
|
||||
#ifdef DEBUGOPEN
|
||||
printf("matcd%d open2: partition=%d disksize=%d blksize=%x flags=%x\n",
|
||||
ldrive,partition,(int)cd->disksize,cd->blksize,cd->flags);
|
||||
|
@ -296,8 +296,6 @@ int mcdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
if (!(cd->flags & MCDVALID) && cd->openflags)
|
||||
return ENXIO;
|
||||
|
||||
dev->si_bsize_phys = 2048;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
if (mcd_getstat(unit,1) == -1)
|
||||
return EIO;
|
||||
|
||||
@ -352,6 +350,8 @@ int mcdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
MCD_TRACE("open: partition=%d, disksize = %ld, blksize=%d\n",
|
||||
part, cd->disksize, cd->blksize);
|
||||
|
||||
dev->si_bsize_phys = cd->blksize;
|
||||
|
||||
if (part == RAW_PART ||
|
||||
(part < cd->dlabel.d_npartitions &&
|
||||
cd->dlabel.d_partitions[part].p_fstype != FS_UNUSED)) {
|
||||
|
@ -258,8 +258,6 @@ scdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
|
||||
XDEBUG(1,("scd%d: DEBUG: status = 0x%x\n", unit, inb(cd->iobase+IREG_STATUS)));
|
||||
|
||||
dev->si_bsize_phys = 2048;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
if ((rc = spin_up(unit)) != 0) {
|
||||
print_error(unit, rc);
|
||||
return EIO;
|
||||
@ -281,6 +279,8 @@ scdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
}
|
||||
|
||||
dev->si_bsize_phys = cd->blksize;
|
||||
|
||||
cd->openflag = 1;
|
||||
cd->flags |= SCDVALID;
|
||||
|
||||
|
@ -399,8 +399,6 @@ acdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
return ENXIO;
|
||||
cdp = acdtab[lun];
|
||||
|
||||
dev->si_bsize_phys = 2048;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) {
|
||||
/* Prevent user eject */
|
||||
acd_request_wait(cdp, ATAPI_PREVENT_ALLOW,
|
||||
@ -411,7 +409,7 @@ acdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
cdp->flags |= F_BOPEN;
|
||||
else
|
||||
++cdp->refcnt;
|
||||
|
||||
dev->si_bsize_phys = cdp->block_size;
|
||||
if (!(flags & O_NONBLOCK) && acd_read_toc(cdp) && !(flags & FWRITE))
|
||||
printf("acd%d: read_toc failed\n", lun);
|
||||
return 0;
|
||||
|
@ -1279,9 +1279,6 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p)
|
||||
fd_p fd;
|
||||
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)
|
||||
return (ENXIO);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/disk.h>
|
||||
@ -235,3 +236,14 @@ diskpsize(dev_t dev)
|
||||
}
|
||||
return (dssize(dev, &dp->d_slice));
|
||||
}
|
||||
|
||||
SYSCTL_DECL(_debug_sizeof);
|
||||
|
||||
SYSCTL_INT(_debug_sizeof, OID_AUTO, disklabel, CTLFLAG_RD,
|
||||
0, sizeof(struct disklabel), "sizeof(struct disklabel)");
|
||||
|
||||
SYSCTL_INT(_debug_sizeof, OID_AUTO, diskslices, CTLFLAG_RD,
|
||||
0, sizeof(struct diskslices), "sizeof(struct diskslices)");
|
||||
|
||||
SYSCTL_INT(_debug_sizeof, OID_AUTO, disk, CTLFLAG_RD,
|
||||
0, sizeof(struct disk), "sizeof(struct disk)");
|
||||
|
@ -718,8 +718,6 @@ 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);
|
||||
if (lp->d_secsize % DEV_BSIZE) {
|
||||
|
@ -429,22 +429,29 @@ vn_stat(vp, sb, p)
|
||||
sb->st_atimespec = vap->va_atime;
|
||||
sb->st_mtimespec = vap->va_mtime;
|
||||
sb->st_ctimespec = vap->va_ctime;
|
||||
/*
|
||||
* 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
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
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:
|
||||
|
||||
if (vap->va_type == VREG) {
|
||||
sb->st_blksize = vap->va_blocksize;
|
||||
break;
|
||||
} else if ((vp->v_type == VBLK || vp->v_type == VCHR) &&
|
||||
devsw(vp->v_rdev) && (devsw(vp->v_rdev)->d_flags & D_DISK)) {
|
||||
/* XXX use vn_isdisk() above once VCHR is also disk */
|
||||
sb->st_blksize = vp->v_rdev->si_bsize_best;
|
||||
if (sb->st_blksize < vp->v_rdev->si_bsize_phys)
|
||||
sb->st_blksize = vp->v_rdev->si_bsize_phys;
|
||||
if (sb->st_blksize < BLKDEV_IOSIZE)
|
||||
sb->st_blksize = BLKDEV_IOSIZE;
|
||||
} else {
|
||||
sb->st_blksize = 0;
|
||||
}
|
||||
|
||||
sb->st_flags = vap->va_flags;
|
||||
if (suser_xxx(p->p_ucred, 0, 0))
|
||||
sb->st_gen = 0;
|
||||
|
@ -234,8 +234,6 @@ spec_open(ap)
|
||||
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;
|
||||
}
|
||||
@ -296,6 +294,10 @@ spec_read(ap)
|
||||
*/
|
||||
|
||||
bsize = vp->v_rdev->si_bsize_best;
|
||||
if (bsize < vp->v_rdev->si_bsize_phys)
|
||||
bsize = vp->v_rdev->si_bsize_phys;
|
||||
if (bsize < BLKDEV_IOSIZE)
|
||||
bsize = BLKDEV_IOSIZE;
|
||||
|
||||
if ((ioctl = devsw(dev)->d_ioctl) != NULL &&
|
||||
(*ioctl)(dev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0 &&
|
||||
@ -380,6 +382,10 @@ spec_write(ap)
|
||||
* be larger then the physical minimum.
|
||||
*/
|
||||
bsize = vp->v_rdev->si_bsize_best;
|
||||
if (bsize < vp->v_rdev->si_bsize_phys)
|
||||
bsize = vp->v_rdev->si_bsize_phys;
|
||||
if (bsize < BLKDEV_IOSIZE)
|
||||
bsize = BLKDEV_IOSIZE;
|
||||
|
||||
if ((*devsw(vp->v_rdev)->d_ioctl)(vp->v_rdev, DIOCGPART,
|
||||
(caddr_t)&dpart, FREAD, p) == 0) {
|
||||
|
@ -399,8 +399,6 @@ acdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
return ENXIO;
|
||||
cdp = acdtab[lun];
|
||||
|
||||
dev->si_bsize_phys = 2048;
|
||||
dev->si_bsize_max = MAXBSIZE;
|
||||
if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) {
|
||||
/* Prevent user eject */
|
||||
acd_request_wait(cdp, ATAPI_PREVENT_ALLOW,
|
||||
@ -411,7 +409,7 @@ acdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
cdp->flags |= F_BOPEN;
|
||||
else
|
||||
++cdp->refcnt;
|
||||
|
||||
dev->si_bsize_phys = cdp->block_size;
|
||||
if (!(flags & O_NONBLOCK) && acd_read_toc(cdp) && !(flags & FWRITE))
|
||||
printf("acd%d: read_toc failed\n", lun);
|
||||
return 0;
|
||||
|
@ -332,8 +332,8 @@ 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);
|
||||
/* It is not clear that these will get initialized otherwise */
|
||||
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,8 +494,8 @@ mfs_init(vfsp)
|
||||
mountrootfsname = "mfs";
|
||||
rootdev = make_dev(&mfs_cdevsw, mfs_minor,
|
||||
0, 0, 0, "MFS%d", mfs_minor);
|
||||
/* It is not clear that these will get initialized otherwise */
|
||||
rootdev->si_bsize_phys = DEV_BSIZE;
|
||||
rootdev->si_bsize_best = BLKDEV_IOSIZE;
|
||||
rootdev->si_bsize_max = MAXBSIZE;
|
||||
mfs_minor++;
|
||||
} else if (bootverbose)
|
||||
|
Loading…
Reference in New Issue
Block a user