NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/46494: cgd doesn't work on disk with 4K (read: non-512 byte) sector size

>Number:         46494
>Category:       kern
>Synopsis:       cgd doesn't work on disk with 4K (read: non-512 byte) sector 
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 29 13:15:00 +0000 2012
>Originator:     Jan Danielsson
>Release:        NetBSD/amd64 6 beta 2
NetBSD pussycat 6.0_BETA NetBSD 6.0_BETA (PUSSYCAT) #0: Mon May 21 10:04:13 
CEST 2012  
# dmesg
umass0 at uhub6 port 6 configuration 1 interface 0
umass0: JMicron USB to ATA/ATAPI bridge, rev 2.00/1.00, addr 2
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, 1 lun per target
sd0 at scsibus0 target 0 lun 0: <WDC WD75, 00AARX-00N0YB0, > disk fixed
sd0: 698 GB, 16383 cyl, 16 head, 63 sec, 4096 bytes/sect x 183143646 sectors

# disklabel sd0
# /dev/rsd0d:
type: SCSI
disk: 00AARX-00N0YB0  
label: fictitious
bytes/sector: 4096
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 16383
total sectors: 183143646
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0 

The disk shown in the dmesg and disklabel excerpt above appears to work without 
cgd. Configuring a cgd device on top of it works, but using the cgd device 
fails when used (write errors occur when trying to save disklabel, for 

For a configured cgd device on such a disk, "disklabel cgdN" yields an output 
which shows the wrong geometry (in particular, the sector size is 512, rather 
than 4096).
[Assuming one is using a disk with 4K sector size]
# cgdconfig -g -V ffs -k storedkey -o test.cgd aes-cbc 256
# gpt create sd0
# gpt add -t cgd sd0
Partition added, use:
        dkctl sd0 addwedge <wedgename> 6 183143635 <type>
to create a wedge for it
# dkctl sd0 addwedge dk0 6 183143635 cgd
dk0 created successfully.
# cgdconfig -V none cgd3 /dev/dk0 test.cgd

.. then try to create a disklabel, and find that writing won't work.
Unknown, but replacing some DEV_BSIZE's in cgd.c with secsize from 
getdisksize() would appear to be a good place to start. That trivial change 
alone causes a panic though. For some reason my machine isn't entering DDB 
(even though DDB_ONPANIC is enabled), so I haven't looked closer at it yet.

Home | Main Index | Thread Index | Old Index