NetBSD Problem Report #46494

From www@NetBSD.org  Tue May 29 13:10:54 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 9E58B63B88D
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 29 May 2012 13:10:54 +0000 (UTC)
Message-Id: <20120529131052.1226E63B882@www.NetBSD.org>
Date: Tue, 29 May 2012 13:10:52 +0000 (UTC)
From: jan.m.danielsson@gmail.com
Reply-To: jan.m.danielsson@gmail.com
To: gnats-bugs@NetBSD.org
Subject: cgd doesn't work on disk with 4K (read: non-512 byte) sector size
X-Send-Pr-Version: www-1.0

>Number:         46494
>Category:       kern
>Synopsis:       cgd doesn't work on disk with 4K (read: non-512 byte) sector size
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    mlelstv
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 29 13:15:00 +0000 2012
>Closed-Date:    Sun Nov 20 07:46:30 +0000 2022
>Last-Modified:  Sun Nov 20 07:46:30 +0000 2022
>Originator:     Jan Danielsson
>Release:        NetBSD/amd64 6 beta 2
>Organization:
>Environment:
NetBSD pussycat 6.0_BETA NetBSD 6.0_BETA (PUSSYCAT) #0: Mon May 21 10:04:13 CEST 2012  jan@pussycat:/home/jan/sysbuild/obj.amd64/usr/src/sys/arch/amd64/compile/PUSSYCAT amd64
>Description:
# 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
flags:
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 instance).

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).
>How-To-Repeat:
[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.
>Fix:
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.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->mlelstv
Responsible-Changed-By: mlelstv@NetBSD.org
Responsible-Changed-When: Mon, 30 Nov 2015 06:57:46 +0000
Responsible-Changed-Why:
Working on it


State-Changed-From-To: open->closed
State-Changed-By: mlelstv@NetBSD.org
State-Changed-When: Sun, 20 Nov 2022 07:46:30 +0000
State-Changed-Why:
Fixed in cgd.c 1.105.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.