Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1187436pxb; Wed, 16 Feb 2022 13:04:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1rrqTI/idg3qHJ1NgU5jv15mWSo5onvonJU4OX/nbFwX+xrAEZAhH/bIy7Wr6MKrCmJFV X-Received: by 2002:a17:906:344b:b0:6ce:e64e:1b09 with SMTP id d11-20020a170906344b00b006cee64e1b09mr3715484ejb.54.1645045469280; Wed, 16 Feb 2022 13:04:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645045469; cv=none; d=google.com; s=arc-20160816; b=LwVEYfsgbEqGhGETXmzTP8EJeWgUUWGEaFROaaPazIfU0bts9lmUlg3prAjXWCH/DO JhDkLxsgU1EMCIg7hoLS70yascao8ACMQoovbQMToaLZk2tbXwxvTOh9/Q3dL5C8txf+ iAiV4f2C0lGRUZskrr31o5Ro43llpD7LaOtTVdeBfQFgKVdGu3hDcAMFt1FLYy3bBE/j 3W51Krb1C+klbMX8rz76S/f+RAZsxM5E9kbfP0pCtWmgLKRh3FzvtQ/xDu7oPrlCi8zu tXPuAYJotnTJWqxmDaG+QPt4BOzGDkOmBKC6A+dd1xKsapx3014EDhsfPWlaDAD1b9W6 akLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=I5FGz9UopDmOr/sS+hUAyFgI3PwHIeG5FXWhjwGlyJI=; b=W71hNhsAIqOYBrAk2kK2CBAf+JYPj+hJrL7lzZ18xk63i81oRQGbL6/+LcYLU9JVOb 2zyvD8q7z2iFIgTnA+Ii80kgy5zK1hq1HeX0sd+d1PD5QP4aGRleVB6BcDnKzobf1mxe 4MVowN/9GU11wC9vsElj0BVLxzaWk4V5NFOQwFQMLkLLDULJ8a7hBmnpuJAqdoH2bqnH k/3NlY+MrGUaDK00KYQW2lkUBhTJOhpBCSnYYUTgnuG8//mO4GkVDUJ1SFK1gPKXyTSU GkXjUg1Vx89JcluBaxuQdQfsRLKPG+k7frBTv7q53zvh5aqnuIqD5tZejucPqXfBN9tv +LAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GcZdvida; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16si2671175edd.426.2022.02.16.13.04.06; Wed, 16 Feb 2022 13:04:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GcZdvida; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236830AbiBPRBx (ORCPT + 99 others); Wed, 16 Feb 2022 12:01:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236457AbiBPRBw (ORCPT ); Wed, 16 Feb 2022 12:01:52 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44F3894965 for ; Wed, 16 Feb 2022 09:01:39 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id q8so445552iod.2 for ; Wed, 16 Feb 2022 09:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=I5FGz9UopDmOr/sS+hUAyFgI3PwHIeG5FXWhjwGlyJI=; b=GcZdvidaiUJh4QJe+8knJfUEKZ0kHu1Ekr7Fo/prc3WQlwk5azLOhn2N99tiJ9KyqC BRkRSS3c9Dqv7LlyetYkHxm1DUijOeBruzahYgv4QAUclx4iFN1jef3U+Lv1YU6WveS2 0LyiMYhUsTil26XK8Vw7ZyqH/3QPg21CoHIHEW97CgZzYZacGpLar/wPlxeUgji34ELu cc3fNOn8UudSzs1eZT9yUYDDcL31fxZyor0Hly0uxoXwxw548ce+RVQ+SQdanEzwrFRn PCsU77mVX/1LvHrMZs8uieuHXsc7loALHhc7rZu06F+9nuAPHEMkizvNdmela1m/Uzf5 Jy1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=I5FGz9UopDmOr/sS+hUAyFgI3PwHIeG5FXWhjwGlyJI=; b=DjqLqzCg/eG35a4vIUX7+GU/HNSG6BgRCyDTPw1orzzLZaKClFNvss99+EccxmDjCe 6DZe3xHyvxzW8CULp4diceZib0pbSSlTGZ7mQQI2wt6IcZKKUa5TV4pYM7U1icfPRz5d U7sg6yxuxne2PTpn3Lt+wIgw8Rb7ex6hcYZBDWomKP00YCHd0UGU0KEV3O5UiEicuZO0 MMr7s4lsQJDpc0N4R+pcLcfQdRrYCfPD7PWs5qtsTBPmJJg0fatHPvd7XooF+jP2+A/O vVCkrnewXOYFWSySvSQGlrzH18dW8xVroWD58bwkqWwsHnmKYBh8g5wPgzF6kK/dHHbq abfQ== X-Gm-Message-State: AOAM533qgYPTcFlJGUpwIubU/sHqYvgFjlux+dO/OCQjJIuS6D3UA1t6 F65Ln6CmZ4r3zn9bFWnIA5B8CsXRw2pHIF+vCRw= X-Received: by 2002:a5e:8c15:0:b0:634:478e:450e with SMTP id n21-20020a5e8c15000000b00634478e450emr2495232ioj.56.1645030898651; Wed, 16 Feb 2022 09:01:38 -0800 (PST) MIME-Version: 1.0 References: <20220111161937.56272-1-pankaj.gupta.linux@gmail.com> <20220111161937.56272-3-pankaj.gupta.linux@gmail.com> In-Reply-To: From: Pankaj Gupta Date: Wed, 16 Feb 2022 18:01:27 +0100 Message-ID: Subject: Re: [RFC v3 2/2] pmem: enable pmem_submit_bio for asynchronous flush To: Dan Williams Cc: Linux NVDIMM , virtualization@lists.linux-foundation.org, Linux Kernel Mailing List , jmoyer , Stefan Hajnoczi , David Hildenbrand , "Michael S. Tsirkin" , Cornelia Huck , Vishal L Verma , Dave Jiang , "Weiny, Ira" , Pankaj Gupta Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > Return from "pmem_submit_bio" when asynchronous flush is > > > > still in progress in other context. > > > > > > > > Signed-off-by: Pankaj Gupta > > > > --- > > > > 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? > > Ok, maybe a comment to indicate the need to avoid exposing these error > codes toa guest so someone does not ask the same question in the > future? Sure. Thanks, Pankaj