Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Feb 96 17:29:35 JST
From:      akiyama@kme.mei.co.jp (Shunsuke Akiyama)
To:        hackers@freebsd.org
Subject:   Optical disk driver update and enhancement patch.
Message-ID:  <9602140829.AA05282@kmegate.kme.mei.co.jp>

next in thread | raw e-mail | index | archive | help
Hi FreeBSD hackers,

I made optical disk driver update(1) and enhancement(2) patch for
2.2-960130-SNAP.  It's not for -current, sorry.

Here are brief descriptions.

(1) update patch

  * some fixes.
  * add CD device compatible lock/unlock and eject ioctl.
  * improved ficticious geometry translation.
  * add bogus sense code handling.

(2) enhancement patch

  * UFS works on 1024 byte/sector optical disk media.

  Known problem:
    UFS build on 1024 byte/sector media can not mount as root
    filesystem.

-- 
Shunsuke Akiyama
Kyushu Matsushita Electric Co., Ltd. Fukuoka, Japan.
akiyama@kme.mei.co.jp

----- (1) update patch -----
===================================================================
RCS file: etc/etc.i386/RCS/MAKEDEV,v
retrieving revision 1.111
diff -u -r1.111 etc/etc.i386/MAKEDEV
--- 1.111	1996/01/28 19:10:37
+++ etc/etc.i386/MAKEDEV	1996/02/12 12:59:24
@@ -93,7 +93,7 @@
 #	isdn*	ISDN devices
 #	labpc*	National Instrument's Lab-PC and LAB-PC+
 #
-#	$Id: MAKEDEV,v 1.111 1996/01/28 19:10:37 bde Exp $
+#	$Id: MAKEDEV,v 1.111.0.1 1996/02/11 12:54:52 shun Exp $
 #
 
 PATH=/sbin:/bin/:/usr/bin:/usr/sbin:
@@ -164,7 +164,7 @@
 
 all)
 	sh MAKEDEV std						# standard
-	sh MAKEDEV wd0 wd1 wd2 wd3 fd0 fd1 sd0 sd1 sd2 sd3	# bdev, disk
+	sh MAKEDEV wd0 wd1 wd2 wd3 fd0 fd1 sd0 sd1 sd2 sd3 od0	# bdev, disk
 	sh MAKEDEV cd0 mcd0 scd0 matcd0				# bdev, cdrom
 	sh MAKEDEV ft0 wt0 st0					# bdev, tape
 	sh MAKEDEV ttyd0 ttyd1 ttyd2 ttyd3			# cdev, serial
===================================================================
RCS file: sys/scsi/RCS/cd.c,v
retrieving revision 1.60
diff -u -r1.60 sys/scsi/cd.c
--- 1.60	1996/01/30 16:38:30
+++ sys/scsi/cd.c	1996/02/12 12:59:25
@@ -14,7 +14,7 @@
  *
  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
  *
- *      $Id: cd.c,v 1.60 1996/01/30 16:38:30 ache Exp $
+ *      $Id: cd.c,v 1.60.0.1 1996/02/12 12:57:14 shun Exp $
  */
 
 #include "opt_bounce.h"
