Subject: kern/3460: block io unit for sd should be sector size
To: None <gnats-bugs@gnats.netbsd.org>
From: Koji Imada - je4owb/2 <koji@imada.math.human.nagoya-u.ac.jp>
List: netbsd-bugs
Date: 04/08/1997 10:19:10
>Number:         3460
>Category:       kern
>Synopsis:       block io unit for sd should be sector size
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Apr  7 18:35:03 1997
>Last-Modified:
>Originator:     Koji Imada - je4owb/2
>Organization:
Mathematics Group of Graduate School of Human
	Infomatics, Nagoya University, Japan.
>Release:        970330
>Environment:
	
System: NetBSD bimota 1.2D NetBSD 1.2D (BIMOTA) #3: Mon Mar 31 01:14:23 JST 1997 koji@bimota:/usr/local/work/current/src/sys/arch/i386/compile/BIMOTA i386


>Description:
	block io unit of sd should be physical sector size. So
	translation of b_blkno in sdstart is not
	necessary. Support of non-512 bytes/sector media becomes easy
	If this is corrected. I think file system code assume this
	behavior.

	I applied this and disklabel routine modification and am using
	ffs/msdosfs on 640MB MO(2048bytes/sector). Of course ffs code
	may needs more clean up.
>How-To-Repeat:
>Fix:
	apply following patch.

Index: sys/scsi/sd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/sd.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 sd.c
*** sd.c	1997/04/01 07:19:17	1.1.1.2
--- sd.c	1997/04/08 01:05:04
***************
*** 577,584 ****
  		 * First, translate the block to absolute and put it in terms
  		 * of the logical blocksize of the device.
  		 */
! 		blkno =
! 		    bp->b_blkno / (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
  		if (SDPART(bp->b_dev) != RAW_PART) {
  		     p = &sd->sc_dk.dk_label->d_partitions[SDPART(bp->b_dev)];
  		     blkno += p->p_offset;
--- 577,583 ----
  		 * First, translate the block to absolute and put it in terms
  		 * of the logical blocksize of the device.
  		 */
! 		blkno = bp->b_blkno;
  		if (SDPART(bp->b_dev) != RAW_PART) {
  		     p = &sd->sc_dk.dk_label->d_partitions[SDPART(bp->b_dev)];
  		     blkno += p->p_offset;
***************
*** 812,819 ****
  	lp->d_flags = 0;
  
  	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_partitions[RAW_PART].p_fstype = FS_UNUSED;
  	lp->d_npartitions = RAW_PART + 1;
  
--- 811,817 ----
  	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;
  
>Audit-Trail:
>Unformatted: