From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Williams Subject: Re: [PATCH v3 3/5] libnvdimm: add nd_region buffered dax_dev flag Date: Wed, 9 Jan 2019 09:02:07 -0800 Message-ID: References: <20190109135024.14093-1-pagupta@redhat.com> <20190109135024.14093-4-pagupta@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Jan Kara , KVM list , David Hildenbrand , linux-nvdimm , Jason Wang , Qemu Developers , virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Andreas Dilger , Ross Zwisler , Eric Blake , "Darrick J. Wong" , "Michael S. Tsirkin" , Matthew Wilcox , Christoph Hellwig , Linux ACPI , Nitesh Narayan Lal , Rik van Riel , Stefan Hajnoczi , Igor Mammedov , lcapitulino-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, Kevin Wolf , linux-ext4 , Theodore Ts'o , Xiao Guangrong Return-path: In-Reply-To: <20190109135024.14093-4-pagupta-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" List-Id: kvm.vger.kernel.org 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.