From: Christoph Hellwig <hch@lst.de>
To: Dan Williams <dan.j.williams@intel.com>, Jens Axboe <axboe@kernel.dk>
Cc: Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
linux-block@vger.kernel.org, nvdimm@lists.linux.dev
Subject: [PATCH 2/3] nvdimm/pmem: move dax_attribute_group from dax to pmem
Date: Mon, 20 Sep 2021 09:27:25 +0200 [thread overview]
Message-ID: <20210920072726.1159572-3-hch@lst.de> (raw)
In-Reply-To: <20210920072726.1159572-1-hch@lst.de>
dax_attribute_group is only used by the pmem driver, and can avoid the
completely pointless lookup by the disk name if moved there.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/dax/super.c | 64 -------------------------------------------
drivers/nvdimm/pmem.c | 43 +++++++++++++++++++++++++++++
include/linux/dax.h | 2 --
3 files changed, 43 insertions(+), 66 deletions(-)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index fc89e91beea7c..e03d94bdc0449 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -231,70 +231,6 @@ enum dax_device_flags {
DAXDEV_SYNC,
};
-static ssize_t write_cache_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct dax_device *dax_dev = dax_get_by_host(dev_name(dev));
- ssize_t rc;
-
- WARN_ON_ONCE(!dax_dev);
- if (!dax_dev)
- return -ENXIO;
-
- rc = sprintf(buf, "%d\n", !!dax_write_cache_enabled(dax_dev));
- put_dax(dax_dev);
- return rc;
-}
-
-static ssize_t write_cache_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t len)
-{
- bool write_cache;
- int rc = strtobool(buf, &write_cache);
- struct dax_device *dax_dev = dax_get_by_host(dev_name(dev));
-
- WARN_ON_ONCE(!dax_dev);
- if (!dax_dev)
- return -ENXIO;
-
- if (rc)
- len = rc;
- else
- dax_write_cache(dax_dev, write_cache);
-
- put_dax(dax_dev);
- return len;
-}
-static DEVICE_ATTR_RW(write_cache);
-
-static umode_t dax_visible(struct kobject *kobj, struct attribute *a, int n)
-{
- struct device *dev = container_of(kobj, typeof(*dev), kobj);
- struct dax_device *dax_dev = dax_get_by_host(dev_name(dev));
-
- WARN_ON_ONCE(!dax_dev);
- if (!dax_dev)
- return 0;
-
-#ifndef CONFIG_ARCH_HAS_PMEM_API
- if (a == &dev_attr_write_cache.attr)
- return 0;
-#endif
- return a->mode;
-}
-
-static struct attribute *dax_attributes[] = {
- &dev_attr_write_cache.attr,
- NULL,
-};
-
-struct attribute_group dax_attribute_group = {
- .name = "dax",
- .attrs = dax_attributes,
- .is_visible = dax_visible,
-};
-EXPORT_SYMBOL_GPL(dax_attribute_group);
-
/**
* dax_direct_access() - translate a device pgoff to an absolute pfn
* @dax_dev: a dax_device instance representing the logical memory range
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index ef4950f808326..bbeb3f46db157 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -328,6 +328,49 @@ static const struct dax_operations pmem_dax_ops = {
.zero_page_range = pmem_dax_zero_page_range,
};
+static ssize_t write_cache_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct pmem_device *pmem = dev_to_disk(dev)->private_data;
+
+ return sprintf(buf, "%d\n", !!dax_write_cache_enabled(pmem->dax_dev));
+}
+
+static ssize_t write_cache_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct pmem_device *pmem = dev_to_disk(dev)->private_data;
+ bool write_cache;
+ int rc;
+
+ rc = strtobool(buf, &write_cache);
+ if (rc)
+ return rc;
+ dax_write_cache(pmem->dax_dev, write_cache);
+ return len;
+}
+static DEVICE_ATTR_RW(write_cache);
+
+static umode_t dax_visible(struct kobject *kobj, struct attribute *a, int n)
+{
+#ifndef CONFIG_ARCH_HAS_PMEM_API
+ if (a == &dev_attr_write_cache.attr)
+ return 0;
+#endif
+ return a->mode;
+}
+
+static struct attribute *dax_attributes[] = {
+ &dev_attr_write_cache.attr,
+ NULL,
+};
+
+static const struct attribute_group dax_attribute_group = {
+ .name = "dax",
+ .attrs = dax_attributes,
+ .is_visible = dax_visible,
+};
+
static const struct attribute_group *pmem_attribute_groups[] = {
&dax_attribute_group,
NULL,
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 2619d94c308d4..8623caa673889 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -38,8 +38,6 @@ struct dax_operations {
int (*zero_page_range)(struct dax_device *, pgoff_t, size_t);
};
-extern struct attribute_group dax_attribute_group;
-
#if IS_ENABLED(CONFIG_DAX)
struct dax_device *alloc_dax(void *private, const char *host,
const struct dax_operations *ops, unsigned long flags);
--
2.30.2
next prev parent reply other threads:[~2021-09-20 7:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 7:27 fix a dax/block device attribute registration regression Christoph Hellwig
2021-09-20 7:27 ` [PATCH 1/3] nvdimm/pmem: fix creating the dax group Christoph Hellwig
2021-09-20 22:52 ` Ira Weiny
2021-09-20 23:09 ` Dan Williams
2021-09-20 23:09 ` Dan Williams
2021-09-20 7:27 ` Christoph Hellwig [this message]
2021-09-20 18:00 ` [PATCH 2/3] nvdimm/pmem: move dax_attribute_group from dax to pmem kernel test robot
2021-09-20 18:00 ` kernel test robot
2021-09-20 23:29 ` Dan Williams
2021-09-20 23:29 ` Dan Williams
2021-09-20 23:29 ` Dan Williams
2021-09-20 22:51 ` Ira Weiny
2021-09-20 23:36 ` Dan Williams
2021-09-20 23:36 ` Dan Williams
2021-09-20 23:37 ` Dan Williams
2021-09-20 23:37 ` Dan Williams
2021-09-20 7:27 ` [PATCH 3/3] block: warn if ->groups is set when calling add_disk Christoph Hellwig
2021-09-20 22:52 ` Ira Weiny
2021-09-20 23:50 ` Dan Williams
2021-09-20 23:50 ` Dan Williams
2021-09-21 6:32 ` Christoph Hellwig
2021-09-22 17:34 dax_supported() related cleanups v2 Christoph Hellwig
2021-09-22 17:34 ` [PATCH 2/3] nvdimm/pmem: move dax_attribute_group from dax to pmem Christoph Hellwig
2021-09-22 18:33 fix a dax/block device attribute registration regression Christoph Hellwig
2021-09-22 18:33 ` [PATCH 2/3] nvdimm/pmem: move dax_attribute_group from dax to pmem Christoph Hellwig
2021-09-22 21:40 ` Ira Weiny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210920072726.1159572-3-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.