Re: svn commit: r277788 - head/sys/dev/virtio/block

2015-01-26 Thread Mark Johnston
On Tue, Jan 27, 2015 at 05:34:47AM +, Bryan Venteicher wrote:
 Author: bryanv
 Date: Tue Jan 27 05:34:46 2015
 New Revision: 277788
 URL: https://svnweb.freebsd.org/changeset/base/277788
 
 Log:
   Rework vtblk dump handling of in flight requests
   
   Previously, the driver resets the device and abandon the requests that
   are caught in flight when the dump was initiated. This was problematic
   if the system is resumed after the dump is completed.
   
   While that is probably not the typical action, it is simple to rework
   the driver to very likely have the device usable after the dump without
   making it more likely for the dump to fail. The in flight requests are
   simply queued for completion once the dump is finished.
   
   Requested by:   markj
   MFC after:  1 month

Thank you!
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r277788 - head/sys/dev/virtio/block

2015-01-26 Thread Bryan Venteicher
Author: bryanv
Date: Tue Jan 27 05:34:46 2015
New Revision: 277788
URL: https://svnweb.freebsd.org/changeset/base/277788

Log:
  Rework vtblk dump handling of in flight requests
  
  Previously, the driver resets the device and abandon the requests that
  are caught in flight when the dump was initiated. This was problematic
  if the system is resumed after the dump is completed.
  
  While that is probably not the typical action, it is simple to rework
  the driver to very likely have the device usable after the dump without
  making it more likely for the dump to fail. The in flight requests are
  simply queued for completion once the dump is finished.
  
  Requested by: markj
  MFC after:1 month

Modified:
  head/sys/dev/virtio/block/virtio_blk.c

Modified: head/sys/dev/virtio/block/virtio_blk.c
==
--- head/sys/dev/virtio/block/virtio_blk.c  Tue Jan 27 04:06:47 2015
(r277787)
+++ head/sys/dev/virtio/block/virtio_blk.c  Tue Jan 27 05:34:46 2015
(r277788)
@@ -76,9 +76,8 @@ struct vtblk_softc {
 #define VTBLK_FLAG_READONLY0x0002
 #define VTBLK_FLAG_DETACH  0x0004
 #define VTBLK_FLAG_SUSPEND 0x0008
-#define VTBLK_FLAG_DUMPING 0x0010
-#define VTBLK_FLAG_BARRIER 0x0020
-#define VTBLK_FLAG_WC_CONFIG   0x0040
+#define VTBLK_FLAG_BARRIER 0x0010
+#define VTBLK_FLAG_WC_CONFIG   0x0020
 
struct virtqueue*vtblk_vq;
struct sglist   *vtblk_sglist;
@@ -95,6 +94,7 @@ struct vtblk_softc {
int  vtblk_request_count;
enum vtblk_cache_modevtblk_write_cache;
 
+   struct bio_queue vtblk_dump_queue;
struct vtblk_request vtblk_dump_request;
 };
 
@@ -162,7 +162,7 @@ static void vtblk_queue_completed(struct
struct bio_queue *);
 static voidvtblk_done_completed(struct vtblk_softc *,
struct bio_queue *);
-static voidvtblk_drain_vq(struct vtblk_softc *, int);
+static voidvtblk_drain_vq(struct vtblk_softc *);
 static voidvtblk_drain(struct vtblk_softc *);
 
 static voidvtblk_startio(struct vtblk_softc *);
@@ -177,9 +177,10 @@ static int vtblk_quiesce(struct vtblk_so
 static voidvtblk_vq_intr(void *);
 static voidvtblk_stop(struct vtblk_softc *);
 
-static voidvtblk_dump_prepare(struct vtblk_softc *);
+static voidvtblk_dump_quiesce(struct vtblk_softc *);
 static int vtblk_dump_write(struct vtblk_softc *, void *, off_t, size_t);
 static int vtblk_dump_flush(struct vtblk_softc *);
+static voidvtblk_dump_complete(struct vtblk_softc *);
 
 static voidvtblk_set_write_cache(struct vtblk_softc *, int);
 static int vtblk_write_cache_enabled(struct vtblk_softc *sc,
@@ -302,6 +303,7 @@ vtblk_attach(device_t dev)
sc-vtblk_dev = dev;
VTBLK_LOCK_INIT(sc, device_get_nameunit(dev));
bioq_init(sc-vtblk_bioq);
+   TAILQ_INIT(sc-vtblk_dump_queue);
TAILQ_INIT(sc-vtblk_req_free);
TAILQ_INIT(sc-vtblk_req_ready);
 
@@ -506,25 +508,19 @@ vtblk_dump(void *arg, void *virtual, vm_
int error;
 
dp = arg;
+   error = 0;
 
if ((sc = dp-d_drv1) == NULL)
return (ENXIO);
 
VTBLK_LOCK(sc);
 
-   if ((sc-vtblk_flags  VTBLK_FLAG_DUMPING) == 0) {
-   vtblk_dump_prepare(sc);
-   sc-vtblk_flags |= VTBLK_FLAG_DUMPING;
-   }
+   vtblk_dump_quiesce(sc);
 
if (length  0)
error = vtblk_dump_write(sc, virtual, offset, length);
-   else if (virtual == NULL  offset == 0)
-   error = vtblk_dump_flush(sc);
-   else {
-   error = EINVAL;
-   sc-vtblk_flags = ~VTBLK_FLAG_DUMPING;
-   }
+   if (error || (virtual == NULL  offset == 0))
+   vtblk_dump_complete(sc);
 
VTBLK_UNLOCK(sc);
 
@@ -996,7 +992,7 @@ vtblk_done_completed(struct vtblk_softc 
 }
 
 static void
-vtblk_drain_vq(struct vtblk_softc *sc, int skip_done)
+vtblk_drain_vq(struct vtblk_softc *sc)
 {
struct virtqueue *vq;
struct vtblk_request *req;
@@ -1006,9 +1002,7 @@ vtblk_drain_vq(struct vtblk_softc *sc, i
last = 0;
 
while ((req = virtqueue_drain(vq, last)) != NULL) {
-   if (!skip_done)
-   vtblk_bio_done(sc, req-vbr_bp, ENXIO);
-
+   vtblk_bio_done(sc, req-vbr_bp, ENXIO);
vtblk_request_enqueue(sc, req);
}
 
@@ -1031,7 +1025,7 @@ vtblk_drain(struct vtblk_softc *sc)
vtblk_queue_completed(sc, queue);
vtblk_done_completed(sc, queue);
 
-   vtblk_drain_vq(sc, 0);
+   vtblk_drain_vq(sc);
}
 
while ((req = vtblk_request_next_ready(sc)) != NULL) {
@@ -1256,31 +1250,16 @@ vtblk_stop(struct vtblk_softc *sc)
 }
 
 static void
-vtblk_dump_prepare(struct vtblk_softc *sc)
+vtblk_dump_quiesce(struct vtblk_softc *sc)
 {
-