Return-Path: Received: from mail-oi1-f196.google.com ([209.85.167.196]:41986 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726656AbfAIRCT (ORCPT ); Wed, 9 Jan 2019 12:02:19 -0500 Received: by mail-oi1-f196.google.com with SMTP id w13so6847722oiw.9 for ; Wed, 09 Jan 2019 09:02:19 -0800 (PST) MIME-Version: 1.0 References: <20190109135024.14093-1-pagupta@redhat.com> <20190109135024.14093-4-pagupta@redhat.com> In-Reply-To: <20190109135024.14093-4-pagupta@redhat.com> From: Dan Williams Date: Wed, 9 Jan 2019 09:02:07 -0800 Message-ID: Subject: Re: [PATCH v3 3/5] libnvdimm: add nd_region buffered dax_dev flag To: Pankaj Gupta Cc: Linux Kernel Mailing List , KVM list , Qemu Developers , linux-nvdimm , linux-fsdevel , virtualization@lists.linux-foundation.org, Linux ACPI , linux-ext4 , linux-xfs , Jan Kara , Stefan Hajnoczi , Rik van Riel , Nitesh Narayan Lal , Kevin Wolf , Paolo Bonzini , Ross Zwisler , Vishal L Verma , Dave Jiang , David Hildenbrand , jmoyer , Xiao Guangrong , Christoph Hellwig , "Michael S. Tsirkin" , Jason Wang , lcapitulino@redhat.com, Igor Mammedov , Eric Blake , Matthew Wilcox , "Theodore Ts'o" , Andreas Dilger , "Darrick J. Wong" , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" Sender: linux-ext4-owner@vger.kernel.org List-ID: On Wed, Jan 9, 2019 at 5:53 AM Pankaj Gupta wrote: > > This patch adds 'DAXDEV_BUFFERED' flag which is set > for virtio pmem corresponding nd_region. This later > is used to disable MAP_SYNC functionality for ext4 > & xfs filesystem. > > Signed-off-by: Pankaj Gupta > --- > drivers/dax/super.c | 17 +++++++++++++++++ > drivers/nvdimm/pmem.c | 3 +++ > drivers/nvdimm/region_devs.c | 7 +++++++ > drivers/virtio/pmem.c | 1 + > include/linux/dax.h | 9 +++++++++ > include/linux/libnvdimm.h | 6 ++++++ > 6 files changed, 43 insertions(+) > > diff --git a/drivers/dax/super.c b/drivers/dax/super.c > index 6e928f3..9128740 100644 > --- a/drivers/dax/super.c > +++ b/drivers/dax/super.c > @@ -167,6 +167,8 @@ enum dax_device_flags { > DAXDEV_ALIVE, > /* gate whether dax_flush() calls the low level flush routine */ > DAXDEV_WRITE_CACHE, > + /* flag to disable MAP_SYNC for virtio based host page cache flush */ > + DAXDEV_BUFFERED, > }; > > /** > @@ -335,6 +337,21 @@ bool dax_write_cache_enabled(struct dax_device *dax_dev) > } > EXPORT_SYMBOL_GPL(dax_write_cache_enabled); > > +void virtio_pmem_host_cache(struct dax_device *dax_dev, bool wc) > +{ > + if (wc) > + set_bit(DAXDEV_BUFFERED, &dax_dev->flags); > + else > + clear_bit(DAXDEV_BUFFERED, &dax_dev->flags); > +} > +EXPORT_SYMBOL_GPL(virtio_pmem_host_cache); The "write_cache" property was structured this way because it can conceivably change at runtime. The MAP_SYNC capability should be static and never changed after init. > +bool virtio_pmem_host_cache_enabled(struct dax_device *dax_dev) > +{ > + return test_bit(DAXDEV_BUFFERED, &dax_dev->flags); > +} > +EXPORT_SYMBOL_GPL(virtio_pmem_host_cache_enabled); Echoing Darrick and Jan this is should be a generic property of a dax_device and not specific to virtio. I don't like the "buffered" designation as that's not accurate. There may be hardware reasons why a dax_device is not synchronous, like a requirement to flush a write-pending queue or otherwise notify the device of new writes. I would just have a dax_synchronous() helper and a DAXDEV_SYNC flag. I would also modify alloc_dax() to take a flags argument so that the capability can be instantiated when the dax_device is allocated.