Skip to content

Commit fadc38a

Browse files
committed
nvdimm/namespace: Delete blk namespace consideration in shared paths
Given is_namespace_blk() is never true outside of the NVDIMM unit tests delete the support from namespace device management. Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/164688417214.2879318.4698377272678028573.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent f8669f1 commit fadc38a

1 file changed

Lines changed: 9 additions & 143 deletions

File tree

drivers/nvdimm/namespace_devs.c

Lines changed: 9 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ static void namespace_blk_release(struct device *dev)
4646
}
4747

4848
static bool is_namespace_pmem(const struct device *dev);
49-
static bool is_namespace_blk(const struct device *dev);
5049
static bool is_namespace_io(const struct device *dev);
5150

5251
static int is_uuid_busy(struct device *dev, void *data)
@@ -57,10 +56,6 @@ static int is_uuid_busy(struct device *dev, void *data)
5756
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
5857

5958
uuid2 = nspm->uuid;
60-
} else if (is_namespace_blk(dev)) {
61-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
62-
63-
uuid2 = nsblk->uuid;
6459
} else if (is_nd_btt(dev)) {
6560
struct nd_btt *nd_btt = to_nd_btt(dev);
6661

@@ -178,12 +173,6 @@ const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
178173
else
179174
sprintf(name, "pmem%d%s", nd_region->id,
180175
suffix ? suffix : "");
181-
} else if (is_namespace_blk(&ndns->dev)) {
182-
struct nd_namespace_blk *nsblk;
183-
184-
nsblk = to_nd_namespace_blk(&ndns->dev);
185-
sprintf(name, "ndblk%d.%d%s", nd_region->id, nsblk->id,
186-
suffix ? suffix : "");
187176
} else {
188177
return NULL;
189178
}
@@ -201,10 +190,6 @@ const uuid_t *nd_dev_to_uuid(struct device *dev)
201190
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
202191

203192
return nspm->uuid;
204-
} else if (is_namespace_blk(dev)) {
205-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
206-
207-
return nsblk->uuid;
208193
} else
209194
return &uuid_null;
210195
}
@@ -229,10 +214,6 @@ static ssize_t __alt_name_store(struct device *dev, const char *buf,
229214
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
230215

231216
ns_altname = &nspm->alt_name;
232-
} else if (is_namespace_blk(dev)) {
233-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
234-
235-
ns_altname = &nsblk->alt_name;
236217
} else
237218
return -ENXIO;
238219

@@ -264,24 +245,6 @@ static ssize_t __alt_name_store(struct device *dev, const char *buf,
264245
return rc;
265246
}
266247

267-
static resource_size_t nd_namespace_blk_size(struct nd_namespace_blk *nsblk)
268-
{
269-
struct nd_region *nd_region = to_nd_region(nsblk->common.dev.parent);
270-
struct nd_mapping *nd_mapping = &nd_region->mapping[0];
271-
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
272-
struct nd_label_id label_id;
273-
resource_size_t size = 0;
274-
struct resource *res;
275-
276-
if (!nsblk->uuid)
277-
return 0;
278-
nd_label_gen_id(&label_id, nsblk->uuid, NSLABEL_FLAG_LOCAL);
279-
for_each_dpa_resource(ndd, res)
280-
if (strcmp(res->name, label_id.id) == 0)
281-
size += resource_size(res);
282-
return size;
283-
}
284-
285248
static bool __nd_namespace_blk_validate(struct nd_namespace_blk *nsblk)
286249
{
287250
struct nd_region *nd_region = to_nd_region(nsblk->common.dev.parent);
@@ -363,16 +326,6 @@ static int nd_namespace_label_update(struct nd_region *nd_region,
363326
return 0;
364327

365328
return nd_pmem_namespace_label_update(nd_region, nspm, size);
366-
} else if (is_namespace_blk(dev)) {
367-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
368-
resource_size_t size = nd_namespace_blk_size(nsblk);
369-
370-
if (size == 0 && nsblk->uuid)
371-
/* delete allocation */;
372-
else if (!nsblk->uuid || !nsblk->lbasize)
373-
return 0;
374-
375-
return nd_blk_namespace_label_update(nd_region, nsblk, size);
376329
} else
377330
return -ENXIO;
378331
}
@@ -405,10 +358,6 @@ static ssize_t alt_name_show(struct device *dev,
405358
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
406359

407360
ns_altname = nspm->alt_name;
408-
} else if (is_namespace_blk(dev)) {
409-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
410-
411-
ns_altname = nsblk->alt_name;
412361
} else
413362
return -ENXIO;
414363

@@ -966,12 +915,6 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
966915

967916
uuid = nspm->uuid;
968917
id = nspm->id;
969-
} else if (is_namespace_blk(dev)) {
970-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
971-
972-
uuid = nsblk->uuid;
973-
flags = NSLABEL_FLAG_LOCAL;
974-
id = nsblk->id;
975918
}
976919

