Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/scsipi Add a flag to dk_dump for virtual disk devices.



details:   https://anonhg.NetBSD.org/src/rev/7605a3a79413
branches:  trunk
changeset: 969768:7605a3a79413
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Mar 01 03:21:54 2020 +0000

description:
Add a flag to dk_dump for virtual disk devices.

If a disk is backed by a physical medium other than itself, such as
cgd(4), then it passes DK_DUMP_RECURSIVE to disable the recursion
detection for dk_dump.

If, however, a device represents a physical medium on its own, such
as wd(4), then it passes 0 instead.

With this, I can now dump to dk on cgd on dk on wd.

diffstat:

 sys/arch/xen/xen/xbd_xenbus.c      |   6 +++---
 sys/dev/ata/wd.c                   |   6 +++---
 sys/dev/cgd.c                      |   6 +++---
 sys/dev/dksubr.c                   |  12 +++++++-----
 sys/dev/dkvar.h                    |   6 ++++--
 sys/dev/ld.c                       |   6 +++---
 sys/dev/raidframe/rf_netbsdkintf.c |   8 ++++----
 sys/dev/scsipi/sd.c                |   6 +++---
 8 files changed, 30 insertions(+), 26 deletions(-)

diffs (245 lines):

diff -r 794af28fd49f -r 7605a3a79413 sys/arch/xen/xen/xbd_xenbus.c
--- a/sys/arch/xen/xen/xbd_xenbus.c     Sun Mar 01 03:19:46 2020 +0000
+++ b/sys/arch/xen/xen/xbd_xenbus.c     Sun Mar 01 03:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: xbd_xenbus.c,v 1.94 2019/10/16 19:52:08 jdolecek Exp $      */
+/*      $NetBSD: xbd_xenbus.c,v 1.95 2020/03/01 03:21:54 riastradh Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.94 2019/10/16 19:52:08 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.95 2020/03/01 03:21:54 riastradh Exp $");
 
 #include "opt_xen.h"
 
@@ -929,7 +929,7 @@
 
        DPRINTF(("xbddump(%d, %" PRId64 ", %p, %lu)\n", dev, blkno, va,
            (unsigned long)size));
-       return dk_dump(&sc->sc_dksc, dev, blkno, va, size);
+       return dk_dump(&sc->sc_dksc, dev, blkno, va, size, 0);
 }
 
 static int
diff -r 794af28fd49f -r 7605a3a79413 sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Sun Mar 01 03:19:46 2020 +0000
+++ b/sys/dev/ata/wd.c  Sun Mar 01 03:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd.c,v 1.457 2020/01/18 11:24:40 simonb Exp $ */
+/*     $NetBSD: wd.c,v 1.458 2020/03/01 03:21:54 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.457 2020/01/18 11:24:40 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.458 2020/03/01 03:21:54 riastradh Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -1522,7 +1522,7 @@
                return (ENXIO);
        dksc = &wd->sc_dksc;
 
-       return dk_dump(dksc, dev, blkno, va, size);
+       return dk_dump(dksc, dev, blkno, va, size, 0);
 }
 
 static int
diff -r 794af28fd49f -r 7605a3a79413 sys/dev/cgd.c
--- a/sys/dev/cgd.c     Sun Mar 01 03:19:46 2020 +0000
+++ b/sys/dev/cgd.c     Sun Mar 01 03:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.119 2020/01/17 19:31:30 ad Exp $ */
+/* $NetBSD: cgd.c,v 1.120 2020/03/01 03:21:54 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.119 2020/01/17 19:31:30 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.120 2020/03/01 03:21:54 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -737,7 +737,7 @@
        DPRINTF_FOLLOW(("cgddump(0x%"PRIx64", %" PRId64 ", %p, %lu)\n",
            dev, blkno, va, (unsigned long)size));
        GETCGD_SOFTC(cs, dev);
-       return dk_dump(&cs->sc_dksc, dev, blkno, va, size);
+       return dk_dump(&cs->sc_dksc, dev, blkno, va, size, DK_DUMP_RECURSIVE);
 }
 
 /*
diff -r 794af28fd49f -r 7605a3a79413 sys/dev/dksubr.c
--- a/sys/dev/dksubr.c  Sun Mar 01 03:19:46 2020 +0000
+++ b/sys/dev/dksubr.c  Sun Mar 01 03:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.111 2019/12/08 12:15:24 mlelstv Exp $ */
+/* $NetBSD: dksubr.c,v 1.112 2020/03/01 03:21:54 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.111 2019/12/08 12:15:24 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.112 2020/03/01 03:21:54 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -767,7 +767,7 @@
 /* ARGSUSED */
 int
 dk_dump(struct dk_softc *dksc, dev_t dev,
-    daddr_t blkno, void *vav, size_t size)
+    daddr_t blkno, void *vav, size_t size, int flags)
 {
        const struct dkdriver *dkd = dksc->sc_dkdev.dk_driver;
        struct disk_geom *dg = &dksc->sc_dkdev.dk_geom;
@@ -790,7 +790,8 @@
        /* ensure that we are not already dumping */
        if (dk_dumping)
                return EFAULT;
-       dk_dumping = 1;
+       if ((flags & DK_DUMP_RECURSIVE) == 0)
+               dk_dumping = 1;
 
        if (dkd->d_dumpblocks == NULL) {
                DPRINTF(DKDB_DUMP, ("%s: no dumpblocks\n", __func__));
@@ -869,7 +870,8 @@
                va += nblk * lp->d_secsize;
        }
 
-       dk_dumping = 0;
+       if ((flags & DK_DUMP_RECURSIVE) == 0)
+               dk_dumping = 0;
 
        return 0;
 }
