diff mbox

[v2,8/9] xen/9pfs: send responses back to the frontend

Message ID 1489449360-14411-8-git-send-email-sstabellini@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Stefano Stabellini March 13, 2017, 11:55 p.m. UTC
Once a request is completed, xen_9pfs_push_and_notify gets called. In
xen_9pfs_push_and_notify, update the indexes (data has already been
copied to the sg by the common code) and send a notification to the
frontend.

Schedule the bottom-half to check if we already have any other requests
pending.

Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
CC: anthony.perard@citrix.com
CC: jgross@suse.com
CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
CC: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/xen-9p-backend.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Greg Kurz March 15, 2017, 10:59 a.m. UTC | #1
On Mon, 13 Mar 2017 16:55:59 -0700
Stefano Stabellini <sstabellini@kernel.org> wrote:

> Once a request is completed, xen_9pfs_push_and_notify gets called. In
> xen_9pfs_push_and_notify, update the indexes (data has already been
> copied to the sg by the common code) and send a notification to the
> frontend.
> 
> Schedule the bottom-half to check if we already have any other requests
> pending.
> 
> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> CC: anthony.perard@citrix.com
> CC: jgross@suse.com
> CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> CC: Greg Kurz <groug@kaod.org>
> ---
>  hw/9pfs/xen-9p-backend.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> index d72a749..fed369f 100644
> --- a/hw/9pfs/xen-9p-backend.c
> +++ b/hw/9pfs/xen-9p-backend.c
> @@ -166,6 +166,22 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
>  
>  static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
>  {
> +    RING_IDX prod;
> +    struct Xen9pfsDev *priv = container_of(pdu->s, struct Xen9pfsDev, state);
> +    struct Xen9pfsRing *ring = &priv->rings[pdu->tag % priv->num_rings];
> +

Coding style for structured types.

> +    ring->intf->out_cons = ring->out_cons;
> +    xen_wmb();
> +
> +    prod = ring->intf->in_prod;
> +    xen_rmb();
> +    ring->intf->in_prod = prod + pdu->size;
> +    xen_wmb();
> +
> +    ring->inprogress = false;
> +    xenevtchn_notify(ring->evtchndev, ring->local_port);
> +
> +    qemu_bh_schedule(ring->bh);
>  }
>  
>  static const struct V9fsTransport xen_9p_transport = {
Stefano Stabellini March 15, 2017, 9:59 p.m. UTC | #2
On Wed, 15 Mar 2017, Greg Kurz wrote:
> On Mon, 13 Mar 2017 16:55:59 -0700
> Stefano Stabellini <sstabellini@kernel.org> wrote:
> 
> > Once a request is completed, xen_9pfs_push_and_notify gets called. In
> > xen_9pfs_push_and_notify, update the indexes (data has already been
> > copied to the sg by the common code) and send a notification to the
> > frontend.
> > 
> > Schedule the bottom-half to check if we already have any other requests
> > pending.
> > 
> > Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> > CC: anthony.perard@citrix.com
> > CC: jgross@suse.com
> > CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> > CC: Greg Kurz <groug@kaod.org>
> > ---
> >  hw/9pfs/xen-9p-backend.c | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> > index d72a749..fed369f 100644
> > --- a/hw/9pfs/xen-9p-backend.c
> > +++ b/hw/9pfs/xen-9p-backend.c
> > @@ -166,6 +166,22 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
> >  
> >  static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
> >  {
> > +    RING_IDX prod;
> > +    struct Xen9pfsDev *priv = container_of(pdu->s, struct Xen9pfsDev, state);
> > +    struct Xen9pfsRing *ring = &priv->rings[pdu->tag % priv->num_rings];
> > +
> 
> Coding style for structured types.

Yep



> > +    ring->intf->out_cons = ring->out_cons;
> > +    xen_wmb();
> > +
> > +    prod = ring->intf->in_prod;
> > +    xen_rmb();
> > +    ring->intf->in_prod = prod + pdu->size;
> > +    xen_wmb();
> > +
> > +    ring->inprogress = false;
> > +    xenevtchn_notify(ring->evtchndev, ring->local_port);
> > +
> > +    qemu_bh_schedule(ring->bh);
> >  }
> >  
> >  static const struct V9fsTransport xen_9p_transport = {
> 
>
diff mbox

Patch

diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index d72a749..fed369f 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -166,6 +166,22 @@  static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
 
 static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
 {
+    RING_IDX prod;
+    struct Xen9pfsDev *priv = container_of(pdu->s, struct Xen9pfsDev, state);
+    struct Xen9pfsRing *ring = &priv->rings[pdu->tag % priv->num_rings];
+
+    ring->intf->out_cons = ring->out_cons;
+    xen_wmb();
+
+    prod = ring->intf->in_prod;
+    xen_rmb();
+    ring->intf->in_prod = prod + pdu->size;
+    xen_wmb();
+
+    ring->inprogress = false;
+    xenevtchn_notify(ring->evtchndev, ring->local_port);
+
+    qemu_bh_schedule(ring->bh);
 }
 
 static const struct V9fsTransport xen_9p_transport = {