Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbdFNK5e (ORCPT ); Wed, 14 Jun 2017 06:57:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:54041 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751889AbdFNK5d (ORCPT ); Wed, 14 Jun 2017 06:57:33 -0400 Date: Wed, 14 Jun 2017 12:57:31 +0200 From: Jan Kara To: Dan Williams Cc: linux-nvdimm@lists.01.org, Matthew Wilcox , x86@kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Ross Zwisler , hch@lst.de Subject: Re: [PATCH v3 04/14] dax, pmem: introduce an optional 'flush' dax_operation Message-ID: <20170614105731.GG21506@quack2.suse.cz> References: <149703982465.20620.14881139332926778446.stgit@dwillia2-desk3.amr.corp.intel.com> <149703984722.20620.1577767383686219477.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <149703984722.20620.1577767383686219477.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2380 Lines: 66 On Fri 09-06-17 13:24:07, Dan Williams wrote: > Filesystem-DAX flushes caches whenever it writes to the address returned > through dax_direct_access() and when writing back dirty radix entries. > That flushing is only required in the pmem case, so add a dax operation > to allow pmem to take this extra action, but skip it for other dax > capable devices that do not provide a flush routine. > > An example for this differentiation might be a volatile ram disk where > there is no expectation of persistence. In fact the pmem driver itself might > front such an address range specified by the NFIT. So, this "no flush" > property might be something passed down by the bus / libnvdimm. > > Cc: Christoph Hellwig > Cc: Matthew Wilcox > Cc: Ross Zwisler > Signed-off-by: Dan Williams Looks good to me. You can add: Reviewed-by: Jan Kara Honza > --- > drivers/nvdimm/pmem.c | 7 +++++++ > include/linux/dax.h | 2 ++ > 2 files changed, 9 insertions(+) > > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c > index 2f3aefe565c6..823b07774244 100644 > --- a/drivers/nvdimm/pmem.c > +++ b/drivers/nvdimm/pmem.c > @@ -242,9 +242,16 @@ static size_t pmem_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, > return copy_from_iter_flushcache(addr, bytes, i); > } > > +static void pmem_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, > + void *addr, size_t size) > +{ > + wb_cache_pmem(addr, size); > +} > + > static const struct dax_operations pmem_dax_ops = { > .direct_access = pmem_dax_direct_access, > .copy_from_iter = pmem_copy_from_iter, > + .flush = pmem_dax_flush, > }; > > static void pmem_release_queue(void *q) > diff --git a/include/linux/dax.h b/include/linux/dax.h > index 28e398f8c59e..407dd3ff6e54 100644 > --- a/include/linux/dax.h > +++ b/include/linux/dax.h > @@ -19,6 +19,8 @@ struct dax_operations { > /* copy_from_iter: dax-driver override for default copy_from_iter */ > size_t (*copy_from_iter)(struct dax_device *, pgoff_t, void *, size_t, > struct iov_iter *); > + /* flush: optional driver-specific cache management after writes */ > + void (*flush)(struct dax_device *, pgoff_t, void *, size_t); > }; > > #if IS_ENABLED(CONFIG_DAX) > -- Jan Kara SUSE Labs, CR