Author: imp
Date: Fri Jan 17 01:15:55 2020
New Revision: 356818
URL: https://svnweb.freebsd.org/changeset/base/356818

Log:
  Pass BIO_SPEEDUP through all the geom layers
  
  While some geom layers pass unknown commands down, not all do. For the ones 
that
  don't, pass BIO_SPEEDUP down to the providers that constittue the geom, as
  applicable. No changes to vinum or virstor because I was unsure how to add 
this
  support, and I'm also unsure how to test these. gvinum doesn't implement
  BIO_FLUSH either, so it may just be poorly maintained. gvirstor is for testing
  and not supportig BIO_SPEEDUP is fine.
  
  Reviewed by: chs
  Differential Revision: https://reviews.freebsd.org/D23183

Modified:
  head/sys/geom/concat/g_concat.c
  head/sys/geom/eli/g_eli.c
  head/sys/geom/gate/g_gate.c
  head/sys/geom/geom_disk.c
  head/sys/geom/geom_io.c
  head/sys/geom/geom_slice.c
  head/sys/geom/journal/g_journal.c
  head/sys/geom/linux_lvm/g_linux_lvm.c
  head/sys/geom/mirror/g_mirror.c
  head/sys/geom/nop/g_nop.c
  head/sys/geom/nop/g_nop.h
  head/sys/geom/part/g_part.c
  head/sys/geom/raid/g_raid.c
  head/sys/geom/raid/tr_concat.c
  head/sys/geom/raid/tr_raid0.c
  head/sys/geom/raid/tr_raid1.c
  head/sys/geom/raid/tr_raid1e.c
  head/sys/geom/raid/tr_raid5.c
  head/sys/geom/raid3/g_raid3.c
  head/sys/geom/shsec/g_shsec.c
  head/sys/geom/stripe/g_stripe.c

Modified: head/sys/geom/concat/g_concat.c
==============================================================================
--- head/sys/geom/concat/g_concat.c     Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/concat/g_concat.c     Fri Jan 17 01:15:55 2020        
(r356818)
@@ -279,8 +279,11 @@ g_concat_done(struct bio *bp)
        g_destroy_bio(bp);
 }
 
+/*
+ * Called for both BIO_FLUSH and BIO_SPEEDUP. Just pass the call down
+ */
 static void