diff -r 794af28fd49f -r 7605a3a79413 sys/dev/dkvar.h
--- a/sys/dev/dkvar.h   Sun Mar 01 03:19:46 2020 +0000
+++ b/sys/dev/dkvar.h   Sun Mar 01 03:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkvar.h,v 1.31 2019/12/08 12:15:24 mlelstv Exp $ */
+/* $NetBSD: dkvar.h,v 1.32 2020/03/01 03:21:54 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -83,6 +83,8 @@
        ((_dksc)->sc_dkdev.dk_bopenmask & (_pmask)  &&  \
        ((_dksc)->sc_dkdev.dk_copenmask & (_pmask))))
 
+#define        DK_DUMP_RECURSIVE       __BIT(0) /* this is a virtual disk */
+
 /*
  * Functions that are exported to the pseudo disk implementations:
  */
@@ -106,7 +108,7 @@
 int    dk_ioctl(struct dk_softc *, dev_t,
                 u_long, void *, int, struct lwp *);
 int    dk_dump(struct dk_softc *, dev_t,
-               daddr_t, void *, size_t);
+               daddr_t, void *, size_t, int);
 void   dk_getdisklabel(struct dk_softc *, dev_t);
 void   dk_getdefaultlabel(struct dk_softc *, struct disklabel *);
 
diff -r 794af28fd49f -r 7605a3a79413 sys/dev/ld.c
--- a/sys/dev/ld.c      Sun Mar 01 03:19:46 2020 +0000
+++ b/sys/dev/ld.c      Sun Mar 01 03:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld.c,v 1.108 2020/02/10 10:05:55 mlelstv Exp $ */
+/*     $NetBSD: ld.c,v 1.109 2020/03/01 03:21:54 riastradh Exp $       */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.108 2020/02/10 10:05:55 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.109 2020/03/01 03:21:54 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -513,7 +513,7 @@
        if ((sc->sc_flags & LDF_ENABLED) == 0)
                return (ENODEV);
 
-       return dk_dump(dksc, dev, blkno, va, size);
+       return dk_dump(dksc, dev, blkno, va, size, 0);
 }
 
 static int
diff -r 794af28fd49f -r 7605a3a79413 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Sun Mar 01 03:19:46 2020 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Sun Mar 01 03:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.379 2019/11/10 21:16:37 chs Exp $ */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.380 2020/03/01 03:21:54 riastradh Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * from: Utah $Hdr: cd.c 1.6 90/11/28$
+ * from: Utah $Hdr$
  *
  *      @(#)cd.c        8.2 (Berkeley) 11/16/93
  */
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.379 2019/11/10 21:16:37 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.380 2020/03/01 03:21:54 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_raid_autoconfig.h"
@@ -662,7 +662,7 @@
         */
        blkno += RF_PROTECTED_SECTORS;
 
-       return dk_dump(dksc, dev, blkno, va, size);
+       return dk_dump(dksc, dev, blkno, va, size, DK_DUMP_RECURSIVE);
 }
 
 static int
diff -r 794af28fd49f -r 7605a3a79413 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Sun Mar 01 03:19:46 2020 +0000
+++ b/sys/dev/scsipi/sd.c       Sun Mar 01 03:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sd.c,v 1.327 2019/03/19 06:59:40 mlelstv Exp $ */
+/*     $NetBSD: sd.c,v 1.328 2020/03/01 03:21:54 riastradh Exp $       */
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.327 2019/03/19 06:59:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.328 2020/03/01 03:21:54 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -1192,7 +1192,7 @@
        if ((periph->periph_flags & PERIPH_MEDIA_LOADED) == 0)
                return (ENXIO);
 
-       return dk_dump(dksc, dev, blkno, va, size);
+       return dk_dump(dksc, dev, blkno, va, size, 0);
 }
 
 static int



Home | Main Index | Thread Index | Old Index