NetBSD Problem Report #3791

Received: (qmail 3684 invoked from network); 25 Jun 1997 08:27:15 -0000
Message-Id: <199706250805.RAA19862@bimota.imada.math.human.nagoya-u.ac.jp>
Date: Wed, 25 Jun 1997 17:05:23 +0900 (JST)
From: koji@math.human.nagoya-u.ac.jp
Reply-To: koji@math.human.nagoya-u.ac.jp
To: gnats-bugs@gnats.netbsd.org
Subject: non-512 bytes/sector media support case 2
X-Send-Pr-Version: 3.95

>Number:         3791
>Category:       kern
>Synopsis:       non-512 bytes/sector media support case 2
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 25 01:35:02 +0000 1997
>Closed-Date:    
>Last-Modified:  Mon Feb 28 14:55:46 +0000 2011
>Originator:     Koji Imada - je4owb/2
>Release:        970622
>Organization:
Mathematics Group of Graduate School of Human
	Infomatics, Nagoya University, Japan.
>Environment:

System: NetBSD bimota 1.2E NetBSD 1.2E (BIMOTA) #: Wed Jun 11 02:13:27 JST 1997 koji@ducati:/mnt2/NetBSD/work/src-ufs-mod/sys/arch/i386/compile/BIMOTA i386


>Description:
	Modification required to support non-512 bytes/sector media
	for file system and device drivers.

	This is case 2 of 3 implementation. This keeps block io unit
	as DEV_BSIZE and adapts file systems(cd9660, ffs, msdosfs) and
	device driver(cd, sd) to support non-512 bytes/sector media.

	I will send mail to tech-kern about these 3 implementation.

	Also, these obsoletes kern/3460 and kern/3458
>How-To-Repeat:
	Current NetBSD can't handle non-512 bytes/sector media properly.
>Fix:
	Apply following patches
Index: sys/arch/i386/i386/disksubr.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/arch/i386/i386/disksubr.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 disksubr.c
--- disksubr.c	1997/04/01 07:21:40	1.1.1.2
+++ disksubr.c	1997/06/25 06:38:03
@@ -91,7 +91,7 @@
 	lp->d_partitions[i].p_offset = 0;

 	/* get a buffer and initialize it */
-	bp = geteblk((int)lp->d_secsize);
+	bp = geteblk((int)BLKDEV_IOSIZE);
 	bp->b_dev = dev;

 	/* do dos partitions in the process of getting disklabel? */
@@ -100,6 +100,12 @@
 	if (osdep && (dp = osdep->dosparts) != NULL) {
 		/* read master boot record */
 		bp->b_blkno = DOSBBSECTOR;
+#if 1
+		if (lp->d_secsize > DEV_BSIZE)
+			bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+		else
+			bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
 		bp->b_bcount = lp->d_secsize;
 		bp->b_flags = B_BUSY | B_READ;
 		bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
@@ -148,8 +154,14 @@

 	/* next, dig out disk label */
 	bp->b_blkno = dospartoff + LABELSECTOR;
+#if 1
+	if (lp->d_secsize > DEV_BSIZE)
+		bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+	else
+		bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
 	bp->b_cylin = cyl;
-	bp->b_bcount = lp->d_secsize;
+	bp->b_bcount = BLKDEV_IOSIZE;
 	bp->b_flags = B_BUSY | B_READ;
 	(*strat)(bp);

@@ -159,7 +171,7 @@
 		goto done;
 	}
 	for (dlp = (struct disklabel *)bp->b_data;
-	    dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp));
+	    dlp <= (struct disklabel *)(bp->b_data + BLKDEV_IOSIZE - sizeof(*dlp));
 	    dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
 		if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
 			if (msg == NULL)
@@ -186,10 +198,12 @@
 			/* read a bad sector table */
 			bp->b_flags = B_BUSY | B_READ;
 			bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i;
+#if 1
 			if (lp->d_secsize > DEV_BSIZE)
 				bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
 			else
 				bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
 			bp->b_bcount = lp->d_secsize;
 			bp->b_cylin = lp->d_ncylinders - 1;
 			(*strat)(bp);
@@ -291,7 +305,7 @@
 	int error, dospartoff, cyl, i;

 	/* get a buffer and initialize it */
-	bp = geteblk((int)lp->d_secsize);
+	bp = geteblk(BLKDEV_IOSIZE);
 	bp->b_dev = dev;

 	/* do dos partitions in the process of getting disklabel? */
