Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Mar 1998 09:48:41 -0800 (PST)
From:      vanmaren@cs.utah.edu
To:        freebsd-gnats-submit@FreeBSD.ORG
Subject:   kern/6133: optical drive with 1024-byte (1k) sectors does not work in 2.2-STABLE
Message-ID:  <199803251748.JAA23407@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         6133
>Category:       kern
>Synopsis:       optical drive with 1024-byte (1k) sectors does not work in 2.2-STABLE
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 25 09:50:01 PST 1998
>Last-Modified:
>Originator:     Kevin T. Van Maren
>Organization:
University of Utah
>Release:        2.2.6-BETA
>Environment:
FreeBSD slug.cs.utah.edu 2.2.6-BETA FreeBSD 2.2.6-BETA #13: Wed Mar 25 10:12:29 MST 1998     vanmaren@marker.cs.utah.edu:/usr/src/sys/compile/SLUG  i386

>Description:
The OD drive appeared to be usable when reading or writing 1k
chunks, but any accesses after the first half of the drive failed.
By specifying the sector size and number of sectors newfs would
`succeed'.  However, the filesystem was non-functional after mounting.

>From dmesg:

aha0 at 0x330-0x333 irq 11 drq 5 on isa
(aha0:0:0): "iomega jaz 1GB J^77" type 0 removable SCSI 2
sd0(aha0:0:0): Direct-Access
sd0(aha0:0:0): ILLEGAL REQUEST asc:24,0 Invalid field in CDB
sd0 could not mode sense (4). Using ficticious geometry
1021MB (2091050 512 byte sectors)
(aha0:1:0): "SONY SMO-C501-00E 3.02" type 0 removable SCSI 1
od0(aha0:1:0): Optical 311MB (318665 1024 byte sectors)

>How-To-Repeat:
Attempt to newfs a MO drive (od.c driver) with 1k sectors,
mount it, and access it.
>Fix:
By applying some patches from -current, I was able to newfs,
mount, and use the optical drive.  I did not attempt to partition
the drive, using the entire disk for one filesystem.  Applying the
patches for the 4 files appears to be sufficient.

===
sys/scsi/od.c:
        merged in 1.22 to 1.24 diffs (bringing to 1.24 in 2.2-STABLE)

sys/ufs/ufs/ufs_disksubr.c
        merged in 1.26 to 1.27 (bringing to 1.27 in 2.2-STABLE)

sbin/newfs/newfs.c
        merged in 1.13 to 1.14 changes into 2.2-STABLE

bin/newfs/mkfs.c
        merged in 1.11 to 1.12 changes into 2.2-STABLE
===
Other related patched I did not apply:

sys/kern/subr_diskslice.c
        did not merge in 1.30 to 1.31

sys/scsi/sd.c:
        did not merge in 1.95 to 1.96, so scsi disks with large
        sectors are still not supported in 2.2-STABLE.

sbin/i386/fdisk/fdisk.c:
        did not merge in 1.95 to 1.96, so fdisk won't work
        with large sectors in 2.2-STABLE.
=== 
After adding this in disktab:

sony-ours:\ 
        :ty=optical:ns#32:nt#64:nc#155:\ 
        :pc#318665:oc#0:bc#8192:fc#1024:

newfs works, and mounting succeeded

% newfs  -S 1024 /dev/rod0c sony-ours
Warning: Block size restricts cylinders per group to 11.
Warning: 1646 sector(s) in last cylinder unallocated
/dev/rod0c:     637330 sectors in 78 cylinders of 1 tracks, 8192 sectors
        311.2MB in 8 cyl groups (11 c/g, 44.00MB/g, 10624 i/g)
super-block backups (for fsck -b #) at:
 32, 90144, 180256, 270368, 360480, 450592, 540704, 630816,

=====

Index: sbin/newfs/mkfs.c
===================================================================
RCS file: /n/marker/usr/lsrc/FreeBSD/CVS/src/sbin/newfs/mkfs.c,v
retrieving revision 1.11.2.1
diff -r1.11.2.1 mkfs.c
84a85
> extern int    realsectorsize; /* bytes/sector in hardware*/
217c218,219
<       wtfs(fssize - 1, sectorsize, (char *)&sblock);
---
>       wtfs(fssize - (realsectorsize / DEV_BSIZE), realsectorsize,
>               (char *)&sblock);
Index: sbin/newfs/newfs.c
===================================================================
RCS file: /n/marker/usr/lsrc/FreeBSD/CVS/src/sbin/newfs/newfs.c,v
retrieving revision 1.13.2.1
diff -r1.13.2.1 newfs.c
170d169
< #ifdef tahoe
172d170
< #endif
237c235
<       while ((ch = getopt(argc, argv, opstring)) != EOF)
---
>       while ((ch = getopt(argc, argv, opstring)) !=  -1)
532a531,542
> #else
>       realsectorsize = sectorsize;
>       if (sectorsize != DEV_BSIZE) {          /* XXX */
>               int secperblk = sectorsize / DEV_BSIZE;
> 
>               sectorsize = DEV_BSIZE;
>               nsectors *= secperblk;
>               nphyssectors *= secperblk;
>               secpercyl *= secperblk;
>               fssize *= secperblk;
>               pp->p_size *= secperblk;
>       }
537a548,550
> #else
>       if (realsectorsize != DEV_BSIZE)
>               pp->p_size /= realsectorsize /DEV_BSIZE;
Index: sys/scsi/od.c
===================================================================
RCS file: /n/marker/usr/lsrc/FreeBSD/CVS/src/sys/scsi/od.c,v
retrieving revision 1.22.2.1
diff -r1.22.2.1 od.c
448a449
>       int secsize;
465c466
<       if (bp->b_blkno < 0 || bp->b_bcount % DEV_BSIZE != 0) {
---
>       if (bp->b_blkno < 0 ) {
466a468
>               printf("od_strategy: Negative block number: 0x%x\n", bp->b_blkno
);
468a471,488
> 
>       
>       secsize = od->params.secsiz;
> 
>       /* make sure the blkno is scalable */
>       if( (bp->b_blkno % (secsize/DEV_BSIZE)) != 0 ) {
>               bp->b_error = EINVAL;
>               printf("od_strategy: Block number is not multiple of sector size
 (2): 0x%x\n", bp->b_blkno);
>               goto bad;
>       }
> 
>       /* make sure that the transfer size is a multiple of the sector size */
>       if( (bp->b_bcount % secsize) != 0 ) {
>               bp->b_error = EINVAL;
>               printf("od_strategy: Invalid b_bcount %d at block number: 0x%x\n
", bp->b_bcount, bp->b_blkno);
>               goto bad;
>       }
> 
472c492,514
<       if (dscheck(bp, od->dk_slices) <= 0)
---
>       {
>       int status;
>       int sec_blk_ratio = secsize/DEV_BSIZE;
>       /* save original block number and size */
>       int b_blkno = bp->b_blkno;
>       int b_bcount = bp->b_bcount;
> 
>       /* replace with scaled values */
>       bp->b_blkno /= sec_blk_ratio;
>       bp->b_bcount /= sec_blk_ratio;
>       
>       /* have dscheck enforce limits and map to physical block number */
>       status = dscheck(bp, od->dk_slices);
> 
>       /* restore original values to prevent bad side effects in block system *
/
>       bp->b_blkno = b_blkno;
>       bp->b_bcount = b_bcount;
>       /* scale resid */
>       bp->b_resid *= sec_blk_ratio;
> 
>       /* see if the mapping failed */
>       if (status <= 0)
>               {
473a516,517
>               }
>       }
582c626
<               blkno = bp->b_pblkno / (secsize / DEV_BSIZE);
---
>               blkno = bp->b_pblkno;
587c631
<               nblk = (bp->b_bcount + (secsize - 1)) / secsize;
---
>               nblk = bp->b_bcount / secsize;
Index: sys/ufs/ufs/ufs_disksubr.c
===================================================================
RCS file: /n/marker/usr/lsrc/FreeBSD/CVS/src/sys/ufs/ufs/ufs_disksubr.c,v
retrieving revision 1.26
diff -r1.26 ufs_disksubr.c
185c185
<       bp->b_blkno = LABELSECTOR;
---
>       bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE);
287c287
<       bp->b_blkno = LABELSECTOR;
---
>       bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE);

>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



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