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

Re: [PATCH v3 1/3] xen/blkfront: read response from backend only once


  • To: Juergen Gross <jgross@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "linux-block@xxxxxxxxxxxxxxx" <linux-block@xxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Mon, 2 Aug 2021 14:06:06 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TXcguFnSot8XXc0tG5EG1IN+iJ1WUv7tqRfpX4JufOo=; b=UERGr1akvw75tI5rhJt4PgbskDWUNn97kuEjtRVdQGL8woKvwH6SxmkxKOKtMbH8J7GAyJ8/BOTe6IbxO8df/GNwyIsGp0WcD39NwFeiyHLZsngXbvekmsS2ixyYJjqaEWW/QLGHsNlS1wuRc6AdcEmQd652yxW8FngvSaKnZY5GRMeK1G0ttodSBqadjLC/eQ/GXRkQDEZA+w3sh8kxAp7t7K9cTc1VtlqYkgb/s98opcOMrR/phucTA85Mfk6+imr9KQLU0tala54a3DOr8yYQw65K28+N3iEwL8tS+0rcVZ/j+Ot6W3yyJEcJNaFCBH2zvNA0ZPD7OTfXwTi5RA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kw5KuHtgQPay1jFq137aDdagf2wTe4G3BsAduIADuv2HdguSi8Chl4egyjMvBAhTurkFW6a1eN1MO1SvzE5+lFUXkwdENG3ad0EQtLJOb/9qCL277hyyUyVl2wtzOUJCMExMIC4vx6qFdXaVWRcw1clw7/zKhkmPvgfJ3gxdci3xf+ItHppePWCEIWe8Xe5HN7/STIVFouJmTYf/vGeFEgphTUIZciHeLZ/2EZE/thFhQKt6x0w+tgUPFuQETcWu93i+ONrP1Fa02O++mCL3eQOKemDvcxAoGIy4NmS6WjmV7VWYckJ1Gd5Nc9LrMxM2/lxbTRQWNHJk/IdC0V1wgw==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=epam.com;
  • Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jens Axboe <axboe@xxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Mon, 02 Aug 2021 14:06:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXh6eJ91LWa/O//ESEGVadZuHLeQ==
  • Thread-topic: [PATCH v3 1/3] xen/blkfront: read response from backend only once

Hi, Juergen!

