aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/core.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2015-05-01 13:34:01 -0400
committerDan Williams <dan.j.williams@intel.com>2015-06-24 21:24:10 -0400
commit1b40e09a1232de537b193fa1b6b3ef16d3a1e397 (patch)
tree48111c53fa3125b7d1f46d0f01b9448acbee62d0 /drivers/nvdimm/core.c
parentbf9bccc14c05dae8caba29df6187c731710f5380 (diff)
libnvdimm: blk labels and namespace instantiation
A blk label set describes a namespace comprised of one or more discontiguous dpa ranges on a single dimm. They may alias with one or more pmem interleave sets that include the given dimm. This is the runtime/volatile configuration infrastructure for sysfs manipulation of 'alt_name', 'uuid', 'size', and 'sector_size'. A later patch will make these settings persistent by writing back the label(s). Unlike pmem namespaces, multiple blk namespaces can be created per region. Once a blk namespace has been created a new seed device (unconfigured child of a parent blk region) is instantiated. As long as a region has 'available_size' != 0 new child namespaces may be created. Cc: Greg KH <gregkh@linuxfoundation.org> Cc: Neil Brown <neilb@suse.de> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/core.c')
-rw-r--r--drivers/nvdimm/core.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c
index cf99cce8ef33..dd824d7c2669 100644
--- a/drivers/nvdimm/core.c
+++ b/drivers/nvdimm/core.c
@@ -173,6 +173,46 @@ int nd_uuid_store(struct device *dev, u8 **uuid_out, const char *buf,
173 return 0; 173 return 0;
174} 174}
175 175
176ssize_t nd_sector_size_show(unsigned long current_lbasize,
177 const unsigned long *supported, char *buf)
178{
179 ssize_t len = 0;
180 int i;
181
182 for (i = 0; supported[i]; i++)
183 if (current_lbasize == supported[i])
184 len += sprintf(buf + len, "[%ld] ", supported[i]);
185 else
186 len += sprintf(buf + len, "%ld ", supported[i]);
187 len += sprintf(buf + len, "\n");
188 return len;
189}
190
191ssize_t nd_sector_size_store(struct device *dev, const char *buf,
192 unsigned long *current_lbasize, const unsigned long *supported)
193{
194 unsigned long lbasize;
195 int rc, i;
196
197 if (dev->driver)
198 return -EBUSY;
199
200 rc = kstrtoul(buf, 0, &lbasize);
201 if (rc)
202 return rc;
203
204 for (i = 0; supported[i]; i++)
205 if (lbasize == supported[i])
206 break;
207
208 if (supported[i]) {
209 *current_lbasize = lbasize;
210 return 0;
211 } else {
212 return -EINVAL;
213 }
214}
215
176static ssize_t commands_show(struct device *dev, 216static ssize_t commands_show(struct device *dev,
177 struct device_attribute *attr, char *buf) 217 struct device_attribute *attr, char *buf)
178{ 218{