977920
/*
@@ -1067,10 +1010,6 @@ static ssize_t size_store(struct device *dev,
10671010
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
10681011

10691012
uuid = &nspm->uuid;
1070-
} else if (is_namespace_blk(dev)) {
1071-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
1072-
1073-
uuid = &nsblk->uuid;
10741013
}
10751014

10761015
if (rc == 0 && val == 0 && uuid) {
@@ -1095,8 +1034,6 @@ resource_size_t __nvdimm_namespace_capacity(struct nd_namespace_common *ndns)
10951034
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
10961035

10971036
return resource_size(&nspm->nsio.res);
1098-
} else if (is_namespace_blk(dev)) {
1099-
return nd_namespace_blk_size(to_nd_namespace_blk(dev));
11001037
} else if (is_namespace_io(dev)) {
11011038
struct nd_namespace_io *nsio = to_nd_namespace_io(dev);
11021039

@@ -1152,12 +1089,8 @@ static uuid_t *namespace_to_uuid(struct device *dev)
11521089
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
11531090

11541091
return nspm->uuid;
1155-
} else if (is_namespace_blk(dev)) {
1156-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
1157-
1158-
return nsblk->uuid;
1159-
} else
1160-
return ERR_PTR(-ENXIO);
1092+
}
1093+
return ERR_PTR(-ENXIO);
11611094
}
11621095

11631096
static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
@@ -1183,7 +1116,6 @@ static int namespace_update_uuid(struct nd_region *nd_region,
11831116
struct device *dev, uuid_t *new_uuid,
11841117
uuid_t **old_uuid)
11851118
{
1186-
u32 flags = is_namespace_blk(dev) ? NSLABEL_FLAG_LOCAL : 0;
11871119
struct nd_label_id old_label_id;
11881120
struct nd_label_id new_label_id;
11891121
int i;
@@ -1214,8 +1146,8 @@ static int namespace_update_uuid(struct nd_region *nd_region,
12141146
return -EBUSY;
12151147
}
12161148

1217-
nd_label_gen_id(&old_label_id, *old_uuid, flags);
1218-
nd_label_gen_id(&new_label_id, new_uuid, flags);
1149+
nd_label_gen_id(&old_label_id, *old_uuid, 0);
1150+
nd_label_gen_id(&new_label_id, new_uuid, 0);
12191151
for (i = 0; i < nd_region->ndr_mappings; i++) {
12201152
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
12211153
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
@@ -1261,10 +1193,6 @@ static ssize_t uuid_store(struct device *dev,
12611193
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
12621194

12631195
ns_uuid = &nspm->uuid;
1264-
} else if (is_namespace_blk(dev)) {
1265-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
1266-
1267-
ns_uuid = &nsblk->uuid;
12681196
} else
12691197
return -ENXIO;
12701198

@@ -1321,13 +1249,6 @@ static const unsigned long pmem_lbasize_supported[] = { 512, 4096, 0 };
13211249
static ssize_t sector_size_show(struct device *dev,
13221250
struct device_attribute *attr, char *buf)
13231251
{
1324-
if (is_namespace_blk(dev)) {
1325-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
1326-
1327-
return nd_size_select_show(nsblk->lbasize,
1328-
blk_lbasize_supported, buf);
1329-
}
1330-
13311252
if (is_namespace_pmem(dev)) {
13321253
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
13331254

@@ -1345,12 +1266,7 @@ static ssize_t sector_size_store(struct device *dev,
13451266
unsigned long *lbasize;
13461267
ssize_t rc = 0;
13471268

1348-
if (is_namespace_blk(dev)) {
1349-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
1350-
1351-
lbasize = &nsblk->lbasize;
1352-
supported = blk_lbasize_supported;
1353-
} else if (is_namespace_pmem(dev)) {
1269+
if (is_namespace_pmem(dev)) {
13541270
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
13551271

13561272
lbasize = &nspm->lbasize;
@@ -1390,11 +1306,6 @@ static ssize_t dpa_extents_show(struct device *dev,
13901306

13911307
uuid = nspm->uuid;
13921308
flags = 0;
1393-
} else if (is_namespace_blk(dev)) {
1394-
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
1395-
1396-
uuid = nsblk->uuid;
1397-
flags = NSLABEL_FLAG_LOCAL;
13981309
}
13991310

14001311
if (!uuid)
@@ -1627,10 +1538,7 @@ static umode_t namespace_visible(struct kobject *kobj,
16271538
{
16281539
struct device *dev = container_of(kobj, struct device, kobj);
16291540

1630-
if (a == &dev_attr_resource.attr && is_namespace_blk(dev))
1631-
return 0;
1632-
1633-
if (is_namespace_pmem(dev) || is_namespace_blk(dev)) {
1541+
if (is_namespace_pmem(dev)) {
16341542
if (a == &dev_attr_size.attr)
16351543
return 0644;
16361544

@@ -1682,11 +1590,6 @@ static bool is_namespace_pmem(const struct device *dev)
16821590
return dev ? dev->type == &namespace_pmem_device_type : false;
16831591
}
16841592

1685-
static bool is_namespace_blk(const struct device *dev)
1686-
{
1687-
return dev ? dev->type == &namespace_blk_device_type : false;
1688-
}
1689-
16901593
static bool is_namespace_io(const struct device *dev)
16911594
{
16921595
return dev ? dev->type == &namespace_io_device_type : false;
@@ -1769,18 +1672,6 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
17691672
nspm = to_nd_namespace_pmem(&ndns->dev);
17701673
if (uuid_not_set(nspm->uuid, &ndns->dev, __func__))
17711674
return ERR_PTR(-ENODEV);
1772-
} else if (is_namespace_blk(&ndns->dev)) {
1773-
struct nd_namespace_blk *nsblk;
1774-
1775-
nsblk = to_nd_namespace_blk(&ndns->dev);
1776-
if (uuid_not_set(nsblk->uuid, &ndns->dev, __func__))
1777-
return ERR_PTR(-ENODEV);
1778-
if (!nsblk->lbasize) {
1779-
dev_dbg(&ndns->dev, "sector size not set\n");
1780-
return ERR_PTR(-ENODEV);
1781-
}
1782-
if (!nd_namespace_blk_validate(nsblk))
1783-
return ERR_PTR(-ENODEV);
17841675
}
17851676

17861677
return ndns;
@@ -1790,16 +1681,12 @@ EXPORT_SYMBOL(nvdimm_namespace_common_probe);
17901681
int devm_namespace_enable(struct device *dev, struct nd_namespace_common *ndns,
17911682
resource_size_t size)
17921683
{
1793-
if (is_namespace_blk(&ndns->dev))
1794-
return 0;
17951684
return devm_nsio_enable(dev, to_nd_namespace_io(&ndns->dev), size);
17961685
}
17971686
EXPORT_SYMBOL_GPL(devm_namespace_enable);
17981687

17991688
void devm_namespace_disable(struct device *dev, struct nd_namespace_common *ndns)
18001689
{
1801-
if (is_namespace_blk(&ndns->dev))
1802-
return;
18031690
devm_nsio_disable(dev, to_nd_namespace_io(&ndns->dev));
18041691
}
18051692
EXPORT_SYMBOL_GPL(devm_namespace_disable);
@@ -2225,7 +2112,6 @@ static int add_namespace_resource(struct nd_region *nd_region,
22252112

22262113
for (i = 0; i < count; i++) {
22272114
uuid_t *uuid = namespace_to_uuid(devs[i]);
2228-
struct resource *res;
22292115

22302116
if (IS_ERR(uuid)) {
22312117
WARN_ON(1);
@@ -2234,20 +2120,9 @@ static int add_namespace_resource(struct nd_region *nd_region,
22342120

22352121
if (!nsl_uuid_equal(ndd, nd_label, uuid))
22362122
continue;
2237-
if (is_namespace_blk(devs[i])) {
2238-
res = nsblk_add_resource(nd_region, ndd,
2239-
to_nd_namespace_blk(devs[i]),
2240-
nsl_get_dpa(ndd, nd_label));
2241-
if (!res)
2242-
return -ENXIO;
2243-
nd_dbg_dpa(nd_region, ndd, res, "%d assign\n", count);
2244-
} else {
2245-
dev_err(&nd_region->dev,
2246-
"error: conflicting extents for uuid: %pUb\n",
2247-
uuid);
2248-
return -ENXIO;
2249-
}
2250-
break;
2123+
dev_err(&nd_region->dev,
2124+
"error: conflicting extents for uuid: %pUb\n", uuid);
2125+
return -ENXIO;
22512126
}
22522127

22532128
return i;
@@ -2305,20 +2180,11 @@ static int cmp_dpa(const void *a, const void *b)
23052180
{
23062181
const struct device *dev_a = *(const struct device **) a;
23072182
const struct device *dev_b = *(const struct device **) b;
2308-
struct nd_namespace_blk *nsblk_a, *nsblk_b;
23092183
struct nd_namespace_pmem *nspm_a, *nspm_b;
23102184

23112185
if (is_namespace_io(dev_a))
23122186
return 0;
23132187

2314-
if (is_namespace_blk(dev_a)) {
2315-
nsblk_a = to_nd_namespace_blk(dev_a);
2316-
nsblk_b = to_nd_namespace_blk(dev_b);
2317-
2318-
return memcmp(&nsblk_a->res[0]->start, &nsblk_b->res[0]->start,
2319-
sizeof(resource_size_t));
2320-
}
2321-
23222188
nspm_a = to_nd_namespace_pmem(dev_a);
23232189
nspm_b = to_nd_namespace_pmem(dev_b);
23242190

0 commit comments

Comments
 (0)