Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5972863yba; Thu, 11 Apr 2019 09:23:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/1n83Q7JoAX6ilaLFIfsUtXCDwmPQYJotTm3QO26gqKescgoEAB915JU+L0hrWcJbRrWi X-Received: by 2002:a63:7d03:: with SMTP id y3mr47788639pgc.8.1554999838422; Thu, 11 Apr 2019 09:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554999838; cv=none; d=google.com; s=arc-20160816; b=Uai+RfeX/FBJE99bguOWc1Lj5IWsOw5cjb1+wvXuHvkNrlgeytj2mJWinujEMacQ1v yRuc8aDAJxouE3vh+nZYgcBXLuNPVq3IiZsEVUmsskuEtEREICopbDzZNMAsi3a3lx2N c85zLTniXRViAcZpKrboPlquIxGJWiJ2Bdov85MbW3eeScyt4DrAKOOnaSiE2QdfSLxB 6o4H+06mPwY0VLiH2Bt68WmYdb6Ou6+eRqbjTljW9YZhFdtfajJm6al3kQwsCEa/1+Z3 Yv/wg3IqthqFXKCirX+hdcQnSe1Hv3I9Rsp333uAqRpyXjsuoaamtibDY5V1NRmJ6DPk UlAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=cPieg7xKiJOVNsvMbzfjiv4JmCjt6yT6diH0gINsuXI=; b=m0k2m6W06ImLYZl8U/YkD5NTCPq5gqeOkxKygrQ7zXyAuqEpluvXvCFmdNwM4ntNh4 aotKj5poXWaFPLplMqTZmtesRLmvaJto9Yt4tItbF4qGW3yL1QsQcKXRqrJT+/MzXmlV FtujPLf2CUNuuSw/zLWzfswE/kDQOjPq08KC5zbD4rTSekZbF/6TubrMQxCZkcD83D+V 1G6O1DyVAt0sSz56BUBjPLu8EJn8OnR5YnvnhG8ANYLD0Oqj0B23/dEfzyn00AqVWBtc 7kPoWbdyvh5SIO2P3uN3cUy/Gbk8Rk5Nz21Rp8FgySwKOxc4cgFdwBpvOhYXyD2htRBU 3ITA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x186si23482534pgx.399.2019.04.11.09.23.42; Thu, 11 Apr 2019 09:23:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbfDKQXE (ORCPT + 99 others); Thu, 11 Apr 2019 12:23:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58814 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbfDKQXD (ORCPT ); Thu, 11 Apr 2019 12:23:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E7A03134342; Thu, 11 Apr 2019 16:23:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DCC38183DC; Thu, 11 Apr 2019 16:23:01 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5DC143FB10; Thu, 11 Apr 2019 16:23:00 +0000 (UTC) Date: Thu, 11 Apr 2019 12:23:00 -0400 (EDT) From: Pankaj Gupta To: Dan Williams Cc: cohuck@redhat.com, Jan Kara , KVM list , "Michael S. Tsirkin" , Jason Wang , david , Qemu Developers , virtualization@lists.linux-foundation.org, Andreas Dilger , Ross Zwisler , Andrea Arcangeli , Dave Jiang , linux-nvdimm , Vishal L Verma , David Hildenbrand , Matthew Wilcox , Christoph Hellwig , Linux ACPI , jmoyer , linux-ext4 , Len Brown , kilobyte@angband.pl, Rik van Riel , yuval shaia , Stefan Hajnoczi , Paolo Bonzini , lcapitulino@redhat.com, Kevin Wolf , Nitesh Narayan Lal , Theodore Ts'o , Xiao Guangrong , "Darrick J. Wong" , "Rafael J. Wysocki" , Linux Kernel Mailing List , linux-xfs , linux-fsdevel , Igor Mammedov Message-ID: <1150671088.21162726.1554999780030.JavaMail.zimbra@redhat.com> In-Reply-To: References: <20190410040826.24371-1-pagupta@redhat.com> <20190410040826.24371-2-pagupta@redhat.com> <1463291806.21158433.1554998258746.JavaMail.zimbra@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 1/6] libnvdimm: nd_region flush callback support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.116.71, 10.4.195.1] Thread-Topic: libnvdimm: nd_region flush callback support Thread-Index: gw3ZQ9aBgaO/mtRYQSpGSYATa+Jryw== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 11 Apr 2019 16:23:03 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > This patch adds functionality to perform flush from guest > > > > to host over VIRTIO. We are registering a callback based > > > > on 'nd_region' type. virtio_pmem driver requires this special > > > > flush function. For rest of the region types we are registering > > > > existing flush function. Report error returned by host fsync > > > > failure to userspace. > > > > > > > > This also handles asynchronous flush requests from the block layer > > > > by creating a child bio and chaining it with parent bio. > > > > > > > > Signed-off-by: Pankaj Gupta > > > > ---bio_chain Dan williams > > > [..] > > > > diff --git a/drivers/nvdimm/region_devs.c > > > > b/drivers/nvdimm/region_devs.c > > > > index b4ef7d9ff22e..fb1041ab32a6 100644 > > > > --- a/drivers/nvdimm/region_devs.c > > > > +++ b/drivers/nvdimm/region_devs.c > > > > @@ -295,7 +295,9 @@ static ssize_t deep_flush_store(struct device *dev, > > > > struct device_attribute *att > > > > return rc; > > > > if (!flush) > > > > return -EINVAL; > > > > - nvdimm_flush(nd_region); > > > > + rc = nvdimm_flush(nd_region, NULL, false); > > > > + if (rc) > > > > + return rc; > > > > > > > > return len; > > > > } > > > > @@ -1085,6 +1087,11 @@ static struct nd_region *nd_region_create(struct > > > > nvdimm_bus *nvdimm_bus, > > > > dev->of_node = ndr_desc->of_node; > > > > nd_region->ndr_size = resource_size(ndr_desc->res); > > > > nd_region->ndr_start = ndr_desc->res->start; > > > > + if (ndr_desc->flush) > > > > + nd_region->flush = ndr_desc->flush; > > > > + else > > > > + nd_region->flush = generic_nvdimm_flush; > > > > + > > > > nd_device_register(dev); > > > > > > > > return nd_region; > > > > @@ -1125,11 +1132,36 @@ struct nd_region > > > > *nvdimm_volatile_region_create(struct nvdimm_bus *nvdimm_bus, > > > > } > > > > EXPORT_SYMBOL_GPL(nvdimm_volatile_region_create); > > > > > > > > +int nvdimm_flush(struct nd_region *nd_region, struct bio *bio, bool > > > > async) > > > > +{ > > > > > > I don't quite see the point of the 'async' argument. All the usages of > > > this routine are either > > > > > > nvdimm_flush(nd_region, bio, true) > > > ...or: > > > nvdimm_flush(nd_region, NULL, false) > > > > Agree. > > > > > > > > ...so why not gate async behavior on the presence of the 'bio' argument? > > > > Sure. > > > > > > > > > > > > + int rc = 0; > > > > + > > > > + /* Create child bio for asynchronous flush and chain with > > > > + * parent bio. Otherwise directly call nd_region flush. > > > > + */ > > > > + if (async && bio->bi_iter.bi_sector != -1) { > > > > + > > > > + struct bio *child = bio_alloc(GFP_ATOMIC, 0); > > > > + > > > > + if (!child) > > > > + return -ENOMEM; > > > > + bio_copy_dev(child, bio); > > > > + child->bi_opf = REQ_PREFLUSH; > > > > + child->bi_iter.bi_sector = -1; > > > > + bio_chain(child, bio); > > > > + submit_bio(child); > > > > > > I understand how this works, but it's a bit too "magical" for my > > > taste. I would prefer that all flush implementations take an optional > > > 'bio' argument rather than rely on the make_request implementation to > > > stash the bio away on a driver specific list. > > > > I did this to make use of "bio_chain" for chaining child bio for async > > flush > > suggested [1]. Are you saying to remove this and just call "flush" based on > > bio argument? Or I implemented the 'bio_chain' request entirely wrong? > > No, I think you implemented it correctly. I'm just asking for the > chaining to be performed internal to the ->flush() callback rather > than in the common nvdimm_flush() front-end. Sure. Perfect! Thank you very much for all the suggestions. Best regards, Pankaj >