Path: csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod From: Jeff Moyer Newsgroups: linux.kernel Subject: Re: [PATCH] libnvdimm, region: sysfs trigger for nvdimm_flush() Date: Mon, 24 Apr 2017 18:30:02 +0200 Message-ID: References: X-Original-To: Dan Williams Dmarc-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2C0F3C052507 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jmoyer@redhat.com Dkim-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2C0F3C052507 X-PGP-Keyid: 1F78E1B4 X-PGP-Certkey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-Pcloadletter: What the f**k does that mean? User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 24 Apr 2017 16:26:19 +0000 (UTC) Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 75 Organization: linux.* mail to news gateway X-Original-Cc: linux-nvdimm@lists.01.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org X-Original-Date: Mon, 24 Apr 2017 12:26:17 -0400 X-Original-Message-ID: X-Original-References: <149281853758.22910.2919981036906495309.stgit@dwillia2-desk3.amr.corp.intel.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1629756 Dan Williams writes: > The nvdimm_flush() mechanism helps to reduce the impact of an ADR > (asynchronous-dimm-refresh) failure. The ADR mechanism handles flushing > platform WPQ (write-pending-queue) buffers when power is removed. The > nvdimm_flush() mechanism performs that same function on-demand. > > When a pmem namespace is associated with a block device, an > nvdimm_flush() is triggered with every block-layer REQ_FUA, or REQ_FLUSH > request. However, when a namespace is in device-dax mode, or namespaces > are disabled, userspace needs another path. > > The new 'flush' attribute is visible when it can be determined that the > interleave-set either does, or does not have DIMMs that expose WPQ-flush > addresses, "flush-hints" in ACPI NFIT terminology. It returns "1" and > flushes DIMMs, or returns "0" the flush operation is a platform nop. > > Signed-off-by: Dan Williams NACK. This should function the same way it does for a pmem device. Wire up sync. -Jeff > --- > drivers/nvdimm/region_devs.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c > index 8de5a04644a1..3495b4c23941 100644 > --- a/drivers/nvdimm/region_devs.c > +++ b/drivers/nvdimm/region_devs.c > @@ -255,6 +255,19 @@ static ssize_t size_show(struct device *dev, > } > static DEVICE_ATTR_RO(size); > > +static ssize_t flush_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct nd_region *nd_region = to_nd_region(dev); > + > + if (nvdimm_has_flush(nd_region)) { > + nvdimm_flush(nd_region); > + return sprintf(buf, "1\n"); > + } > + return sprintf(buf, "0\n"); > +} > +static DEVICE_ATTR_RO(flush); > + > static ssize_t mappings_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > @@ -474,6 +487,7 @@ static DEVICE_ATTR_RO(resource); > > static struct attribute *nd_region_attributes[] = { > &dev_attr_size.attr, > + &dev_attr_flush.attr, > &dev_attr_nstype.attr, > &dev_attr_mappings.attr, > &dev_attr_btt_seed.attr, > @@ -508,6 +522,9 @@ static umode_t region_visible(struct kobject *kobj, struct attribute *a, int n) > if (!is_nd_pmem(dev) && a == &dev_attr_resource.attr) > return 0; > > + if (a == &dev_attr_flush.attr && nvdimm_has_flush(nd_region) < 0) > + return 0; > + > if (a != &dev_attr_set_cookie.attr > && a != &dev_attr_available_size.attr) > return a->mode; > > _______________________________________________ > Linux-nvdimm mailing list > Linux-nvdimm@lists.01.org > https://lists.01.org/mailman/listinfo/linux-nvdimm