nsblk 16 drivers/nvdimm/blk.c static u32 nsblk_meta_size(struct nd_namespace_blk *nsblk) nsblk 18 drivers/nvdimm/blk.c return nsblk->lbasize - ((nsblk->lbasize >= 4096) ? 4096 : 512); nsblk 21 drivers/nvdimm/blk.c static u32 nsblk_internal_lbasize(struct nd_namespace_blk *nsblk) nsblk 23 drivers/nvdimm/blk.c return roundup(nsblk->lbasize, INT_LBASIZE_ALIGNMENT); nsblk 26 drivers/nvdimm/blk.c static u32 nsblk_sector_size(struct nd_namespace_blk *nsblk) nsblk 28 drivers/nvdimm/blk.c return nsblk->lbasize - nsblk_meta_size(nsblk); nsblk 31 drivers/nvdimm/blk.c static resource_size_t to_dev_offset(struct nd_namespace_blk *nsblk, nsblk 36 drivers/nvdimm/blk.c for (i = 0; i < nsblk->num_resources; i++) { nsblk 37 drivers/nvdimm/blk.c if (ns_offset < resource_size(nsblk->res[i])) { nsblk 38 drivers/nvdimm/blk.c if (ns_offset + len > resource_size(nsblk->res[i])) { nsblk 39 drivers/nvdimm/blk.c dev_WARN_ONCE(&nsblk->common.dev, 1, nsblk 43 drivers/nvdimm/blk.c return nsblk->res[i]->start + ns_offset; nsblk 45 drivers/nvdimm/blk.c ns_offset -= resource_size(nsblk->res[i]); nsblk 48 drivers/nvdimm/blk.c dev_WARN_ONCE(&nsblk->common.dev, 1, "request out of range\n"); nsblk 52 drivers/nvdimm/blk.c static struct nd_blk_region *to_ndbr(struct nd_namespace_blk *nsblk) nsblk 57 drivers/nvdimm/blk.c parent = nsblk->common.dev.parent; nsblk 63 drivers/nvdimm/blk.c static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk, nsblk 66 drivers/nvdimm/blk.c struct nd_blk_region *ndbr = to_ndbr(nsblk); nsblk 67 drivers/nvdimm/blk.c unsigned int len = nsblk_meta_size(nsblk); nsblk 72 drivers/nvdimm/blk.c internal_lbasize = nsblk_internal_lbasize(nsblk); nsblk 73 drivers/nvdimm/blk.c sector_size = nsblk_sector_size(nsblk); nsblk 75 drivers/nvdimm/blk.c dev_offset = to_dev_offset(nsblk, ns_offset, len); nsblk 109 drivers/nvdimm/blk.c static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk, nsblk 116 drivers/nvdimm/blk.c static int nsblk_do_bvec(struct nd_namespace_blk *nsblk, nsblk 120 drivers/nvdimm/blk.c struct nd_blk_region *ndbr = to_ndbr(nsblk); nsblk 127 drivers/nvdimm/blk.c internal_lbasize = nsblk_internal_lbasize(nsblk); nsblk 128 drivers/nvdimm/blk.c sector_size = nsblk_sector_size(nsblk); nsblk 142 drivers/nvdimm/blk.c dev_offset = to_dev_offset(nsblk, ns_offset, cur_len); nsblk 153 drivers/nvdimm/blk.c err = nd_blk_rw_integrity(nsblk, bip, lba, rw); nsblk 168 drivers/nvdimm/blk.c struct nd_namespace_blk *nsblk; nsblk 179 drivers/nvdimm/blk.c nsblk = q->queuedata; nsblk 186 drivers/nvdimm/blk.c err = nsblk_do_bvec(nsblk, bip, bvec.bv_page, len, nsblk 189 drivers/nvdimm/blk.c dev_dbg(&nsblk->common.dev, nsblk 208 drivers/nvdimm/blk.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(&ndns->dev); nsblk 209 drivers/nvdimm/blk.c struct nd_blk_region *ndbr = to_ndbr(nsblk); nsblk 212 drivers/nvdimm/blk.c dev_offset = to_dev_offset(nsblk, offset, n); nsblk 214 drivers/nvdimm/blk.c if (unlikely(offset + n > nsblk->size)) { nsblk 241 drivers/nvdimm/blk.c static int nsblk_attach_disk(struct nd_namespace_blk *nsblk) nsblk 243 drivers/nvdimm/blk.c struct device *dev = &nsblk->common.dev; nsblk 249 drivers/nvdimm/blk.c internal_nlba = div_u64(nsblk->size, nsblk_internal_lbasize(nsblk)); nsblk 250 drivers/nvdimm/blk.c available_disk_size = internal_nlba * nsblk_sector_size(nsblk); nsblk 260 drivers/nvdimm/blk.c blk_queue_logical_block_size(q, nsblk_sector_size(nsblk)); nsblk 262 drivers/nvdimm/blk.c q->queuedata = nsblk; nsblk 272 drivers/nvdimm/blk.c nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name); nsblk 277 drivers/nvdimm/blk.c if (nsblk_meta_size(nsblk)) { nsblk 278 drivers/nvdimm/blk.c int rc = nd_integrity_init(disk, nsblk_meta_size(nsblk)); nsblk 293 drivers/nvdimm/blk.c struct nd_namespace_blk *nsblk; nsblk 299 drivers/nvdimm/blk.c nsblk = to_nd_namespace_blk(&ndns->dev); nsblk 300 drivers/nvdimm/blk.c nsblk->size = nvdimm_namespace_capacity(ndns); nsblk 301 drivers/nvdimm/blk.c dev_set_drvdata(dev, nsblk); nsblk 310 drivers/nvdimm/blk.c return nsblk_attach_disk(nsblk); nsblk 898 drivers/nvdimm/label.c struct nd_mapping *nd_mapping, struct nd_namespace_blk *nsblk, nsblk 903 drivers/nvdimm/label.c struct nd_namespace_common *ndns = &nsblk->common; nsblk 919 drivers/nvdimm/label.c old_res_list = nsblk->res; nsblk 921 drivers/nvdimm/label.c old_num_resources = nsblk->num_resources; nsblk 922 drivers/nvdimm/label.c nd_label_gen_id(&label_id, nsblk->uuid, NSLABEL_FLAG_LOCAL); nsblk 950 drivers/nvdimm/label.c if (memcmp(uuid, nsblk->uuid, NSLABEL_UUID_LEN) != 0) nsblk 964 drivers/nvdimm/label.c dev_info(&nsblk->common.dev, "insufficient label space\n"); nsblk 972 drivers/nvdimm/label.c nsblk->res = NULL; nsblk 973 drivers/nvdimm/label.c nsblk->num_resources = 0; nsblk 977 drivers/nvdimm/label.c if (!nsblk_add_resource(nd_region, ndd, nsblk, res->start)) { nsblk 987 drivers/nvdimm/label.c for (i = 0; i < nsblk->num_resources; i++) { nsblk 988 drivers/nvdimm/label.c struct resource *min = nsblk->res[min_dpa_idx]; nsblk 990 drivers/nvdimm/label.c res = nsblk->res[i]; nsblk 995 drivers/nvdimm/label.c for (i = 0; i < nsblk->num_resources; i++) { nsblk 998 drivers/nvdimm/label.c res = nsblk->res[i]; nsblk 1008 drivers/nvdimm/label.c memcpy(nd_label->uuid, nsblk->uuid, NSLABEL_UUID_LEN); nsblk 1009 drivers/nvdimm/label.c if (nsblk->alt_name) nsblk 1010 drivers/nvdimm/label.c memcpy(nd_label->name, nsblk->alt_name, nsblk 1021 drivers/nvdimm/label.c nd_label->nlabel = __cpu_to_le16(nsblk->num_resources); nsblk 1036 drivers/nvdimm/label.c nd_label->lbasize = __cpu_to_le64(nsblk->lbasize); nsblk 1086 drivers/nvdimm/label.c if (memcmp(uuid, nsblk->uuid, NSLABEL_UUID_LEN) != 0) nsblk 1095 drivers/nvdimm/label.c if (nlabel + nsblk->num_resources > num_labels) { nsblk 1117 drivers/nvdimm/label.c if (memcmp(uuid, nsblk->uuid, NSLABEL_UUID_LEN) != 0) nsblk 1121 drivers/nvdimm/label.c dev_vdbg(&nsblk->common.dev, "assign label slot: %d\n", slot); nsblk 1130 drivers/nvdimm/label.c dev_WARN(&nsblk->common.dev, nsblk 1146 drivers/nvdimm/label.c kfree(nsblk->res); nsblk 1147 drivers/nvdimm/label.c nsblk->res = old_res_list; nsblk 1148 drivers/nvdimm/label.c nsblk->num_resources = old_num_resources; nsblk 1293 drivers/nvdimm/label.c struct nd_namespace_blk *nsblk, resource_size_t size) nsblk 1300 drivers/nvdimm/label.c return del_labels(nd_mapping, nsblk->uuid); nsblk 1309 drivers/nvdimm/label.c return __blk_label_update(nd_region, nd_mapping, nsblk, count); nsblk 145 drivers/nvdimm/label.h struct nd_namespace_blk *nsblk, resource_size_t size); nsblk 36 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 39 drivers/nvdimm/namespace_devs.c if (nsblk->id >= 0) nsblk 40 drivers/nvdimm/namespace_devs.c ida_simple_remove(&nd_region->ns_ida, nsblk->id); nsblk 41 drivers/nvdimm/namespace_devs.c kfree(nsblk->alt_name); nsblk 42 drivers/nvdimm/namespace_devs.c kfree(nsblk->uuid); nsblk 43 drivers/nvdimm/namespace_devs.c kfree(nsblk->res); nsblk 44 drivers/nvdimm/namespace_devs.c kfree(nsblk); nsblk 86 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 88 drivers/nvdimm/namespace_devs.c uuid2 = nsblk->uuid; nsblk 207 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk; nsblk 209 drivers/nvdimm/namespace_devs.c nsblk = to_nd_namespace_blk(&ndns->dev); nsblk 210 drivers/nvdimm/namespace_devs.c sprintf(name, "ndblk%d.%d%s", nd_region->id, nsblk->id, nsblk 232 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 234 drivers/nvdimm/namespace_devs.c return nsblk->uuid; nsblk 260 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 262 drivers/nvdimm/namespace_devs.c ns_altname = &nsblk->alt_name; nsblk 294 drivers/nvdimm/namespace_devs.c static resource_size_t nd_namespace_blk_size(struct nd_namespace_blk *nsblk) nsblk 296 drivers/nvdimm/namespace_devs.c struct nd_region *nd_region = to_nd_region(nsblk->common.dev.parent); nsblk 303 drivers/nvdimm/namespace_devs.c if (!nsblk->uuid) nsblk 305 drivers/nvdimm/namespace_devs.c nd_label_gen_id(&label_id, nsblk->uuid, NSLABEL_FLAG_LOCAL); nsblk 312 drivers/nvdimm/namespace_devs.c static bool __nd_namespace_blk_validate(struct nd_namespace_blk *nsblk) nsblk 314 drivers/nvdimm/namespace_devs.c struct nd_region *nd_region = to_nd_region(nsblk->common.dev.parent); nsblk 321 drivers/nvdimm/namespace_devs.c if (!nsblk->uuid || !nsblk->lbasize || !ndd) nsblk 325 drivers/nvdimm/namespace_devs.c nd_label_gen_id(&label_id, nsblk->uuid, NSLABEL_FLAG_LOCAL); nsblk 339 drivers/nvdimm/namespace_devs.c if (count != nsblk->num_resources) nsblk 342 drivers/nvdimm/namespace_devs.c for (i = 0; i < nsblk->num_resources; i++) { nsblk 346 drivers/nvdimm/namespace_devs.c if (res == nsblk->res[i]) { nsblk 358 drivers/nvdimm/namespace_devs.c resource_size_t nd_namespace_blk_validate(struct nd_namespace_blk *nsblk) nsblk 362 drivers/nvdimm/namespace_devs.c nvdimm_bus_lock(&nsblk->common.dev); nsblk 363 drivers/nvdimm/namespace_devs.c size = __nd_namespace_blk_validate(nsblk); nsblk 364 drivers/nvdimm/namespace_devs.c nvdimm_bus_unlock(&nsblk->common.dev); nsblk 394 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 395 drivers/nvdimm/namespace_devs.c resource_size_t size = nd_namespace_blk_size(nsblk); nsblk 397 drivers/nvdimm/namespace_devs.c if (size == 0 && nsblk->uuid) nsblk 399 drivers/nvdimm/namespace_devs.c else if (!nsblk->uuid || !nsblk->lbasize) nsblk 402 drivers/nvdimm/namespace_devs.c return nd_blk_namespace_label_update(nd_region, nsblk, size); nsblk 436 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 438 drivers/nvdimm/namespace_devs.c ns_altname = nsblk->alt_name; nsblk 991 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 993 drivers/nvdimm/namespace_devs.c uuid = nsblk->uuid; nsblk 995 drivers/nvdimm/namespace_devs.c id = nsblk->id; nsblk 1092 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 1094 drivers/nvdimm/namespace_devs.c uuid = &nsblk->uuid; nsblk 1177 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 1179 drivers/nvdimm/namespace_devs.c return nsblk->uuid; nsblk 1283 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 1285 drivers/nvdimm/namespace_devs.c ns_uuid = &nsblk->uuid; nsblk 1343 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 1345 drivers/nvdimm/namespace_devs.c return nd_size_select_show(nsblk->lbasize, nsblk 1367 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 1369 drivers/nvdimm/namespace_devs.c lbasize = &nsblk->lbasize; nsblk 1412 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); nsblk 1414 drivers/nvdimm/namespace_devs.c uuid = nsblk->uuid; nsblk 1745 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk; nsblk 1747 drivers/nvdimm/namespace_devs.c nsblk = to_nd_namespace_blk(&ndns->dev); nsblk 1748 drivers/nvdimm/namespace_devs.c if (uuid_not_set(nsblk->uuid, &ndns->dev, __func__)) nsblk 1750 drivers/nvdimm/namespace_devs.c if (!nsblk->lbasize) { nsblk 1754 drivers/nvdimm/namespace_devs.c if (!nd_namespace_blk_validate(nsblk)) nsblk 2038 drivers/nvdimm/namespace_devs.c struct nvdimm_drvdata *ndd, struct nd_namespace_blk *nsblk, nsblk 2044 drivers/nvdimm/namespace_devs.c nd_label_gen_id(&label_id, nsblk->uuid, NSLABEL_FLAG_LOCAL); nsblk 2045 drivers/nvdimm/namespace_devs.c res = krealloc(nsblk->res, nsblk 2046 drivers/nvdimm/namespace_devs.c sizeof(void *) * (nsblk->num_resources + 1), nsblk 2050 drivers/nvdimm/namespace_devs.c nsblk->res = (struct resource **) res; nsblk 2054 drivers/nvdimm/namespace_devs.c nsblk->res[nsblk->num_resources++] = res; nsblk 2062 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk; nsblk 2068 drivers/nvdimm/namespace_devs.c nsblk = kzalloc(sizeof(*nsblk), GFP_KERNEL); nsblk 2069 drivers/nvdimm/namespace_devs.c if (!nsblk) nsblk 2072 drivers/nvdimm/namespace_devs.c dev = &nsblk->common.dev; nsblk 2074 drivers/nvdimm/namespace_devs.c nsblk->id = ida_simple_get(&nd_region->ns_ida, 0, 0, GFP_KERNEL); nsblk 2075 drivers/nvdimm/namespace_devs.c if (nsblk->id < 0) { nsblk 2076 drivers/nvdimm/namespace_devs.c kfree(nsblk); nsblk 2079 drivers/nvdimm/namespace_devs.c dev_set_name(dev, "namespace%d.%d", nd_region->id, nsblk->id); nsblk 2083 drivers/nvdimm/namespace_devs.c return &nsblk->common.dev; nsblk 2222 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk; nsblk 2243 drivers/nvdimm/namespace_devs.c nsblk = kzalloc(sizeof(*nsblk), GFP_KERNEL); nsblk 2244 drivers/nvdimm/namespace_devs.c if (!nsblk) nsblk 2246 drivers/nvdimm/namespace_devs.c dev = &nsblk->common.dev; nsblk 2249 drivers/nvdimm/namespace_devs.c nsblk->id = -1; nsblk 2250 drivers/nvdimm/namespace_devs.c nsblk->lbasize = __le64_to_cpu(nd_label->lbasize); nsblk 2251 drivers/nvdimm/namespace_devs.c nsblk->uuid = kmemdup(nd_label->uuid, NSLABEL_UUID_LEN, nsblk 2254 drivers/nvdimm/namespace_devs.c nsblk->common.claim_class nsblk 2256 drivers/nvdimm/namespace_devs.c if (!nsblk->uuid) nsblk 2260 drivers/nvdimm/namespace_devs.c nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN, nsblk 2262 drivers/nvdimm/namespace_devs.c if (!nsblk->alt_name) nsblk 2265 drivers/nvdimm/namespace_devs.c res = nsblk_add_resource(nd_region, ndd, nsblk, nsblk 2379 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk; nsblk 2381 drivers/nvdimm/namespace_devs.c nsblk = kzalloc(sizeof(*nsblk), GFP_KERNEL); nsblk 2382 drivers/nvdimm/namespace_devs.c if (!nsblk) nsblk 2384 drivers/nvdimm/namespace_devs.c dev = &nsblk->common.dev; nsblk 2592 drivers/nvdimm/namespace_devs.c struct nd_namespace_blk *nsblk; nsblk 2594 drivers/nvdimm/namespace_devs.c nsblk = to_nd_namespace_blk(dev); nsblk 2597 drivers/nvdimm/namespace_devs.c nsblk->id = id; nsblk 157 drivers/nvdimm/nd-core.h struct nvdimm_drvdata *ndd, struct nd_namespace_blk *nsblk, nsblk 431 drivers/nvdimm/nd.h resource_size_t nd_namespace_blk_validate(struct nd_namespace_blk *nsblk);