-g_concat_flush(struct g_concat_softc *sc, struct bio *bp)
+g_concat_passdown(struct g_concat_softc *sc, struct bio *bp)
 {
        struct bio_queue_head queue;
        struct g_consumer *cp;
@@ -340,8 +343,9 @@ g_concat_start(struct bio *bp)
        case BIO_WRITE:
        case BIO_DELETE:
                break;
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
-               g_concat_flush(sc, bp);
+               g_concat_passdown(sc, bp);
                return;
        case BIO_GETATTR:
                if (strcmp("GEOM::kerneldump", bp->bio_attribute) == 0) {

Modified: head/sys/geom/eli/g_eli.c
==============================================================================
--- head/sys/geom/eli/g_eli.c   Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/eli/g_eli.c   Fri Jan 17 01:15:55 2020        (r356818)
@@ -429,6 +429,7 @@ g_eli_start(struct bio *bp)
        case BIO_GETATTR:
        case BIO_FLUSH:
        case BIO_ZONE:
+       case BIO_SPEEDUP:
                break;
        case BIO_DELETE:
                /*
@@ -468,6 +469,7 @@ g_eli_start(struct bio *bp)
        case BIO_GETATTR:
        case BIO_FLUSH:
        case BIO_DELETE:
+       case BIO_SPEEDUP:
        case BIO_ZONE:
                if (bp->bio_cmd == BIO_GETATTR)
                        cbp->bio_done = g_eli_getattr_done;

Modified: head/sys/geom/gate/g_gate.c
==============================================================================
--- head/sys/geom/gate/g_gate.c Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/gate/g_gate.c Fri Jan 17 01:15:55 2020        (r356818)
@@ -285,6 +285,7 @@ g_gate_start(struct bio *pbp)
        case BIO_DELETE:
        case BIO_WRITE:
        case BIO_FLUSH:
+       case BIO_SPEEDUP:
                /* XXX: Hack to allow read-only mounts. */
                if ((sc->sc_flags & G_GATE_FLAG_READONLY) != 0) {
                        g_io_deliver(pbp, EPERM);
@@ -871,6 +872,7 @@ g_gate_ioctl(struct cdev *dev, u_long cmd, caddr_t add
                case BIO_READ:
                case BIO_DELETE:
                case BIO_FLUSH:
+               case BIO_SPEEDUP:
                        break;
                case BIO_WRITE:
                        error = copyout(bp->bio_data, ggio->gctl_data,
@@ -935,6 +937,7 @@ start_end:
                                case BIO_DELETE:
                                case BIO_WRITE:
                                case BIO_FLUSH:
+                               case BIO_SPEEDUP:
                                        break;
                                }
                        }

Modified: head/sys/geom/geom_disk.c
==============================================================================
--- head/sys/geom/geom_disk.c   Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/geom_disk.c   Fri Jan 17 01:15:55 2020        (r356818)
@@ -560,6 +560,17 @@ g_disk_start(struct bio *bp)
                devstat_start_transaction_bio(dp->d_devstat, bp2);
                dp->d_strategy(bp2);
                break;
+       case BIO_SPEEDUP:
+               bp2 = g_clone_bio(bp);
+               if (bp2 == NULL) {
+                       g_io_deliver(bp, ENOMEM);
+                       return;
+               }
+               bp2->bio_done = g_disk_done;
+               bp2->bio_caller1 = sc;
+               bp2->bio_disk = dp;
+               dp->d_strategy(bp2);
+               break;
        default:
                error = EOPNOTSUPP;
                break;

Modified: head/sys/geom/geom_io.c
==============================================================================
--- head/sys/geom/geom_io.c     Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/geom_io.c     Fri Jan 17 01:15:55 2020        (r356818)
@@ -407,6 +407,7 @@ g_io_check(struct bio *bp)
                break;
        case BIO_WRITE:
        case BIO_DELETE:
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
                if (cp->acw == 0)
                        return (EPERM);

Modified: head/sys/geom/geom_slice.c
==============================================================================
--- head/sys/geom/geom_slice.c  Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/geom_slice.c  Fri Jan 17 01:15:55 2020        (r356818)
@@ -312,6 +312,7 @@ g_slice_start(struct bio *bp)
                        /* now, pass it on downwards... */
                }
                /* FALLTHROUGH */
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
                bp2 = g_clone_bio(bp);
                if (bp2 == NULL) {

Modified: head/sys/geom/journal/g_journal.c
==============================================================================
--- head/sys/geom/journal/g_journal.c   Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/journal/g_journal.c   Fri Jan 17 01:15:55 2020        
(r356818)
@@ -746,6 +746,7 @@ g_journal_start(struct bio *bp)
                        return;
                }
                /* FALLTHROUGH */
+       case BIO_SPEEDUP:
        case BIO_DELETE:
        default:
                g_io_deliver(bp, EOPNOTSUPP);

Modified: head/sys/geom/linux_lvm/g_linux_lvm.c
==============================================================================
--- head/sys/geom/linux_lvm/g_linux_lvm.c       Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/linux_lvm/g_linux_lvm.c       Fri Jan 17 01:15:55 2020        
(r356818)
@@ -215,6 +215,10 @@ g_llvm_start(struct bio *bp)
        /* XXX BIO_GETATTR allowed? */
                break;
        default:
+               /*
+                * BIO_SPEEDUP and BIO_FLUSH should pass through to all sg
+                * elements, but aren't.
+                */
                g_io_deliver(bp, EOPNOTSUPP);
                return;
        }

Modified: head/sys/geom/mirror/g_mirror.c
==============================================================================
--- head/sys/geom/mirror/g_mirror.c     Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/mirror/g_mirror.c     Fri Jan 17 01:15:55 2020        
(r356818)
@@ -925,7 +925,8 @@ g_mirror_regular_request_error(struct g_mirror_softc *
     struct g_mirror_disk *disk, struct bio *bp)
 {
 
-       if (bp->bio_cmd == BIO_FLUSH && bp->bio_error == EOPNOTSUPP)
+       if ((bp->bio_cmd == BIO_FLUSH || bp->bio_cmd == BIO_SPEEDUP) &&
+           bp->bio_error == EOPNOTSUPP)
                return;
 
        if ((disk->d_flags & G_MIRROR_DISK_FLAG_BROKEN) == 0) {
@@ -988,6 +989,10 @@ g_mirror_regular_request(struct g_mirror_softc *sc, st
                KFAIL_POINT_ERROR(DEBUG_FP, g_mirror_regular_request_flush,
                    bp->bio_error);
                break;
+       case BIO_SPEEDUP:
+               KFAIL_POINT_ERROR(DEBUG_FP, g_mirror_regular_request_speedup,
+                   bp->bio_error);
+               break;
        }
 
        pbp->bio_inbed++;
@@ -1018,6 +1023,7 @@ g_mirror_regular_request(struct g_mirror_softc *sc, st
                case BIO_DELETE:
                case BIO_WRITE:
                case BIO_FLUSH:
+               case BIO_SPEEDUP:
                        pbp->bio_inbed--;
                        pbp->bio_children--;
                        break;
@@ -1043,6 +1049,7 @@ g_mirror_regular_request(struct g_mirror_softc *sc, st
        case BIO_DELETE:
        case BIO_WRITE:
        case BIO_FLUSH:
+       case BIO_SPEEDUP:
                if (pbp->bio_children == 0) {
                        /*
                         * All requests failed.
@@ -1149,6 +1156,7 @@ g_mirror_start(struct bio *bp)
        case BIO_READ:
        case BIO_WRITE:
        case BIO_DELETE:
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
                break;
        case BIO_GETATTR:
@@ -1783,6 +1791,7 @@ g_mirror_register_request(struct g_mirror_softc *sc, s
                 */
                TAILQ_INSERT_TAIL(&sc->sc_inflight, bp, bio_queue);
                return;
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
                TAILQ_INIT(&queue);
                LIST_FOREACH(disk, &sc->sc_disks, d_next) {

Modified: head/sys/geom/nop/g_nop.c
==============================================================================
--- head/sys/geom/nop/g_nop.c   Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/nop/g_nop.c   Fri Jan 17 01:15:55 2020        (r356818)
@@ -255,6 +255,9 @@ g_nop_start(struct bio *bp)
        case BIO_FLUSH:
                sc->sc_flushes++;
                break;
+       case BIO_SPEEDUP:
+               sc->sc_speedups++;
+               break;
        case BIO_CMD0:
                sc->sc_cmd0s++;
                break;
@@ -438,6 +441,7 @@ g_nop_create(struct gctl_req *req, struct g_class *mp,
        sc->sc_deletes = 0;
        sc->sc_getattrs = 0;
        sc->sc_flushes = 0;
+       sc->sc_speedups = 0;
        sc->sc_cmd0s = 0;
        sc->sc_cmd1s = 0;
        sc->sc_cmd2s = 0;
@@ -908,6 +912,7 @@ g_nop_ctl_reset(struct gctl_req *req, struct g_class *
                sc->sc_deletes = 0;
                sc->sc_getattrs = 0;
                sc->sc_flushes = 0;
+               sc->sc_speedups = 0;
                sc->sc_cmd0s = 0;
                sc->sc_cmd1s = 0;
                sc->sc_cmd2s = 0;
@@ -978,6 +983,7 @@ g_nop_dumpconf(struct sbuf *sb, const char *indent, st
        sbuf_printf(sb, "%s<Deletes>%ju</Deletes>\n", indent, sc->sc_deletes);
        sbuf_printf(sb, "%s<Getattrs>%ju</Getattrs>\n", indent, 
sc->sc_getattrs);
        sbuf_printf(sb, "%s<Flushes>%ju</Flushes>\n", indent, sc->sc_flushes);
+       sbuf_printf(sb, "%s<Speedups>%ju</Speedups>\n", indent, 
sc->sc_speedups);
        sbuf_printf(sb, "%s<Cmd0s>%ju</Cmd0s>\n", indent, sc->sc_cmd0s);
        sbuf_printf(sb, "%s<Cmd1s>%ju</Cmd1s>\n", indent, sc->sc_cmd1s);
        sbuf_printf(sb, "%s<Cmd2s>%ju</Cmd2s>\n", indent, sc->sc_cmd2s);

Modified: head/sys/geom/nop/g_nop.h
==============================================================================
--- head/sys/geom/nop/g_nop.h   Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/nop/g_nop.h   Fri Jan 17 01:15:55 2020        (r356818)
@@ -71,6 +71,7 @@ struct g_nop_softc {
        uintmax_t                sc_cmd0s;
        uintmax_t                sc_cmd1s;
        uintmax_t                sc_cmd2s;
+       uintmax_t                sc_speedups;
        uintmax_t                sc_readbytes;
        uintmax_t                sc_wrotebytes;
        char                    *sc_physpath;

Modified: head/sys/geom/part/g_part.c
==============================================================================
--- head/sys/geom/part/g_part.c Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/part/g_part.c Fri Jan 17 01:15:55 2020        (r356818)
@@ -2272,6 +2272,7 @@ g_part_start(struct bio *bp)
                bp2->bio_offset += entry->gpe_offset;
                g_io_request(bp2, cp);
                return;
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
                break;
        case BIO_GETATTR:

Modified: head/sys/geom/raid/g_raid.c
==============================================================================
--- head/sys/geom/raid/g_raid.c Thu Jan 16 22:45:08 2020        (r356817)
+++ head/sys/geom/raid/g_raid.c Fri Jan 17 01:15:55 2020        (r356818)
@@ -1111,6 +1111,7 @@ g_raid_start(struct bio *bp)
        case BIO_WRITE:
        case BIO_DELETE:
        case BIO_FLUSH:
+       case BIO_SPEEDUP:
                break;
        case BIO_GETATTR:
                if (!strcmp(bp->bio_attribute, "GEOM::candelete"))

Modified: head/sys/geom/raid/tr_concat.c
==============================================================================
--- head/sys/geom/raid/tr_concat.c      Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/raid/tr_concat.c      Fri Jan 17 01:15:55 2020        
(r356818)
@@ -224,7 +224,7 @@ g_raid_tr_iostart_concat(struct g_raid_tr_object *tr, 
                g_raid_iodone(bp, EIO);
                return;
        }
-       if (bp->bio_cmd == BIO_FLUSH) {
+       if (bp->bio_cmd == BIO_FLUSH || bp->bio_cmd == BIO_SPEEDUP) {
                g_raid_tr_flush_common(tr, bp);
                return;
        }

Modified: head/sys/geom/raid/tr_raid0.c
==============================================================================
--- head/sys/geom/raid/tr_raid0.c       Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/raid/tr_raid0.c       Fri Jan 17 01:15:55 2020        
(r356818)
@@ -204,7 +204,7 @@ g_raid_tr_iostart_raid0(struct g_raid_tr_object *tr, s
                g_raid_iodone(bp, EIO);
                return;
        }
-       if (bp->bio_cmd == BIO_FLUSH) {
+       if (bp->bio_cmd == BIO_FLUSH || bp->bio_cmd == BIO_SPEEDUP) {
                g_raid_tr_flush_common(tr, bp);
                return;
        }

Modified: head/sys/geom/raid/tr_raid1.c
==============================================================================
--- head/sys/geom/raid/tr_raid1.c       Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/raid/tr_raid1.c       Fri Jan 17 01:15:55 2020        
(r356818)
@@ -641,6 +641,7 @@ g_raid_tr_iostart_raid1(struct g_raid_tr_object *tr, s
        case BIO_DELETE:
                g_raid_tr_iostart_raid1_write(tr, bp);
                break;
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
                g_raid_tr_flush_common(tr, bp);
                break;

Modified: head/sys/geom/raid/tr_raid1e.c
==============================================================================
--- head/sys/geom/raid/tr_raid1e.c      Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/raid/tr_raid1e.c      Fri Jan 17 01:15:55 2020        
(r356818)
@@ -869,6 +869,7 @@ g_raid_tr_iostart_raid1e(struct g_raid_tr_object *tr, 
        case BIO_DELETE:
                g_raid_tr_iostart_raid1e_write(tr, bp);
                break;
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
                g_raid_tr_flush_common(tr, bp);
                break;

Modified: head/sys/geom/raid/tr_raid5.c
==============================================================================
--- head/sys/geom/raid/tr_raid5.c       Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/raid/tr_raid5.c       Fri Jan 17 01:15:55 2020        
(r356818)
@@ -357,6 +357,7 @@ g_raid_tr_iostart_raid5(struct g_raid_tr_object *tr, s
        case BIO_WRITE:
        case BIO_DELETE:
        case BIO_FLUSH:
+       case BIO_SPEEDUP:
                g_raid_iodone(bp, ENODEV);
                break;
        default:

Modified: head/sys/geom/raid3/g_raid3.c
==============================================================================
--- head/sys/geom/raid3/g_raid3.c       Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/raid3/g_raid3.c       Fri Jan 17 01:15:55 2020        
(r356818)
@@ -1446,6 +1446,7 @@ g_raid3_start(struct bio *bp)
        case BIO_WRITE:
        case BIO_DELETE:
                break;
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
                g_raid3_flush(sc, bp);
                return;

Modified: head/sys/geom/shsec/g_shsec.c
==============================================================================
--- head/sys/geom/shsec/g_shsec.c       Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/shsec/g_shsec.c       Fri Jan 17 01:15:55 2020        
(r356818)
@@ -316,6 +316,7 @@ g_shsec_start(struct bio *bp)
        case BIO_READ:
        case BIO_WRITE:
        case BIO_FLUSH:
+       case BIO_SPEEDUP:
                /*
                 * Only those requests are supported.
                 */

Modified: head/sys/geom/stripe/g_stripe.c
==============================================================================
--- head/sys/geom/stripe/g_stripe.c     Thu Jan 16 22:45:08 2020        
(r356817)
+++ head/sys/geom/stripe/g_stripe.c     Fri Jan 17 01:15:55 2020        
(r356818)
@@ -535,7 +535,7 @@ failure:
 }
 
 static void
-g_stripe_flush(struct g_stripe_softc *sc, struct bio *bp)
+g_stripe_pushdown(struct g_stripe_softc *sc, struct bio *bp)
 {
        struct bio_queue_head queue;
        struct g_consumer *cp;
@@ -594,8 +594,9 @@ g_stripe_start(struct bio *bp)
        case BIO_WRITE:
        case BIO_DELETE:
                break;
+       case BIO_SPEEDUP:
        case BIO_FLUSH:
-               g_stripe_flush(sc, bp);
+               g_stripe_pushdown(sc, bp);
                return;
        case BIO_GETATTR:
                /* To which provider it should be delivered? */
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to