@@ -300,6 +314,12 @@
 	if (osdep && (dp = osdep->dosparts) != NULL) {
 		/* read master boot record */
 		bp->b_blkno = DOSBBSECTOR;
+#if 1
+		if (lp->d_secsize > DEV_BSIZE)
+			bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+		else
+			bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
 		bp->b_bcount = lp->d_secsize;
 		bp->b_flags = B_BUSY | B_READ;
 		bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
@@ -333,8 +353,14 @@

 	/* next, dig out disk label */
 	bp->b_blkno = dospartoff + LABELSECTOR;
+#if 1
+	if (lp->d_secsize > DEV_BSIZE)
+		bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+	else
+		bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
 	bp->b_cylin = cyl;
-	bp->b_bcount = lp->d_secsize;
+	bp->b_bcount = BLKDEV_IOSIZE;
 	bp->b_flags = B_BUSY | B_READ;
 	(*strat)(bp);

@@ -342,7 +368,7 @@
 	if ((error = biowait(bp)) != 0)
 		goto done;
 	for (dlp = (struct disklabel *)bp->b_data;
-	    dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp));
+	    dlp <= (struct disklabel *)(bp->b_data + BLKDEV_IOSIZE - sizeof(*dlp));
 	    dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
 		if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC &&
 		    dkcksum(dlp) == 0) {
@@ -374,12 +400,21 @@
 {
 	struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
 	int labelsector = lp->d_partitions[2].p_offset + LABELSECTOR;
-	int sz;
+	int sz, blkno;
+
+#if 0
+	blkno = bp->b_blkno;
+#else
+	if (lp->d_secsize > DEV_BSIZE)
+		blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
+	else
+		blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
+#endif

 	sz = howmany(bp->b_bcount, lp->d_secsize);

-	if (bp->b_blkno + sz > p->p_size) {
-		sz = p->p_size - bp->b_blkno;
+	if (blkno + sz > p->p_size) {
+		sz = p->p_size - blkno;
 		if (sz == 0) {
 			/* If exactly at end of disk, return EOF. */
 			bp->b_resid = bp->b_bcount;
@@ -391,13 +426,13 @@
 			goto bad;
 		}
 		/* Otherwise, truncate request. */
-		bp->b_bcount = sz << DEV_BSHIFT;
+		bp->b_bcount = sz * lp->d_secsize;
 	}

 	/* Overwriting disk label? */
-	if (bp->b_blkno + p->p_offset <= labelsector &&
+	if (blkno + p->p_offset <= labelsector &&
 #if LABELSECTOR != 0
-	    bp->b_blkno + p->p_offset + sz > labelsector &&
+	    blkno + p->p_offset + sz > labelsector &&
 #endif
 	    (bp->b_flags & B_READ) == 0 && !wlabel) {
 		bp->b_error = EROFS;
@@ -405,8 +440,7 @@
 	}

 	/* calculate cylinder for disksort to order transfers with */
-	bp->b_cylin = (bp->b_blkno + p->p_offset) /
-	    (lp->d_secsize / DEV_BSIZE) / lp->d_secpercyl;
+	bp->b_cylin = (blkno + p->p_offset) / lp->d_secpercyl;
 	return (1);

 bad:
Index: sys/dev/vnd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/dev/vnd.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 vnd.c
--- vnd.c	1997/06/23 16:24:04	1.1.1.5
+++ vnd.c	1997/06/25 06:43:42
@@ -94,6 +94,10 @@
 #define b_cylin	b_resid

 #define	vndunit(x)	DISKUNIT(x)
+#define VNDPART(dev)	DISKPART(dev)
+#define MAKEVNDDEV(maj, unit, part)	MAKEDISKDEV(maj, unit, part)
+
+#define VNDLABELDEV(dev) (MAKEVNDDEV(major(dev), vndunit(dev), RAW_PART))

 struct vndxfer {
 	struct buf	*vx_bp;		/* Pointer to parent buffer */
@@ -118,6 +122,9 @@
 struct vnd_softc {
 	int		 sc_flags;	/* flags */
 	size_t		 sc_size;	/* size of vnd */
+	int		 sc_bsize;	/* block size for special file */
+	int		 sc_blksize;	/* number of bytes/dector */
+	int		 sc_bshift;	/* shift constant */
 	struct vnode	*sc_vp;		/* vnode */
 	struct ucred	*sc_cred;	/* credentials */
 	int		 sc_maxactive;	/* max # of active requests */
@@ -129,6 +136,8 @@
 /* sc_flags */
 #define	VNF_ALIVE	0x01
 #define VNF_INITED	0x02
+#define VNF_WLABEL	0x04
+#define VNF_LABELLING	0x08
 #define VNF_WANTED	0x40
 #define VNF_LOCKED	0x80

@@ -140,10 +149,11 @@

 void	vndclear __P((struct vnd_softc *));
 void	vndstart __P((struct vnd_softc *));
-int	vndsetcred __P((struct vnd_softc *, struct ucred *));
+int	vndsetcred __P((struct vnd_softc *, struct ucred *, struct proc *p));
 void	vndthrottle __P((struct vnd_softc *, struct vnode *));
 void	vndiodone __P((struct buf *));
 void	vndshutdown __P((void));
+void	vndgetdisklabel __P((dev_t dev, struct vnd_softc *vnd));

 static	int vndlock __P((struct vnd_softc *));
 static	void vndunlock __P((struct vnd_softc *));
@@ -196,6 +206,15 @@
 	part = DISKPART(dev);
 	pmask = (1 << part);

+	/* Check that the partition exists. */
+	if (part != RAW_PART &&
+	    ((sc->sc_flags & VNF_INITED) == 0 ||
+	     part >= sc->sc_dkdev.dk_label->d_npartitions ||
+	     sc->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
+		error = ENXIO;
+		goto bad;
+	}
+
 	/* Prevent our unit from being unconfigured while open. */
 	switch (mode) {
 	case S_IFCHR:
@@ -211,6 +230,10 @@

 	vndunlock(sc);
 	return (0);
+
+bad:
+	vndunlock(sc);
+	return error;
 }

 int
@@ -272,6 +295,7 @@
 	int sz, flags, error;

 #ifdef DEBUG
+ 	printf("vndstrategy(%p): bsize %ld\n", bp, vnd->sc_vp->v_mount->mnt_stat.f_iosize);
 	if (vnddebug & VDB_FOLLOW)
 		printf("vndstrategy(%p): unit %d\n", bp, unit);
 #endif
@@ -281,9 +305,28 @@
 		biodone(bp);
 		return;
 	}
+
+	if (VNDPART(bp->b_dev) != RAW_PART &&
+	    bounds_check_with_label(bp, vnd->sc_dkdev.dk_label,
+	    (vnd->sc_flags & (VNF_WLABEL|VNF_LABELLING)) != 0) <= 0) {
+		bp->b_resid = bp->b_bcount;
+		biodone(bp);
+		return;
+	}
+
+#if 0
 	bn = bp->b_blkno;
-	sz = howmany(bp->b_bcount, DEV_BSIZE);
+#else
+	bn = bp->b_blkno / (vnd->sc_dkdev.dk_label->d_secsize / DEV_BSIZE);
+#endif
 	bp->b_resid = bp->b_bcount;
+	sz = howmany(bp->b_bcount, vnd->sc_blksize);
+
+	if (VNDPART(bp->b_dev) != RAW_PART) {
+		bn += vnd->sc_dkdev.dk_label->d_partitions[VNDPART(bp->b_dev)].p_offset;
+	}
+	bn *= vnd->sc_dkdev.dk_label->d_secsize / vnd->sc_blksize;
+
 	if (bn < 0 || bn + sz > vnd->sc_size) {
 		if (bn != vnd->sc_size) {
 			bp->b_error = EINVAL;
@@ -292,8 +335,13 @@
 		biodone(bp);
 		return;
 	}
-	bn = dbtob(bn);
+
+	bn = bn << vnd->sc_bshift;
+#if 1
+	bsize = vnd->sc_bsize;
+#else
  	bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
+#endif
 	addr = bp->b_data;
 	flags = bp->b_flags | B_CALL;

@@ -512,6 +560,9 @@
 {
 	int unit = vndunit(dev);
 	struct vnd_softc *sc;
+#if 0
+	int bshift;
+#endif

 #ifdef DEBUG
 	if (vnddebug & VDB_FOLLOW)
@@ -525,7 +576,13 @@
 	if ((sc->sc_flags & VNF_INITED) == 0)
 		return (ENXIO);

+#if 1
 	return (physio(vndstrategy, NULL, dev, B_READ, minphys, uio));
+#else
+	bshift = ffs(sc->sc_dkdev.dk_label->d_secsize)-1;
+
+	return (physio2(vndstrategy, NULL, dev, B_READ, minphys, uio, bshift));
+#endif
 }

 /* ARGSUSED */
@@ -537,6 +594,9 @@
 {
 	int unit = vndunit(dev);
 	struct vnd_softc *sc;
+#if 0
+	int bshift;
+#endif

 #ifdef DEBUG
 	if (vnddebug & VDB_FOLLOW)
@@ -550,7 +610,13 @@
 	if ((sc->sc_flags & VNF_INITED) == 0)
 		return (ENXIO);

+#if 1
 	return (physio(vndstrategy, NULL, dev, B_WRITE, minphys, uio));
+#else
+	bshift = ffs(sc->sc_dkdev.dk_label->d_secsize)-1;
+
+	return (physio2(vndstrategy, NULL, dev, B_WRITE, minphys, uio, bshift));
+#endif
 }

 /* ARGSUSED */
@@ -588,6 +654,10 @@
 		if (vnd->sc_flags & VNF_INITED)
 			return (EBUSY);

+		if (vio->vnd_size == 0 || vio->vnd_size % DEV_BSIZE != 0 ||
+		    vio->vnd_size > BLKDEV_IOSIZE)
+			vio->vnd_size = DEV_BSIZE;
+
 		if ((error = vndlock(vnd)) != 0)
 			return (error);

@@ -602,23 +672,55 @@
 			vndunlock(vnd);
 			return(error);
 		}
-		error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
+		if (nd.ni_vp->v_type == VBLK || nd.ni_vp->v_type == VCHR) {
+			struct partinfo dpart;
+
+			dpart.disklab = NULL;
+			dpart.part = NULL;
+			error = VOP_IOCTL(nd.ni_vp, DIOCGPART, (caddr_t)&dpart,
+			    FREAD, NOCRED, p);
+			if (error == 0) {
+				if (dpart.disklab != NULL && dpart.disklab->d_secsize != 0)
+					vattr.va_blocksize = dpart.disklab->d_secsize;
+				else
+					vattr.va_blocksize = DEV_BSIZE;
+				if (dpart.part == NULL)
+					vattr.va_size = 0;
+				else {
+					vattr.va_size = dpart.part->p_size *
+					    dpart.disklab->d_secsize;
+				}
+			}
+		} else {
+			error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
+		}
 		if (error) {
 			VOP_UNLOCK(nd.ni_vp);
 			(void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
 			vndunlock(vnd);
 			return(error);
 		}
+			
 		VOP_UNLOCK(nd.ni_vp);
 		vnd->sc_vp = nd.ni_vp;
-		vnd->sc_size = btodb(vattr.va_size);	/* note truncation */
-		if ((error = vndsetcred(vnd, p->p_ucred)) != 0) {
+		vnd->sc_blksize = vio->vnd_size;
+		vnd->sc_bshift = ffs(vnd->sc_blksize) - 1;
+		vnd->sc_size = vattr.va_size >> vnd->sc_bshift;	/* note truncation */
+		if (nd.ni_vp->v_type != VBLK && nd.ni_vp->v_type != VCHR) {
+			vnd->sc_bsize = nd.ni_vp->v_mount->mnt_stat.f_iosize;
+		} else {
+			if (vattr.va_blocksize != 0)
+				vnd->sc_bsize = vattr.va_blocksize;
+			else
+				vnd->sc_bsize = DEV_BSIZE;
+		}
+		if ((error = vndsetcred(vnd, p->p_ucred, p)) != 0) {
 			(void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
 			vndunlock(vnd);
 			return(error);
 		}
 		vndthrottle(vnd, vnd->sc_vp);
-		vio->vnd_size = dbtob(vnd->sc_size);
+		vio->vnd_size = vnd->sc_size << vnd->sc_bshift;
 		vnd->sc_flags |= VNF_INITED;
 #ifdef DEBUG
 		if (vnddebug & VDB_INIT)
@@ -632,6 +734,8 @@
 		vnd->sc_dkdev.dk_name = vnd->sc_xname;
 		disk_attach(&vnd->sc_dkdev);

+		vndgetdisklabel(dev, vnd);
+
 		vndunlock(vnd);

 		break;
@@ -673,6 +777,60 @@
 	/*
 	 * XXX Should support disklabels.
 	 */
+	case DIOCGDINFO:
+		if ((vnd->sc_flags & VNF_INITED) == 0)
+			return (ENXIO);
+
+		*(struct disklabel *)data = *(vnd->sc_dkdev.dk_label);
+		return 0;
+
+	case DIOCGPART:
+		if ((vnd->sc_flags & VNF_INITED) == 0)
+			return (ENXIO);
+
+		((struct partinfo *)data)->disklab = vnd->sc_dkdev.dk_label;
+		((struct partinfo *)data)->part =
+		    &vnd->sc_dkdev.dk_label->d_partitions[VNDPART(dev)];
+		return 0;
+
+
+	case DIOCWDINFO:
+	case DIOCSDINFO:
+		if ((vnd->sc_flags & VNF_INITED) == 0)
+			return (ENXIO);
+
+		if ((flag & FWRITE) == 0)
+			return EBADF;
+
+		if ((error = vndlock(vnd)) != 0)
+			return error;
+		vnd->sc_flags |= VNF_LABELLING;
+
+		error = setdisklabel(vnd->sc_dkdev.dk_label,
+		    (struct disklabel *)data, /*vnd->sc_dkdev.dk_openmask : */0,
+		    vnd->sc_dkdev.dk_cpulabel);
+		if (error == 0) {
+			if (cmd == DIOCWDINFO)
+				error = writedisklabel(VNDLABELDEV(dev),
+				    vndstrategy, vnd->sc_dkdev.dk_label,
+				    vnd->sc_dkdev.dk_cpulabel);
+		}
+
+		vnd->sc_flags &= ~VNF_LABELLING;
+		vndunlock(vnd);
+		return error;
+
+	case DIOCWLABEL:
+		if ((vnd->sc_flags & VNF_INITED) == 0)
+			return (ENXIO);
+
+		if ((flag & FWRITE) == 0)
+			return EBADF;
+		if (*(int *)data)
+			vnd->sc_flags |= VNF_WLABEL;
+		else
+			vnd->sc_flags &= ~VNF_WLABEL;
+		return 0;

 	default:
 		return(ENOTTY);
@@ -682,15 +840,69 @@
 }

 /*
+ * Load the label information on the named device
+ */
+void
+vndgetdisklabel(dev, vnd)
+	dev_t dev;
+	struct vnd_softc *vnd;
+{
+	struct disklabel *lp = vnd->sc_dkdev.dk_label;
+	char *errstring;
+
+	bzero(lp, sizeof(struct disklabel));
+	bzero(vnd->sc_dkdev.dk_cpulabel, sizeof(struct cpu_disklabel));
+
+	lp->d_secsize = vnd->sc_blksize;
+	lp->d_ntracks = 64;
+	lp->d_nsectors = 32;
+	lp->d_ncylinders = vnd->sc_size / (64 * 32);
+	lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+	if (lp->d_secpercyl == 0) {
+		lp->d_secpercyl = 100;
+		/* as long as it's not 0 - readdisklabel divides by it (?) */
+	}
+
+	strncpy(lp->d_typename, "vnode disk", 16);
+	lp->d_type = DTYPE_VND;
+	strncpy(lp->d_packname, "fictitious", 16);
+	lp->d_secperunit = vnd->sc_size;
+	lp->d_rpm = 3600;
+	lp->d_interleave = 1;
+	lp->d_flags = 0;
+
+	lp->d_partitions[RAW_PART].p_offset = 0;
+	lp->d_partitions[RAW_PART].p_size =
+	    lp->d_secperunit;
+	lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
+	lp->d_npartitions = RAW_PART + 1;
+
+	lp->d_magic = DISKMAGIC;
+	lp->d_magic2 = DISKMAGIC;
+	lp->d_checksum = dkcksum(lp);
+
+	/*
+	 * Call the generic disklabel extraction routine
+	 */
+	errstring = readdisklabel(dev,
+				  vndstrategy, lp, vnd->sc_dkdev.dk_cpulabel);
+	if (errstring) {
+		printf("%s: %s\n", vnd->sc_xname, errstring);
+		return;
+	}
+}
+
+/*
  * Duplicate the current processes' credentials.  Since we are called only
  * as the result of a SET ioctl and only root can do that, any future access
  * to this "disk" is essentially as root.  Note that credentials may change
  * if some other uid can write directly to the mapped file (NFS).
  */
 int
-vndsetcred(vnd, cred)
+vndsetcred(vnd, cred, p)
 	register struct vnd_softc *vnd;
 	struct ucred *cred;
+	struct proc *p;
 {
 	struct uio auio;
 	struct iovec aiov;
@@ -709,6 +921,7 @@
 	auio.uio_rw = UIO_READ;
 	auio.uio_segflg = UIO_SYSSPACE;
 	auio.uio_resid = aiov.iov_len;
+	auio.uio_procp = p;
 	VOP_LOCK(vnd->sc_vp);
 	error = VOP_READ(vnd->sc_vp, &auio, 0, vnd->sc_cred);
 	VOP_UNLOCK(vnd->sc_vp);
Index: sys/msdosfs/msdosfs_denode.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_denode.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- msdosfs_denode.c	1997/04/01 07:16:17	1.1.1.2
+++ msdosfs_denode.c	1997/05/29 17:50:58	1.2
@@ -380,12 +380,12 @@
 	if ((boff = length & pmp->pm_crbomask) != 0) {
 		if (isadir) {
 			bn = cntobn(pmp, eofentry);
-			error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
-			    NOCRED, &bp);
+			error = bread(pmp->pm_devvp, fsbtosb(pmp, bn),
+			    pmp->pm_bpcluster, NOCRED, &bp);
 		} else {
 			bn = de_blk(pmp, length);
-			error = bread(DETOV(dep), bn, pmp->pm_bpcluster,
-			    NOCRED, &bp);
+			error = bread(DETOV(dep), fsbtosb(pmp, bn),
+			    pmp->pm_bpcluster, NOCRED, &bp);
 		}
 		if (error) {
 			brelse(bp);
Index: sys/msdosfs/msdosfs_fat.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_fat.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- msdosfs_fat.c	1997/05/23 22:00:06	1.1.1.3
+++ msdosfs_fat.c	1997/05/29 17:51:00	1.2
@@ -223,7 +223,8 @@
 		if (bn != bp_bn) {
 			if (bp)
 				brelse(bp);
-			error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
+			error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize,
+			    NOCRED, &bp);
 			if (error) {
 				brelse(bp);
 				return (error);
@@ -349,7 +350,8 @@
 	for (i = 1; i < pmp->pm_FATs; i++) {
 		fatbn += pmp->pm_FATsecs;
 		/* getblk() never fails */
-		bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0);
+		bpn = getblk(pmp->pm_devvp, fsbtosb(pmp, fatbn), bp->b_bcount,
+		    0, 0);
 		bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
 		if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
 			bwrite(bpn);
@@ -491,7 +493,7 @@

 	byteoffset = FATOFS(pmp, cn);
 	fatblock(pmp, byteoffset, &bn, &bsize, &bo);
-	if ((error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp)) != 0) {
+	if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED, &bp)) != 0) {
 		brelse(bp);
 		return (error);
 	}
@@ -562,7 +564,7 @@
 	while (count > 0) {
 		byteoffset = FATOFS(pmp, start);
 		fatblock(pmp, byteoffset, &bn, &bsize, &bo);
-		error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
+		error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED, &bp);
 		if (error) {
 			brelse(bp);
 			return (error);
@@ -792,7 +794,7 @@
 		if (lbn != bn) {
 			if (bp)
 				updatefats(pmp, bp, lbn);
-			error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
+			error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED, &bp);
 			if (error) {
 				brelse(bp);
 				return (error);
@@ -860,7 +862,7 @@
 			if (bp)
 				brelse(bp);
 			fatblock(pmp, byteoffset, &bn, &bsize, NULL);
-			error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
+			error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED, &bp);
 			if (error) {
 				brelse(bp);
 				return (error);
@@ -986,20 +988,22 @@
 				 * Get the buf header for the new block of the file.
 				 */
 				if (dep->de_Attributes & ATTR_DIRECTORY)
-					bp = getblk(pmp->pm_devvp, cntobn(pmp, cn++),
+					bp = getblk(pmp->pm_devvp, fsbtosb(pmp, cntobn(pmp, cn++)),
 						    pmp->pm_bpcluster, 0, 0);
 				else {
-					bp = getblk(DETOV(dep), de_cn2bn(pmp, frcn++),
+					bp = getblk(DETOV(dep), fsbtosb(pmp, de_cn2bn(pmp, frcn++)),
 					    pmp->pm_bpcluster, 0, 0);
 					/*
 					 * Do the bmap now, as in msdosfs_write
 					 */
 					if (pcbmap(dep,
-					    de_bn2cn(pmp, bp->b_lblkno),
+					    de_bn2cn(pmp, sbtofsb(pmp, bp->b_lblkno)),
 					    &bp->b_blkno, 0, 0))
 						bp->b_blkno = -1;
 					if (bp->b_blkno == -1)
 						panic("extendfile: pcbmap");
+					else
+						bp->b_blkno = fsbtosb(pmp, bp->b_blkno);
 				}
 				clrbuf(bp);
 				if (bpp) {
Index: sys/msdosfs/msdosfs_lookup.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_lookup.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- msdosfs_lookup.c	1997/05/12 21:48:22	1.1.1.3
+++ msdosfs_lookup.c	1997/05/29 17:51:01	1.2
@@ -261,7 +261,7 @@
 				break;
 			return (error);
 		}
-		error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+		error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
 		if (error) {
 			brelse(bp);
 			return (error);
@@ -629,7 +629,7 @@
 	diroffset = ddep->de_fndoffset;
 	if (dirclust != MSDOSFSROOT)
 		diroffset &= pmp->pm_crbomask;
-	if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) != 0) {
+	if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp)) != 0) {
 		brelse(bp);
 		return error;
 	}
@@ -659,8 +659,8 @@
 				if (error)
 					return error;

-				error = bread(pmp->pm_devvp, bn, blsize,
-					      NOCRED, &bp);
+				error = bread(pmp->pm_devvp, fsbtosb(pmp, bn),
+					      blsize, NOCRED, &bp);
 				if (error) {
 					brelse(bp);
 					return error;
@@ -722,7 +722,7 @@
 				return (1);	/* it's empty */
 			return (0);
 		}
-		error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+		error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
 		if (error) {
 			brelse(bp);
 			return (0);
@@ -807,7 +807,7 @@
 		}
 		pmp = dep->de_pmp;
 		scn = dep->de_StartCluster;
-		error = bread(pmp->pm_devvp, cntobn(pmp, scn),
+		error = bread(pmp->pm_devvp, fsbtosb(pmp, cntobn(pmp, scn)),
 			      pmp->pm_bpcluster, NOCRED, &bp);
 		if (error)
 			break;
@@ -865,7 +865,7 @@
 	    && de_blk(pmp, diroffset + blsize) > pmp->pm_rootdirsize)
 		blsize = de_bn2off(pmp, pmp->pm_rootdirsize) & pmp->pm_crbomask;
 	bn = detobn(pmp, dirclust, diroffset);
-	if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, bpp)) != 0) {
+	if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, bpp)) != 0) {
 		brelse(*bpp);
 		*bpp = NULL;
 		return (error);
@@ -922,7 +922,7 @@
 		error = pcbmap(pdep, de_cluster(pmp, offset), &bn, 0, &blsize);
 		if (error)
 			return error;
-		error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+		error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
 		if (error) {
 			brelse(bp);
 			return error;
@@ -985,7 +985,7 @@
 					return 0;
 				return error;
 			}
-			error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+			error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
 			if (error) {
 				brelse(bp);
 				return error;
@@ -1036,7 +1036,7 @@
 	for (cn = 0;; cn++) {
 		if (pcbmap(dep, cn, &bn, 0, &blsize))
 			return 0;
-		if (bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) {
+		if (bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp)) {
 			brelse(bp);
 			return 0;
 		}
Index: sys/msdosfs/msdosfs_vfsops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_vfsops.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 msdosfs_vfsops.c
--- msdosfs_vfsops.c	1997/05/12 21:48:23	1.1.1.3
+++ msdosfs_vfsops.c	1997/06/25 07:44:14
@@ -317,7 +317,7 @@
 	 * Read the boot sector of the filesystem, and then check the
 	 * boot signature.  If not a dos boot sector then error out.
 	 */
-	if ((error = bread(devvp, 0, 512, NOCRED, &bp)) != 0)
+	if ((error = bread(devvp, 0, BLKDEV_IOSIZE, NOCRED, &bp)) != 0)
 		goto error_exit;
 	bp->b_flags |= B_AGE;
 	bsp = (union bootsector *)bp->b_data;
@@ -412,6 +412,15 @@
 	    SecPerClust;
 	pmp->pm_maxcluster = pmp->pm_nmbrofclusters + 1;
 	pmp->pm_fatsize = pmp->pm_FATsecs * pmp->pm_BytesPerSec;
+#if 0
+	if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
+		tmp = DEV_BSIZE;
+	else
+		tmp = dpart.disklab->d_secsize;
+#else
+	tmp = DEV_BSIZE;
+#endif
+	pmp->pm_fsbtosb = ffs(pmp->pm_BytesPerSec) - ffs(tmp);

 	if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
 		if ((pmp->pm_nmbrofclusters <= (0xff0 - 2))
Index: sys/msdosfs/msdosfs_vnops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_vnops.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- msdosfs_vnops.c	1997/05/12 21:48:24	1.1.1.3
+++ msdosfs_vnops.c	1997/05/29 17:51:03	1.2
@@ -466,16 +466,16 @@
 		 * vnode for the directory.
 		 */
 		if (isadir) {
-			error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
+			error = bread(pmp->pm_devvp, fsbtosb(pmp, lbn), blsize, NOCRED, &bp);
 		} else {
 			rablock = lbn + 1;
 			if (vp->v_lastr + 1 == lbn &&
 			    de_cn2off(pmp, rablock) < dep->de_FileSize)
-				error = breada(vp, de_cn2bn(pmp, lbn),
+				error = breada(vp, fsbtosb(pmp, de_cn2bn(pmp, lbn)),
 				    pmp->pm_bpcluster, de_cn2bn(pmp, rablock),
 				    pmp->pm_bpcluster, NOCRED, &bp);
 			else
-				error = bread(vp, de_cn2bn(pmp, lbn),
+				error = bread(vp, fsbtosb(pmp, de_cn2bn(pmp, lbn)),
 				    pmp->pm_bpcluster, NOCRED, &bp);
 			vp->v_lastr = lbn;
 		}
@@ -603,7 +603,7 @@
 			 * or we write the cluster from its start beyond EOF,
 			 * then no need to read data from disk.
 			 */
-			bp = getblk(thisvp, bn, pmp->pm_bpcluster, 0, 0);
+			bp = getblk(thisvp, fsbtosb(pmp, bn), pmp->pm_bpcluster, 0, 0);
 			clrbuf(bp);
 			/*
 			 * Do the bmap now, since pcbmap needs buffers
@@ -611,10 +611,12 @@
 			 */
 			if (bp->b_blkno == bp->b_lblkno) {
 				error = pcbmap(dep,
-					       de_bn2cn(pmp, bp->b_lblkno),
+					       de_bn2cn(pmp, sbtofsb(pmp, bp->b_lblkno)),
 					       &bp->b_blkno, 0, 0);
 				if (error)
 					bp->b_blkno = -1;
+				else
+					bp->b_blkno = fsbtosb(pmp, bp->b_blkno);
 			}
 			if (bp->b_blkno == -1) {
 				brelse(bp);
@@ -626,7 +628,7 @@
 			/*
 			 * The block we need to write into exists, so read it in.
 			 */
-			error = bread(thisvp, bn, pmp->pm_bpcluster,
+			error = bread(thisvp, fsbtosb(pmp, bn), pmp->pm_bpcluster,
 				      NOCRED, &bp);
 			if (error) {
 				brelse(bp);
@@ -638,6 +640,7 @@
 		n = min(uio->uio_resid, pmp->pm_bpcluster - croffset);
 		if (uio->uio_offset + n > dep->de_FileSize) {
 			dep->de_FileSize = uio->uio_offset + n;
+
 			vnode_pager_setsize(vp, dep->de_FileSize);	/* why? */
 		}
 		(void) vnode_pager_uncache(vp);	/* why not? */
@@ -1135,7 +1138,7 @@
 			panic("msdosfs_rename: updating .. in root directory?\n");
 		} else
 			bn = cntobn(pmp, cn);
-		error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
+		error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), pmp->pm_bpcluster,
 			      NOCRED, &bp);
 		if (error) {
 			/* XXX should really panic here, fs is corrupt */
@@ -1242,7 +1245,7 @@
 	 */
 	bn = cntobn(pmp, newcluster);
 	/* always succeeds */
-	bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0);
+	bp = getblk(pmp->pm_devvp, fsbtosb(pmp, bn), pmp->pm_bpcluster, 0, 0);
 	bzero(bp->b_data, pmp->pm_bpcluster);
 	bcopy(&dosdirtemplate, bp->b_data, sizeof dosdirtemplate);
 	denp = (struct direntry *)bp->b_data;
@@ -1507,7 +1510,7 @@
 		n = min(n, diff);
 		if ((error = pcbmap(dep, lbn, &bn, &cn, &blsize)) != 0)
 			break;
-		error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+		error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
 		if (error) {
 			brelse(bp);
 			return (error);
@@ -1801,10 +1804,12 @@
 	 * don't allow files with holes, so we shouldn't ever see this.
 	 */
 	if (bp->b_blkno == bp->b_lblkno) {
-		error = pcbmap(dep, de_bn2cn(dep->de_pmp, bp->b_lblkno),
+		error = pcbmap(dep, de_bn2cn(dep->de_pmp, sbtofsb(dep->de_pmp, bp->b_lblkno)),
 			       &bp->b_blkno, 0, 0);
 		if (error)
 			bp->b_blkno = -1;
+		else
+			bp->b_blkno = fsbtosb(dep->de_pmp, bp->b_blkno);
 		if (bp->b_blkno == -1)
 			clrbuf(bp);
 	}
Index: sys/msdosfs/msdosfsmount.h
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfsmount.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- msdosfsmount.h	1997/04/01 07:16:23	1.1.1.2
+++ msdosfsmount.h	1997/05/29 17:51:04	1.2
@@ -58,6 +58,7 @@
 	mode_t pm_mask;		/* mask to and with file protection bits */
 	struct vnode *pm_devvp;	/* vnode for block device mntd */
 	struct bpb50 pm_bpb;	/* BIOS parameter blk for this fs */
+	int pm_fsbtosb;		/* fsbtosb and sbtofsb shift constant */
 	u_long pm_fatblk;	/* block # of first FAT */
 	u_long pm_rootdirblk;	/* block # of root directory */
 	u_long pm_rootdirsize;	/* size in blocks (not clusters) */
@@ -78,6 +79,15 @@
 	struct netexport pm_export;	/* export information */
 	u_int  pm_fatentrysize;	/* size of fat entry (12/16) */
 };
+
+/*
+ * Turn file system block numbers into system block addresses.
+ * This maps file system blocks to system size blocks.
+ */
+#define fsbtosb(pmp, bn) \
+	((bn) << (pmp)->pm_fsbtosb)
+#define sbtofsb(pmp, bn) \
+	((bn) >> (pmp)->pm_fsbtosb)

 /*
  * Mount point flags:
Index: sys/scsi/cd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/cd.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 cd.c
--- cd.c	1997/04/11 07:23:35	1.1.1.3
+++ cd.c	1997/06/25 06:45:15
@@ -549,13 +549,18 @@
 		 * First, translate the block to absolute and put it in terms
 		 * of the logical blocksize of the device.
 		 */
+#if 0
+		blkno = bp->b_blkno;
+#else
 		blkno =
 		    bp->b_blkno / (cd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+#endif
 		if (CDPART(bp->b_dev) != RAW_PART) {
 		      p = &cd->sc_dk.dk_label->d_partitions[CDPART(bp->b_dev)];
 		      blkno += p->p_offset;
 		}
-		nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label->d_secsize);
+		blkno *= cd->sc_dk.dk_label->d_secsize / cd->params.blksize;
+		nblks = howmany(bp->b_bcount, cd->params.blksize);

 		/*
 		 *  Fill out the scsi command.  If the transfer will
@@ -647,8 +652,14 @@
 	struct uio *uio;
 	int ioflag;
 {
-
+	struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
+#if 1
 	return (physio(cdstrategy, NULL, dev, B_READ, cdminphys, uio));
+#else
+	int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;
+
+	return (physio2(cdstrategy, NULL, dev, B_READ, cdminphys, uio, bshift));
+#endif
 }

 int
@@ -657,8 +668,14 @@
 	struct uio *uio;
 	int ioflag;
 {
-
+	struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
+#if 1
 	return (physio(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio));
+#else
+	int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;
+
+	return (physio2(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio, bshift));
+#endif
 }

 /*
@@ -942,6 +959,7 @@
 	struct cd_softc *cd;
 {
 	struct disklabel *lp = cd->sc_dk.dk_label;
+	char *errstring;

 	bzero(lp, sizeof(struct disklabel));
 	bzero(cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
@@ -962,17 +980,46 @@

 	lp->d_partitions[0].p_offset = 0;
 	lp->d_partitions[0].p_size =
-	    lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+	    lp->d_secperunit;
 	lp->d_partitions[0].p_fstype = FS_ISO9660;
 	lp->d_partitions[RAW_PART].p_offset = 0;
 	lp->d_partitions[RAW_PART].p_size =
-	    lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+	    lp->d_secperunit;
 	lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
 	lp->d_npartitions = RAW_PART + 1;

 	lp->d_magic = DISKMAGIC;
 	lp->d_magic2 = DISKMAGIC;
 	lp->d_checksum = dkcksum(lp);
+
+	/*
+	 * Call the generic disklabel extraction routine
+	 */
+	errstring = readdisklabel(MAKECDDEV(0, cd->sc_dev.dv_unit, RAW_PART),
+				  cdstrategy, lp, cd->sc_dk.dk_cpulabel);
+
+#if 0
+	if (errstring) {
+		printf("%s: %s\n", cd->sc_dev.dv_xname, errstring);
+		return;
+	}
+#else
+	if (errstring && strcmp(errstring, "no disk label") == 0) {
+		lp->d_partitions[0].p_offset = 0;
+		lp->d_partitions[0].p_size =
+			lp->d_secperunit;
+		lp->d_partitions[0].p_fstype = FS_ISO9660;
+		lp->d_partitions[RAW_PART].p_offset = 0;
+		lp->d_partitions[RAW_PART].p_size =
+			lp->d_secperunit;
+		lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
+		lp->d_npartitions = RAW_PART + 1;
+
+		lp->d_magic = DISKMAGIC;
+		lp->d_magic2 = DISKMAGIC;
+		lp->d_checksum = dkcksum(lp);
+	}
+#endif
 }

 /*
Index: sys/scsi/sd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/sd.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 sd.c
--- sd.c	1997/06/23 16:30:19	1.1.1.4
+++ sd.c	1997/06/25 06:47:42
@@ -577,13 +577,18 @@
 		 * First, translate the block to absolute and put it in terms
 		 * of the logical blocksize of the device.
 		 */
+#if 1
 		blkno =
 		    bp->b_blkno / (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+#else
+		blkno = bp->b_blkno;
+#endif
 		if (SDPART(bp->b_dev) != RAW_PART) {
 		     p = &sd->sc_dk.dk_label->d_partitions[SDPART(bp->b_dev)];
 		     blkno += p->p_offset;
 		}
-		nblks = howmany(bp->b_bcount, sd->sc_dk.dk_label->d_secsize);
+		blkno *= sd->sc_dk.dk_label->d_secsize / sd->params.blksize;
+		nblks = howmany(bp->b_bcount, sd->params.blksize);

 		/*
 		 *  Fill out the scsi command.  If the transfer will
@@ -675,8 +680,14 @@
 	struct uio *uio;
 	int ioflag;
 {
-
+	struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+#if 1
 	return (physio(sdstrategy, NULL, dev, B_READ, sdminphys, uio));
+#else
+	int bshift = ffs(sd->sc_dk.dk_label->d_secsize)-1;
+
+	return (physio2(sdstrategy, NULL, dev, B_READ, sdminphys, uio, bshift));
+#endif
 }

 int
@@ -685,8 +696,14 @@
 	struct uio *uio;
 	int ioflag;
 {
-
+	struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+#if 1
 	return (physio(sdstrategy, NULL, dev, B_WRITE, sdminphys, uio));
+#else
+	int bshift = ffs(sd->sc_dk.dk_label->d_secsize)-1;
+
+	return (physio2(sdstrategy, NULL, dev, B_WRITE, sdminphys, uio, bshift));
+#endif
 }

 /*
@@ -810,7 +827,7 @@

 	lp->d_partitions[RAW_PART].p_offset = 0;
 	lp->d_partitions[RAW_PART].p_size =
-	    lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+	    lp->d_secperunit;
 	lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
 	lp->d_npartitions = RAW_PART + 1;

Index: sys/ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 ffs_vfsops.c
--- ffs_vfsops.c	1997/06/23 16:31:06	1.1.1.3
+++ ffs_vfsops.c	1997/06/25 06:50:49
@@ -307,7 +307,9 @@
 	struct csum *space;
 	struct buf *bp;
 	struct fs *fs, *newfs;
+#if 0
 	struct partinfo dpart;
+#endif
 	int i, blks, size, error;
 	int32_t *lp;

@@ -322,10 +324,15 @@
 	/*
 	 * Step 2: re-read superblock from disk.
 	 */
+#if 0
 	if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
 		size = DEV_BSIZE;
 	else
 		size = dpart.disklab->d_secsize;
+#else
+	size = DEV_BSIZE;
+#endif
+
 	error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, NOCRED, &bp);
 	if (error)
 		return (error);
@@ -343,6 +350,7 @@
 	 */
 	bcopy(&fs->fs_csp[0], &newfs->fs_csp[0], sizeof(fs->fs_csp));
 	newfs->fs_maxcluster = fs->fs_maxcluster;
+	newfs->fs_fsbtosb = fs->fs_fsbtosb;
 	bcopy(newfs, fs, (u_int)fs->fs_sbsize);
 	if (fs->fs_sbsize < SBSIZE)
 		bp->b_flags |= B_INVAL;
@@ -424,10 +432,12 @@
 	struct buf *bp;
 	register struct fs *fs;
 	dev_t dev;
+#if 0
 	struct partinfo dpart;
+#endif
 	caddr_t base, space;
 	int blks;
-	int error, i, size, ronly;
+	int error, i, size, ssize, ronly;
 	int32_t *lp;
 	struct ucred *cred;
 	extern struct vnode *rootvp;
@@ -452,10 +462,14 @@
 	error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
 	if (error)
 		return (error);
+#if 0
 	if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0)
 		size = DEV_BSIZE;
 	else
 		size = dpart.disklab->d_secsize;
+#else
+	size = DEV_BSIZE;
+#endif

 	bp = NULL;
 	ump = NULL;
@@ -473,6 +487,21 @@
 		error = EROFS;		/* XXX what should be returned? */
 		goto out;
 	}
+	/* XXX bread assumes b_blkno in DEV_BSIZE unit. Calculate fsbtosb */
+
+	ssize = fs->fs_fsize / fs->fs_nspf;
+	fs->fs_fsbtosb = fs->fs_fsbtodb;
+	if (ssize >= size) {
+		ssize = ssize / size;
+		for (i = 0; ssize > 1; ssize >>= 1)
+			i ++;
+		fs->fs_fsbtosb += i;
+	} else {
+		ssize = size / ssize;
+		for (i = 0; ssize > 1; ssize >>= 1)
+			i ++;
+		fs->fs_fsbtosb -= i;
+	}
 	ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
 	bzero((caddr_t)ump, sizeof *ump);
 	ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT,
@@ -523,7 +552,7 @@
 	ump->um_dev = dev;
 	ump->um_devvp = devvp;
 	ump->um_nindir = fs->fs_nindir;
-	ump->um_bptrtodb = fs->fs_fsbtodb;
+	ump->um_bptrtodb = fs->fs_fsbtosb;
 	ump->um_seqinc = fs->fs_frag;
 	for (i = 0; i < MAXQUOTAS; i++)
 		ump->um_quotas[i] = NULLVP;
@@ -921,11 +950,12 @@
 	register struct buf *bp;
 	int i, error = 0;

-	bp = getblk(mp->um_devvp, SBOFF >> (fs->fs_fshift - fs->fs_fsbtodb),
+	bp = getblk(mp->um_devvp, SBOFF >> (fs->fs_fshift - fs->fs_fsbtosb),
 	    (int)fs->fs_sbsize, 0, 0);
 	bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
 	/* Restore compatibility to old file systems.		   XXX */
 	dfs = (struct fs *)bp->b_data;				/* XXX */
+	dfs->fs_fsbtosb = 0;					/* XXX */
 	if (fs->fs_postblformat == FS_42POSTBLFMT)		/* XXX */
 		dfs->fs_nrpos = -1;				/* XXX */
 	if (fs->fs_inodefmt < FS_44INODEFMT) {			/* XXX */
Index: sys/ufs/ffs/fs.h
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/ufs/ffs/fs.h,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- fs.h	1997/06/23 16:31:07	1.1.1.2
+++ fs.h	1997/06/24 03:12:03	1.3
@@ -228,7 +228,8 @@
 	int32_t	 *fs_maxcluster;	/* max cluster in each cyl group */
 	int32_t	 fs_cpc;		/* cyl per cycle in postbl */
 	int16_t	 fs_opostbl[16][8];	/* old rotation block list head */
-	int32_t	 fs_sparecon[49];	/* reserved for future constants */
+	int32_t  fs_fsbtosb;		/* fsbtodb and dbtofsb shift constant */
+	int32_t	 fs_sparecon[48];	/* reserved for future constants */
 	time_t	 fs_fscktime;		/* last time fsck(8)ed */
 	int32_t	 fs_contigsumsize;	/* size of cluster summary array */ 
 	int32_t	 fs_maxsymlinklen;	/* max length of an internal symlink */
@@ -394,8 +395,8 @@
  * Turn file system block numbers into disk block addresses.
  * This maps file system blocks to device size blocks.
  */
-#define fsbtodb(fs, b)	((b) << (fs)->fs_fsbtodb)
-#define	dbtofsb(fs, b)	((b) >> (fs)->fs_fsbtodb)
+#define fsbtodb(fs, b)	((b) << (fs)->fs_fsbtosb)
+#define	dbtofsb(fs, b)	((b) >> (fs)->fs_fsbtosb)

 /*
  * Cylinder group macros to locate things in cylinder groups.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->wrstuden 
Responsible-Changed-By: thorpej 
Responsible-Changed-When: Tue Jan 25 23:46:35 PST 2000 
Responsible-Changed-Why:  
wrstuden is handling large-block disks 
Responsible-Changed-From-To: wrstuden->kern-bug-people
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Mon, 28 Feb 2011 14:55:46 +0000
Responsible-Changed-Why:
Reset responsible field for retired developer.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.