]> Pileus Git - ~andy/linux/commitdiff
tcm_vhost: document inflight ref-counting use
authorMichael S. Tsirkin <mst@redhat.com>
Sun, 28 Apr 2013 12:38:52 +0000 (15:38 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 1 May 2013 07:02:52 +0000 (10:02 +0300)
Add more comments so we remember not to break it
next time we change things.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/tcm_vhost.c

index afb530887936a7cf20b75f48d37d62f1f1d7383b..96d3b47c82cd0c8750f519545a97b1958e2802ab 100644 (file)
@@ -83,9 +83,16 @@ struct vhost_scsi_inflight {
 
 struct vhost_scsi_virtqueue {
        struct vhost_virtqueue vq;
-       /* Track inflight reqs, protected by vq->mutex */
+       /*
+        * Reference counting for inflight reqs, used for flush operation. At
+        * each time, one reference tracks new commands submitted, while we
+        * wait for another one to reach 0.
+        */
        struct vhost_scsi_inflight inflights[2];
-       /* Indicate current inflight in use, protected by vq->mutex */
+       /*
+        * Indicate current inflight in use, protected by vq->mutex.
+        * Writers must also take dev mutex and flush under it.
+        */
        int inflight_idx;
 };
 
@@ -1015,6 +1022,7 @@ static void vhost_scsi_flush_vq(struct vhost_scsi *vs, int index)
        vhost_poll_flush(&vs->vqs[index].vq.poll);
 }
 
+/* Callers must hold dev mutex */
 static void vhost_scsi_flush(struct vhost_scsi *vs)
 {
        struct vhost_scsi_inflight *old_inflight[VHOST_SCSI_MAX_VQ];