On 30.07.21 13:38, Juergen Gross wrote:
> In order to avoid problems in case the backend is modifying a response
> on the ring page while the frontend has already seen it, just read the
> response into a local buffer in one go and then operate on that buffer
> only.
>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
>   drivers/block/xen-blkfront.c | 35 ++++++++++++++++++-----------------
>   1 file changed, 18 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index d83fee21f6c5..15e840287734 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -1496,7 +1496,7 @@ static bool blkif_completion(unsigned long *id,
>   static irqreturn_t blkif_interrupt(int irq, void *dev_id)
>   {
>       struct request *req;
> -     struct blkif_response *bret;
> +     struct blkif_response bret;
>       RING_IDX i, rp;
>       unsigned long flags;
>       struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)dev_id;
> @@ -1513,8 +1513,9 @@ static irqreturn_t blkif_interrupt(int irq, void 
> *dev_id)
>       for (i = rinfo->ring.rsp_cons; i != rp; i++) {
>               unsigned long id;
>   
> -             bret = RING_GET_RESPONSE(&rinfo->ring, i);
> -             id   = bret->id;
> +             RING_COPY_RESPONSE(&rinfo->ring, i, &bret);

As per my understanding copying is still not an atomic operation as the 
request/response

are multi-byte structures in general. IOW, what prevents the backend from 
modifying the ring while

we are copying?

Thanks,

Oleksandr

> +             id = bret.id;
> +
>               /*
>                * The backend has messed up and given us an id that we would
>                * never have given to it (we stamp it up to BLK_RING_SIZE -
> @@ -1522,39 +1523,39 @@ static irqreturn_t blkif_interrupt(int irq, void 
> *dev_id)
>                */
>               if (id >= BLK_RING_SIZE(info)) {
>                       WARN(1, "%s: response to %s has incorrect id (%ld)\n",
> -                          info->gd->disk_name, op_name(bret->operation), id);
> +                          info->gd->disk_name, op_name(bret.operation), id);
>                       /* We can't safely get the 'struct request' as
>                        * the id is busted. */
>                       continue;
>               }
>               req  = rinfo->shadow[id].request;
>   
> -             if (bret->operation != BLKIF_OP_DISCARD) {
> +             if (bret.operation != BLKIF_OP_DISCARD) {
>                       /*
>                        * We may need to wait for an extra response if the
>                        * I/O request is split in 2
>                        */
> -                     if (!blkif_completion(&id, rinfo, bret))
> +                     if (!blkif_completion(&id, rinfo, &bret))
>                               continue;
>               }
>   
>               if (add_id_to_freelist(rinfo, id)) {
>                       WARN(1, "%s: response to %s (id %ld) couldn't be 
> recycled!\n",
> -                          info->gd->disk_name, op_name(bret->operation), id);
> +                          info->gd->disk_name, op_name(bret.operation), id);
>                       continue;
>               }
>   
> -             if (bret->status == BLKIF_RSP_OKAY)
> +             if (bret.status == BLKIF_RSP_OKAY)
>                       blkif_req(req)->error = BLK_STS_OK;
>               else
>                       blkif_req(req)->error = BLK_STS_IOERR;
>   
> -             switch (bret->operation) {
> +             switch (bret.operation) {
>               case BLKIF_OP_DISCARD:
> -                     if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) {
> +                     if (unlikely(bret.status == BLKIF_RSP_EOPNOTSUPP)) {
>                               struct request_queue *rq = info->rq;
>                               printk(KERN_WARNING "blkfront: %s: %s op 
> failed\n",
> -                                        info->gd->disk_name, 
> op_name(bret->operation));
> +                                        info->gd->disk_name, 
> op_name(bret.operation));
>                               blkif_req(req)->error = BLK_STS_NOTSUPP;
>                               info->feature_discard = 0;
>                               info->feature_secdiscard = 0;
> @@ -1564,15 +1565,15 @@ static irqreturn_t blkif_interrupt(int irq, void 
> *dev_id)
>                       break;
>               case BLKIF_OP_FLUSH_DISKCACHE:
>               case BLKIF_OP_WRITE_BARRIER:
> -                     if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) {
> +                     if (unlikely(bret.status == BLKIF_RSP_EOPNOTSUPP)) {
>                               printk(KERN_WARNING "blkfront: %s: %s op 
> failed\n",
> -                                    info->gd->disk_name, 
> op_name(bret->operation));
> +                                    info->gd->disk_name, 
> op_name(bret.operation));
>                               blkif_req(req)->error = BLK_STS_NOTSUPP;
>                       }
> -                     if (unlikely(bret->status == BLKIF_RSP_ERROR &&
> +                     if (unlikely(bret.status == BLKIF_RSP_ERROR &&
>                                    rinfo->shadow[id].req.u.rw.nr_segments == 
> 0)) {
>                               printk(KERN_WARNING "blkfront: %s: empty %s op 
> failed\n",
> -                                    info->gd->disk_name, 
> op_name(bret->operation));
> +                                    info->gd->disk_name, 
> op_name(bret.operation));
>                               blkif_req(req)->error = BLK_STS_NOTSUPP;
>                       }
>                       if (unlikely(blkif_req(req)->error)) {
> @@ -1585,9 +1586,9 @@ static irqreturn_t blkif_interrupt(int irq, void 
> *dev_id)
>                       fallthrough;
>               case BLKIF_OP_READ:
>               case BLKIF_OP_WRITE:
> -                     if (unlikely(bret->status != BLKIF_RSP_OKAY))
> +                     if (unlikely(bret.status != BLKIF_RSP_OKAY))
>                               dev_dbg(&info->xbdev->dev, "Bad return from 
> blkdev data "
> -                                     "request: %x\n", bret->status);
> +                                     "request: %x\n", bret.status);
>   
>                       break;
>               default:

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.