@@ -237,7 +237,7 @@
 	if (sc_link->quirks & CD_Q_NO_TOUCH) {
 		dp->disksize = 0;
 	} else {
-		cd_get_parms(unit, SCSI_NOSLEEP | SCSI_NOMASK);
+		cd_get_parms(unit, SCSI_NOSLEEP | SCSI_NOMASK | SCSI_SILENT);
 	}
 	if (dp->disksize) {
 		printf("cd present [%ld x %ld byte records]",
===================================================================
RCS file: sys/scsi/RCS/od.c,v
retrieving revision 1.12
diff -u -r1.12 sys/scsi/od.c
--- 1.12	1996/01/27 04:18:00
+++ sys/scsi/od.c	1996/02/12 12:59:25
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995 Shunsuke Akiyama.  All rights reserved.
+ * Copyright (c) 1995, 1996 Shunsuke Akiyama.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,12 +28,17 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- *	$Id: od.c,v 1.12 1996/01/27 04:18:00 bde Exp $
+ *	$Id: od.c,v 1.12.0.4 1996/02/11 13:38:06 shun Exp $
  */
 
 /*
- * TODO:
- *   1. Add optical disk specific ioctl functions, such as eject etc.
+ * Compile option defines:
+ *  OD_BOGUS_NOT_READY - If drive returns sense key as 0x02 with
+ *  			 vendor specific additional sense code (ASC)
+ *			 and additional sense code qualifier (ASCQ),
+ *			 or illegal ASC and ASCQ. This cause an error
+ *			 (NOT READY) and retrying.
+ *			 To suppress this, define "OD_BOGUS_NOT_READY".
  */
 
 #include "opt_bounce.h"
@@ -53,6 +58,7 @@
 #include <sys/malloc.h>
 #include <sys/errno.h>
 #include <sys/dkstat.h>
+#include <sys/cdio.h>
 #include <sys/disklabel.h>
 #include <sys/diskslice.h>
 #ifdef DEVFS
@@ -68,7 +74,7 @@
 
 static u_int32 odstrats, odqueues;
 
-#define SECSIZE 512
+#define SECSIZE		512
 #define	ODOUTSTANDING	4
 #define	OD_RETRIES	4
 #define	MAXTRANSFER	8		/* 1 page at a time */
@@ -142,18 +148,18 @@
 
 static struct scsi_device od_switch =
 {
-    od_sense_handler,
-    odstart,			/* have a queue, served by this */
-    NULL,			/* have no async handler */
-    NULL,			/* Use default 'done' routine */
-    "od",
-    0,
+	od_sense_handler,
+	odstart,		/* have a queue, served by this */
+	NULL,			/* have no async handler */
+	NULL,			/* Use default 'done' routine */
+	"od",
+	0,
 	{0, 0},
-	0,				/* Link flags */
+	0,			/* Link flags */
 	odattach,
 	"Optical",
 	odopen,
-    sizeof(struct scsi_data),
+	sizeof(struct scsi_data),
 	T_OPTICAL,
 	odunit,
 	odsetunit,
@@ -191,7 +197,7 @@
 	dev_attach(kdc);
 	if(dk_ndrive < DK_NDRIVE) {
 		sprintf(dk_names[dk_ndrive], "od%d", unit);
-		dk_wpms[dk_ndrive] = (8*1024*1024/2);
+		dk_wpms[dk_ndrive] = (1*1024*1024/2);	/* 1MB/sec */
 		SCSI_DATA(&od_switch, unit)->dkunit = dk_ndrive++;
 	} else {
 		SCSI_DATA(&od_switch, unit)->dkunit = -1;
@@ -293,7 +299,7 @@
 	 * to look for a new device if we are not initted
 	 */
 	if ((!od) || (!(od->flags & ODINIT))) {
-		return (ENXIO);
+		return ENXIO;
 	}
 
 	SC_DEBUG(sc_link, SDEV_DB1,
@@ -351,7 +357,7 @@
 	if (errcode) {
 		goto bad;
 	}
-	if (od->params.secsiz != SECSIZE) {	/* XXX One day... */
+	if (od->params.secsiz != SECSIZE) {
 		printf("od%ld: Can't deal with %d bytes logical blocks\n",
 		    unit, od->params.secsiz);
 		Debugger("od");
@@ -368,8 +374,10 @@
 	label.d_ncylinders = od->params.cyls;
 	label.d_secpercyl = od->params.heads * od->params.sectors;
 	if (label.d_secpercyl == 0)
-		label.d_secpercyl = 100;
-		/* XXX as long as it's not 0 - readdisklabel divides by it (?) */
+		label.d_secpercyl = (64 * 32);
+		/* XXX as long as it's not 0
+		 * - readdisklabel divides by it (?)
+		 */
 	label.d_secperunit = od->params.disksize;
 
 	/* Initialize slice tables. */
@@ -411,7 +419,7 @@
 		scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT | SCSI_ERR_OK);
 		sc_link->flags &= ~SDEV_OPEN;
 	}
-	return (0);
+	return 0;
 }
 
 /*
@@ -439,6 +447,11 @@
 	}
 
 	/*
+	 * check it's not too big a transfer for our adapter
+	 */
+        scsi_minphys(bp, &od_switch);
+
+	/*
 	 * Odd number of bytes
 	 */
 	if (bp->b_bcount % DEV_BSIZE != 0) {
@@ -566,7 +579,6 @@
 		/*
 		 *  Fill out the scsi command
 		 */
-		bzero(&cmd, sizeof(cmd));
 		cmd.op_code = (bp->b_flags & B_READ)
 		    ? READ_BIG : WRITE_BIG;
 		cmd.addr_3 = (blkno & 0xff000000UL) >> 24;
@@ -575,6 +587,7 @@
 		cmd.addr_0 = blkno & 0xff;
 		cmd.length2 = (nblk & 0xff00) >> 8;
 		cmd.length1 = (nblk & 0xff);
+		cmd.byte2 = cmd.reserved = cmd.control = 0;
 		/*
 		 * Call the routine that chats with the adapter.
 		 * Note: we cannot sleep as we may be an interrupt
@@ -624,27 +637,40 @@
 	od = sc_link->sd;
 	SC_DEBUG(sc_link, SDEV_DB1, ("odioctl (0x%x)", cmd));
 
-#if 0
-	/* Wait until we have exclusive access to the device. */
-	/* XXX this is how wd does it.  How did we work without this? */
-	wdsleep(du->dk_ctrlr, "wdioct");
-#endif
-
 	/*
 	 * If the device is not valid.. abandon ship
 	 */
 	if (!(sc_link->flags & SDEV_MEDIA_LOADED))
-		return (EIO);
+		return EIO;
+
+	switch (cmd) {
+	case DIOCSBAD:
+		error = EINVAL;		/* XXX */
+		break;
+	case CDIOCEJECT:
+		error = scsi_stop_unit(sc_link, 1, 0);
+		break;
+	case CDIOCALLOW:
+		error = scsi_prevent(sc_link, PR_ALLOW, 0);
+		break;
+	case CDIOCPREVENT:
+		error = scsi_prevent(sc_link, PR_PREVENT, 0);
+		break;
+	default:
+		error = dsioctl("od", dev, cmd, addr, flag, &od->dk_slices,
+				odstrategy1, (ds_setgeom_t *)NULL);
+		if (error == -1) {
+			if (PARTITION(dev) != RAW_PART) {
+				error = ENOTTY;
+			} else {
+				error = scsi_do_ioctl(dev, cmd, addr,
+						      flag, p, sc_link);
+			}
+		}
+		break;
+	}
 
-	if (cmd ==  DIOCSBAD)
-		return (EINVAL);	/* XXX */
-	error = dsioctl("od", dev, cmd, addr, flag, &od->dk_slices,
-			odstrategy1, (ds_setgeom_t *)NULL);
-	if (error != -1)
-		return (error);
-	if (PARTITION(dev) != RAW_PART)
-		return (ENOTTY);
-	return (scsi_do_ioctl(dev, cmd, addr, flag, p, sc_link));
+	return error;
 }
 
 /*
@@ -657,7 +683,9 @@
 	struct scsi_read_cap_data rdcap;
 	struct scsi_read_capacity scsi_cmd;
 	u_int32 size;
+	u_int32 secsize;
 	struct scsi_link *sc_link = SCSI_LINK(&od_switch, unit);
+	struct scsi_data *od = sc_link->sd;
 
 	/*
 	 * make up a scsi command and ask the scsi driver to do
@@ -679,14 +707,21 @@
 		20000,
 		NULL,
 		flags | SCSI_DATA_IN) != 0) {
-		return (0);
+		return 0;
 	} else {
-		size = rdcap.addr_0 + 1;
+		size = rdcap.addr_0;
 		size += rdcap.addr_1 << 8;
 		size += rdcap.addr_2 << 16;
 		size += rdcap.addr_3 << 24;
-	}
-	return (size);
+		size += 1;
+		secsize = rdcap.length_0;
+		secsize += rdcap.length_1 << 8;
+		secsize += rdcap.length_2 << 16;
+		secsize += rdcap.length_3 << 24;
+	}
+	od->params.disksize = size;
+	od->params.secsiz = secsize;
+	return size;
 }
 
 #ifdef notyet
@@ -712,7 +747,7 @@
 	rbdata.defect_descriptor[0].dlbaddr_1 = ((block >> 8) & 0xff);
 	rbdata.defect_descriptor[0].dlbaddr_0 = ((block) & 0xff);
 
-	return (scsi_scsi_cmd(sc_link,
+	return scsi_scsi_cmd(sc_link,
 		(struct scsi_generic *) &scsi_cmd,
 		sizeof(scsi_cmd),
 		(u_char *) & rbdata,
@@ -720,7 +755,7 @@
 		OD_RETRIES,
 		20000,
 		NULL,
-		SCSI_DATA_OUT));
+		SCSI_DATA_OUT);
 }
 #endif
 #define b2tol(a)	(((unsigned)(a##_1) << 8) + (unsigned)a##_0 )
@@ -747,16 +782,28 @@
 		return 0;
 
 	/*
-	 * use adaptec standard ficticious geometry
-	 * this depends on which controller (e.g. 1542C is
-	 * different. but we have to put SOMETHING here..)
+	 * Use ficticious geometry, this depends on the size of medium.
 	 */
 	sectors = od_size(unit, flags);
+	/* od_size() sets secsiz and disksize */
 	disk_parms->heads = 64;
 	disk_parms->sectors = 32;
 	disk_parms->cyls = sectors / (64 * 32);
-	disk_parms->secsiz = SECSIZE;
-	disk_parms->disksize = sectors;
+	while (disk_parms->cyls >= 1024) {
+		if (disk_parms->heads < 128) {
+			disk_parms->heads *= 2;
+		} else {
+			if (disk_parms->sectors < 128) {
+				disk_parms->sectors *= 2;
+			} else {
+				disk_parms->cyls
+				  = sectors / (disk_parms->heads * disk_parms->sectors);
+				break;
+			}
+		}
+		disk_parms->cyls
+		  = sectors / (disk_parms->heads * disk_parms->sectors);
+	}
 
 	if (sectors != 0) {
 		sc_link->flags |= SDEV_MEDIA_LOADED;
@@ -788,6 +835,13 @@
 	if ((sense->error_code & SSD_ERRCODE) == 0x71)
 		return SCSIRET_CONTINUE;
 
+#ifdef OD_BOGUS_NOT_READY
+	if (((sense->error_code & SSD_ERRCODE) == 0x70) &&
+		((sense->ext.extended.flags & SSD_KEY) == 0x02))
+		/* No point in retrying Not Ready */
+			return SCSIRET_CONTINUE;
+#endif
+
 	if (((sense->error_code & SSD_ERRCODE) == 0x70) &&
 		((sense->ext.extended.flags & SSD_KEY) == 0x04))
 		/* No point in retrying Hardware Failure */
@@ -851,5 +905,3 @@
 }
 
 SYSINIT(oddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,od_drvinit,NULL)
-
-
----- (1) update patch -----

----- (2) enhancement patch -----
===================================================================
RCS file: sys/kern/RCS/subr_diskslice.c,v
retrieving revision 1.19
diff -u -r1.19 sys/kern/subr_diskslice.c
--- 1.19	1996/01/28 08:15:44
+++ sys/kern/subr_diskslice.c	1996/02/12 13:01:22
@@ -43,7 +43,7 @@
  *	from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $
  *	from: @(#)ufs_disksubr.c	7.16 (Berkeley) 5/4/91
  *	from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
- *	$Id: subr_diskslice.c,v 1.19 1996/01/28 08:15:44 bde Exp $
+ *	$Id: subr_diskslice.c,v 1.19.0.1 1996/02/11 13:34:04 shun Exp $
  */
 
 #include <sys/param.h>
@@ -111,6 +111,7 @@
 	struct partition *pp;
 	struct diskslice *sp;
 	long	sz;
+	long	scale;
 
 	if (bp->b_blkno < 0) {
 		Debugger("Slice code got negative blocknumber");
@@ -121,15 +122,17 @@
 	lp = sp->ds_label;
 	sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
 	if (lp == NULL) {
+		scale = 1;
 		blkno = bp->b_blkno;
 		labelsect = -LABELSECTOR - 1;
 		maxsz = sp->ds_size;
 	} else {
-		labelsect = lp->d_partitions[LABEL_PART].p_offset;
+		scale = lp->d_secsize / DEV_BSIZE;
+		labelsect = lp->d_partitions[LABEL_PART].p_offset * scale;
 if (labelsect != 0) Debugger("labelsect != 0 in dscheck()");
 		pp = &lp->d_partitions[dkpart(bp->b_dev)];
-		blkno = pp->p_offset + bp->b_blkno;
-		maxsz = pp->p_size;
+		blkno = pp->p_offset * scale + bp->b_blkno;
+		maxsz = pp->p_size * scale;
 		if (sp->ds_bad != NULL && ds_debug) {
 			daddr_t	newblkno;
 
@@ -142,9 +145,9 @@
 
 	/* overwriting disk label ? */
 	/* XXX should also protect bootstrap in first 8K */
-	if (blkno <= LABELSECTOR + labelsect &&
+	if (blkno <= LABELSECTOR * scale + labelsect &&
 #if LABELSECTOR != 0
-	    bp->b_blkno + sz > LABELSECTOR + labelsect &&
+	    bp->b_blkno + sz > LABELSECTOR * scale + labelsect &&
 #endif
 	    (bp->b_flags & B_READ) == 0 && sp->ds_wlabel == 0) {
 		bp->b_error = EROFS;
@@ -177,7 +180,7 @@
 	}
 
 	/* calculate cylinder for disksort to order transfers with */
-	bp->b_pblkno = blkno + sp->ds_offset;
+	bp->b_pblkno = blkno + sp->ds_offset * scale;
 	if (lp == NULL)
 		bp->b_cylinder = 0;	/* XXX always 0 would be better */
 	else
@@ -188,9 +191,9 @@
 	 * offsets in the label to keep the in-core label coherent with
 	 * the on-disk one.
 	 */
-	if (blkno <= LABELSECTOR + labelsect
+	if (blkno <= LABELSECTOR * scale + labelsect
 #if LABELSECTOR != 0
-	    && bp->b_blkno + sz > LABELSECTOR + labelsect
+	    && bp->b_blkno + sz > LABELSECTOR * scale + labelsect
 #endif
 	    && sp->ds_offset != 0) {
 		struct iodone_chain *ic;
@@ -199,8 +202,8 @@
 		ic->ic_prev_flags = bp->b_flags;
 		ic->ic_prev_iodone = bp->b_iodone;
 		ic->ic_prev_iodone_chain = bp->b_iodone_chain;
-		ic->ic_args[0].ia_long = (LABELSECTOR + labelsect - blkno)
-					 << DEV_BSHIFT;
+		ic->ic_args[0].ia_long =
+		  (LABELSECTOR * scale + labelsect - blkno) << DEV_BSHIFT;
 		ic->ic_args[1].ia_ptr = sp;
 		bp->b_flags |= B_CALL;
 		bp->b_iodone = dsiodone;
@@ -764,7 +767,8 @@
 	lp = ssp->dss_slices[slice].ds_label;
 	if (lp == NULL)
 		return (-1);
-	return ((int)lp->d_partitions[part].p_size);
+	return ((int)lp->d_partitions[part].p_size
+		* (lp->d_secsize / DEV_BSIZE));
 }
 
 static void
===================================================================
RCS file: sys/scsi/RCS/od.c,v
retrieving revision 1.12.0.4
diff -u -r1.12.0.4 sys/scsi/od.c
--- 1.12.0.4	1996/02/11 13:38:06
+++ sys/scsi/od.c	1996/02/12 13:01:22
@@ -28,7 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- *	$Id: od.c,v 1.12.0.4 1996/02/11 13:38:06 shun Exp $
+ *	$Id: od.c,v 1.12.0.4.0.1 1996/02/11 13:41:33 shun Exp $
  */
 
 /*
@@ -357,7 +357,7 @@
 	if (errcode) {
 		goto bad;
 	}
-	if (od->params.secsiz != SECSIZE) {
+	if (od->params.secsiz != SECSIZE && od->params.secsiz != 1024) {
 		printf("od%ld: Can't deal with %d bytes logical blocks\n",
 		    unit, od->params.secsiz);
 		Debugger("od");
@@ -533,6 +533,7 @@
 	struct buf *bp = 0;
 	struct scsi_rw_big cmd;
 	u_int32 blkno, nblk;
+	u_int32 secsize;
 
 	SC_DEBUG(sc_link, SDEV_DB2, ("odstart "));
 	/*
@@ -569,12 +570,13 @@
 		 * We have a buf, now we know we are going to go through
 		 * With this thing..
 		 */
-		blkno = bp->b_pblkno;
-		if (bp->b_bcount & (SECSIZE - 1))
+		secsize = od->params.secsiz;
+		blkno = bp->b_pblkno / (secsize / DEV_BSIZE);
+		if (bp->b_bcount & (secsize - 1))
 		{
 		    goto bad;
 		}
-		nblk = bp->b_bcount >> 9;
+		nblk = (bp->b_bcount + (secsize - 1)) / secsize;
 
 		/*
 		 *  Fill out the scsi command
===================================================================
RCS file: sys/ufs/ffs/RCS/ffs_vfsops.c,v
retrieving revision 1.35
diff -u -r1.35 sys/ufs/ffs/ffs_vfsops.c
--- 1.35	1996/01/19 03:59:14
+++ sys/ufs/ffs/ffs_vfsops.c	1996/02/12 13:01:22
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_vfsops.c	8.8 (Berkeley) 4/18/94
- * $Id: ffs_vfsops.c,v 1.35 1996/01/19 03:59:14 dyson Exp $
+ * $Id: ffs_vfsops.c,v 1.35.0.2 1996/02/12 07:45:48 shun Exp $
  */
 
 #include "opt_quota.h"
@@ -144,7 +144,7 @@
 
 	struct ufs_args args;
 	struct ufsmount *ump = 0;
-	register struct fs *fs;
+	register struct fs *fs = NULL;
 	int flags;
 
 	/*
@@ -326,6 +326,14 @@
 	 */
 	(void)VFS_STATFS(mp, &mp->mnt_stat, p);
 
+	if (fs == NULL) {
+		/* root mounts, set default sector size */
+		mp->mnt_stat.f_spare[0] = 512;
+	} else {
+		/* non-root mounts, set sector size */
+		mp->mnt_stat.f_spare[0] = fs->fs_fsize / fs->fs_nspf;
+	}
+
 	goto success;
 
 
@@ -530,6 +538,8 @@
 		fs->fs_fmod = 1;
 		fs->fs_clean = 0;
 	}
+	for (fs->fs_fsbtodb = 0, i = fs->fs_fsize / DEV_BSIZE; i > 1; i >>= 1)
+		fs->fs_fsbtodb++;
 	blks = howmany(fs->fs_cssize, fs->fs_fsize);
 	base = space = malloc((u_long)fs->fs_cssize, M_UFSMNT,
 	    M_WAITOK);
===================================================================
RCS file: sys/ufs/ufs/RCS/ufs_disksubr.c,v
retrieving revision 1.20
diff -u -r1.20 sys/ufs/ufs/ufs_disksubr.c
--- 1.20	1995/11/23 07:24:32
+++ sys/ufs/ufs/ufs_disksubr.c	1996/02/12 13:01:22
@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ufs_disksubr.c	8.5 (Berkeley) 1/21/94
- * $Id: ufs_disksubr.c,v 1.20 1995/11/23 07:24:32 dyson Exp $
+ * $Id: ufs_disksubr.c,v 1.20.0.1 1996/02/11 14:00:36 shun Exp $
  */
 
 #include <sys/param.h>
@@ -249,13 +249,15 @@
 	register struct buf *bp;
 	struct disklabel *dlp;
 	char *msg = NULL;
+	int scale;
 
+	scale = lp->d_secsize / DEV_BSIZE;
 	bp = geteblk((int)lp->d_secsize);
 	bp->b_dev = dev;
-	bp->b_blkno = LABELSECTOR;
+	bp->b_blkno = LABELSECTOR * scale;
 	bp->b_bcount = lp->d_secsize;
 	bp->b_flags = B_BUSY | B_READ;
-	bp->b_cylinder = LABELSECTOR / lp->d_secpercyl;
+	bp->b_cylinder = (LABELSECTOR * scale) / lp->d_secpercyl;
 	(*strat)(bp);
 	if (biowait(bp))
 		msg = "I/O error";
@@ -353,7 +355,7 @@
 	}
 	bp = geteblk((int)lp->d_secsize);
 	bp->b_dev = dkmodpart(dev, labelpart);
-	bp->b_blkno = LABELSECTOR;
+	bp->b_blkno = LABELSECTOR * (lp->d_secsize / DEV_BSIZE);
 	bp->b_bcount = lp->d_secsize;
 #if 1
 	/*
===================================================================
RCS file: sys/vm/RCS/vnode_pager.c,v
retrieving revision 1.58
diff -u -r1.58 sys/vm/vnode_pager.c
--- 1.58	1996/01/19 04:00:31
+++ sys/vm/vnode_pager.c	1996/02/12 13:01:23
@@ -38,7 +38,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)vnode_pager.c	7.5 (Berkeley) 4/20/91
- *	$Id: vnode_pager.c,v 1.58 1996/01/19 04:00:31 dyson Exp $
+ *	$Id: vnode_pager.c,v 1.58.0.1 1996/02/11 14:04:46 shun Exp $
  */
 
 /*
@@ -628,12 +628,14 @@
 	struct buf *bp;
 	int s;
 	int error = 0;
+	int dev_bsize;
 
 	vp = object->handle;
 	if (vp->v_mount == NULL)
 		return VM_PAGER_BAD;
 
 	bsize = vp->v_mount->mnt_stat.f_iosize;
+	dev_bsize = vp->v_mount->mnt_stat.f_spare[0];
 
 	/* get the UNDERLYING device for the file with VOP_BMAP() */
 
@@ -752,7 +754,7 @@
 	 * round up physical size for real devices
 	 */
 	if (dp->v_type == VBLK || dp->v_type == VCHR)
-		size = (size + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
+		size = (size + dev_bsize - 1) & ~(dev_bsize - 1);
 
 	bp = getpbuf();
 	kva = (vm_offset_t) bp->b_data;
----- (2) enhancement patch -----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9602140829.AA05282>