Subject: Re: proposal for non-512 bytes/sector block device
To: None <thorpej@nas.nasa.gov>
From: Koji Imada - je4owb/2 <koji@math.human.nagoya-u.ac.jp>
List: tech-kern
Date: 07/01/1997 00:48:50
>>>>> ">" == 2  <Koji> writes:

 >>  |> Koji-san has caught the file system cases.  But, what about the swap
 >>  |> pager?  What about raw i/o?

 >> Although raw i/o seems to be working on my kernel, I don't noticed
 >> swap pager. I think it will be possible to adopt swap pager to this
 >> change, I will try this(I dislike btodb() and dbtob() like dtom() :-).

In the case of "block io unit == physical sector size"(5.1 and 5.3),
swap pager worked with 640MB MO(2048 bytes/sector) with change of the
following patch.

Though this worked, there is some thing to decide as implementation
policy like what is the unit of returned value from (*d_psize)() of
bdevsw. This patch just adopt current swap pager to block io unit
different from DEV_BSIZE.
--
Koji Imada - je4owb/2

Index: sys/vm/vm_swap.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/vm/vm_swap.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 vm_swap.c
--- vm_swap.c	1997/06/23 16:31:41	1.1.1.4
+++ vm_swap.c	1997/06/30 13:27:16
@@ -38,6 +38,7 @@
 #include <sys/proc.h>
 #include <sys/namei.h>
 #include <sys/disklabel.h>
+#include <sys/dkio.h>
 #include <sys/dmap.h>
 #include <sys/errno.h>
 #include <sys/kernel.h>
@@ -116,9 +117,9 @@
 	struct extent		*swd_ex;
 	struct vnode		*swd_vp;
 	CIRCLEQ_ENTRY(swapdev)	swd_next;
+	int			swd_bsize;
 
 #ifdef SWAP_TO_FILES
-	int			swd_bsize;
 	int			swd_maxactive;
 	struct buf		swd_tab;
 	struct ucred		*swd_cred;
@@ -516,6 +517,9 @@
 #endif /* NFS */
 	dev_t dev = sdp->swd_dev;
 	char *name;
+#if 1
+	struct partinfo dpart;
+#endif
 
 	/* If root on swap, then the skip open/close operations. */
 	if (vp != rootvp) {
@@ -535,6 +539,18 @@
 			error = ENXIO;
 			goto bad;
 		}
+#if 1
+		if (VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, FREAD, p->p_ucred, p) != 0)
+			sdp->swd_bsize = DEV_BSIZE;
+		else
+			sdp->swd_bsize = dpart.disklab->d_secsize;
+#if 0 /* (*d_psize)() returns  in DEV_BSIZE unit */
+		if (sdp->swd_bsize < DEV_BSIZE)
+			nblks /= (sdp->swd_bsize / DEV_BSIZE);
+		else
+			nblks *= (DEV_BSIZE / sdp->swd_bsize);
+#endif
+#endif
 		break;
 
 #ifdef SWAP_TO_FILES
@@ -853,7 +869,14 @@
 	default:
 		panic("swstrategy: vnode type %x", sdp->swd_vp->v_type);
 	case VBLK:
+#if 1
+		if (sdp->swd_bsize > DEV_BSIZE)
+			bp->b_blkno = bn / (sdp->swd_bsize / DEV_BSIZE);
+		else
+			bp->b_blkno = bn * (DEV_BSIZE / sdp->swd_bsize);
+#else
 		bp->b_blkno = bn;
+#endif
 		vp = sdp->swd_vp;
 		bp->b_dev = sdp->swd_dev;
 		VHOLD(vp);