linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Linux NVDIMM <nvdimm@lists.linux.dev>,
	virtualization@lists.linux-foundation.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	jmoyer <jmoyer@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Vishal L Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	"Weiny, Ira" <ira.weiny@intel.com>,
	Pankaj Gupta <pankaj.gupta@ionos.com>
Subject: Re: [RFC v3 2/2] pmem: enable pmem_submit_bio for asynchronous flush
Date: Wed, 16 Feb 2022 09:39:09 +0100	[thread overview]
Message-ID: <CAM9Jb+iYXn+Diq-vou+_hXdxXLR9rEXm6GOsd2tZpAg9zXn1Fw@mail.gmail.com> (raw)
In-Reply-To: <CAPcyv4gM99M8Waw9uEZefvpK0BsTkjGznLxUOMcMkGpk6SuHyA@mail.gmail.com>

> >
> > Return from "pmem_submit_bio" when asynchronous flush is
> > still in progress in other context.
> >
> > Signed-off-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
> > ---
> >  drivers/nvdimm/pmem.c        | 15 ++++++++++++---
> >  drivers/nvdimm/region_devs.c |  4 +++-
> >  2 files changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> > index fe7ece1534e1..f20e30277a68 100644
> > --- a/drivers/nvdimm/pmem.c
> > +++ b/drivers/nvdimm/pmem.c
> > @@ -201,8 +201,12 @@ static void pmem_submit_bio(struct bio *bio)
> >         struct pmem_device *pmem = bio->bi_bdev->bd_disk->private_data;
> >         struct nd_region *nd_region = to_region(pmem);
> >
> > -       if (bio->bi_opf & REQ_PREFLUSH)
> > +       if (bio->bi_opf & REQ_PREFLUSH) {
> >                 ret = nvdimm_flush(nd_region, bio);
> > +               /* asynchronous flush completes in other context */
>
> I think a negative error code is a confusing way to capture the case
> of "bio successfully coalesced to previously pending flush request.
> Perhaps reserve negative codes for failure, 0 for synchronously
> completed, and > 0 for coalesced flush request.

Yes. I implemented this way previously, will revert it to. Thanks!

>
> > +               if (ret == -EINPROGRESS)
> > +                       return;
> > +       }
> >
> >         do_acct = blk_queue_io_stat(bio->bi_bdev->bd_disk->queue);
> >         if (do_acct)
> > @@ -222,13 +226,18 @@ static void pmem_submit_bio(struct bio *bio)
> >         if (do_acct)
> >                 bio_end_io_acct(bio, start);
> >
> > -       if (bio->bi_opf & REQ_FUA)
> > +       if (bio->bi_opf & REQ_FUA) {
> >                 ret = nvdimm_flush(nd_region, bio);
> > +               /* asynchronous flush completes in other context */
> > +               if (ret == -EINPROGRESS)
> > +                       return;
> > +       }
> >
> >         if (ret)
> >                 bio->bi_status = errno_to_blk_status(ret);
> >
> > -       bio_endio(bio);
> > +       if (bio)
> > +               bio_endio(bio);
> >  }
> >
> >  static int pmem_rw_page(struct block_device *bdev, sector_t sector,
> > diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> > index 9ccf3d608799..8512d2eaed4e 100644
> > --- a/drivers/nvdimm/region_devs.c
> > +++ b/drivers/nvdimm/region_devs.c
> > @@ -1190,7 +1190,9 @@ int nvdimm_flush(struct nd_region *nd_region, struct bio *bio)
> >         if (!nd_region->flush)
> >                 rc = generic_nvdimm_flush(nd_region);
> >         else {
> > -               if (nd_region->flush(nd_region, bio))
> > +               rc = nd_region->flush(nd_region, bio);
> > +               /* ongoing flush in other context */
> > +               if (rc && rc != -EINPROGRESS)
> >                         rc = -EIO;
>
> Why change this to -EIO vs just let the error code through untranslated?

The reason was to be generic error code instead of returning host side
return codes to guest?

Thanks!
Pankaj
>
> >         }
> >
> > --
> > 2.25.1
> >
> >

  reply	other threads:[~2022-02-16  8:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11 16:19 [RFC v3 0/2] virtio-pmem: Asynchronous flush Pankaj Gupta
2022-01-11 16:19 ` [RFC v3 1/2] virtio-pmem: Async virtio-pmem flush Pankaj Gupta
2022-02-16  3:21   ` Dan Williams
2022-02-16  8:47     ` Pankaj Gupta
2022-02-16 16:23       ` Dan Williams
2022-02-16 17:04         ` Pankaj Gupta
2022-01-11 16:19 ` [RFC v3 2/2] pmem: enable pmem_submit_bio for asynchronous flush Pankaj Gupta
2022-02-16  3:34   ` Dan Williams
2022-02-16  8:39     ` Pankaj Gupta [this message]
2022-02-16 16:25       ` Dan Williams
2022-02-16 17:01         ` Pankaj Gupta
2022-01-28 10:11 ` [RFC v3 0/2] virtio-pmem: Asynchronous flush Pankaj Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM9Jb+iYXn+Diq-vou+_hXdxXLR9rEXm6GOsd2tZpAg9zXn1Fw@mail.gmail.com \
    --to=pankaj.gupta.linux@gmail.com \
    --cc=cohuck@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=david@redhat.com \
    --cc=ira.weiny@intel.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=pankaj.gupta@ionos.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).