Subject: Re: wedges and portable media
To: None <tech-kern@NetBSD.org>
From: David Young <dyoung@pobox.com>
List: tech-kern
Date: 04/08/2007 15:04:24
On Fri, Apr 06, 2007 at 09:22:54PM -0500, David Young wrote:
> On a NetBSD/evbmips board, I am trying to access a couple of partitions on
> a CF card that I originally created for i386, using wedges.  I have found
> out that the kernel sets the wedge's parent device to the architecture's
> notion of the "raw partition" on the device.  That choice isn't right
> if the disk will be moved back and forth between i386 and evbmips.
> 
> I am not sure whether/how to fix this.  Should dkwedge_compute_pdev()
> search the partition table for the partition that matches the disk
> geometry?  For the partition that encloses all other partitions?

I have modified dkwedge_compute_pdev() so that it searches for
partitions with p_offset == 0, p_size == d_secperunit, preferring
"unused" partitions, and preferring RAW_PART (be it "unused" or not)
above all.  This gets me a lot closer to where I need to be: on evbmips,
both auto-discovery of partitions and dkscan_bsdlabel work satisfactorily
on a BSD partition table that I created for i386.  With the help of
Martin's patches, I can also dump to the volume.

"swapctl -D /dev/dk1 ; savecore -N /dev/ksyms /var/crash" does not work,
however.  savecore cannot open the dump device (EBUSY).  The kernel
trips over RAW_PART again, in wd(4), wdopen:

        /*
         * If there are wedges, and this is not RAW_PART, then we
         * need to fail.
         */
        if (wd->sc_dk.dk_nwedges != 0 && part != RAW_PART) {
                error = EBUSY;
                goto bad1;
        }

I am considering making the raw partition a property of the disk,
dk_rawpart, instead of the architecture, RAW_PART.  readdisklabel()
will set dk_rawpart.  The above check turns to something like this:

        /*
         * If there are wedges, and this is not RAW_PART, then we
         * need to fail.
         */
        if (wd->sc_dk.dk_nwedges != 0 && part != wd->sc_dk.dk_rawpart) {
                error = EBUSY;
                goto bad1;
        }

I am curious what others think.

Dave

-- 
David Young             OJC Technologies
dyoung@ojctech.com      Urbana, IL * (217) 278-3933