tech-kern archive

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

Enabling wedge autodiscovery on vnd disks



        hello.  In researching a recent bug under NetBSD-5, I discovered the
desire to make wedges work with vnd disks.  While the ability for these
devices to deal with wedge ioctls was added by riz some time ago, the
ability to have wedges autodiscovered when the vnd is configured was not.
The below patch does this.  If a gpt disk partition is defined on the vnd
file when the vnd is configured, then it will be attached to the dk driver.
For example, 
if I do:
vnconfig -c vnd0 testfs
Then I see the following from the kernel:
vnd0: GPT GUID: ea0f421c-b028-11e1-8bf0-00c04f140374
dk0 at vnd0: ea0f42bc-b028-11e1-8bf0-00c04f140374
dk0: 202685 blocks at 34, type: ffs

If I then unconfigure the vnd, I see:
dk0 at vnd0 (ea0f42bc-b028-11e1-8bf0-00c04f140374) deleted

        If there is no gpt partition on a vnd file, then behavior of the vnd
is as it was before this change.  When the dk driver is active, only the
raw partition of the vnd is accessible.

Is there any reason I shouldn't commit this change?  Would folks  be
interested in pullups to the NetBSD-6 and NetBSD-5 branches?
-thanks
-Brian


Index: vnd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/vnd.c,v
retrieving revision 1.220
diff -u -r1.220 vnd.c
--- vnd.c       26 Mar 2012 16:28:08 -0000      1.220
+++ vnd.c       6 Jun 2012 23:42:10 -0000
@@ -339,8 +339,20 @@
         * not already valid.
         */
        if ((sc->sc_flags & (VNF_INITED|VNF_VLABEL)) == VNF_INITED &&
-           sc->sc_dkdev.dk_openmask == 0)
-               vndgetdisklabel(dev, sc);
+           sc->sc_dkdev.dk_openmask == 0) {
+               /*See if we have wedges, then check for the disklabel*/
+               if (sc->sc_dkdev.dk_nwedges == 0) 
+                       vndgetdisklabel(dev, sc);
+       }
+
+       /*
+        * If there are wedges, and this is not RAW_PART, then we
+        * need to fail.
+        */
+       if (sc->sc_dkdev.dk_nwedges != 0 && part != RAW_PART) {
+               error = EBUSY;
+               goto done;
+       }
 
        /* Check that the partitions exists. */
        if (part != RAW_PART) {
@@ -987,6 +999,7 @@
        pool_destroy(&vnd->sc_vxpool);
 
        /* Detach the disk. */
+       dkwedge_delall(&vnd->sc_dkdev);
        disk_detach(&vnd->sc_dkdev);
 
        return 0;
@@ -1321,7 +1334,15 @@
                    0, 0, "vndxpl", NULL, IPL_BIO);
 
                /* Try and read the disklabel. */
-               vndgetdisklabel(dev, vnd);
+               /*Discover wedges if there are any*/
+               vndgetdefaultlabel(vnd, vnd->sc_dkdev.dk_label); /*XXX: */
+               vndunlock(vnd); /*XXX*/
+               dkwedge_discover(&vnd->sc_dkdev);
+               if ((error = vndlock(vnd)) != 0)
+                       goto close_and_exit;
+
+               if (vnd->sc_dkdev.dk_nwedges == 0)
+                       vndgetdisklabel(dev, vnd);
 
                vndunlock(vnd);
 


Home | Main Index | Thread Index | Old Index