Skip to content

Commit 8b1b41e

Browse files
committed
Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm fixes from Dan Williams: "None of these are showstoppers for 4.10 and could wait for 4.11 merge window, but they are low enough risk for this late in the cycle and the fixes have waiting users . They have received a build success notification from the 0day robot, pass the latest ndctl unit tests, and appeared in next: - Fix a crash that can result when SIGINT is sent to a process that is awaiting completion of an address range scrub command. We were not properly cleaning up the workqueue after wait_event_interruptible(). - Fix a memory hotplug failure condition that results from not reserving enough space out of persistent memory for the memmap. By default we align to 2M allocations that the memory hotplug code assumes, but if the administrator specifies a non-default 4K-alignment then we can fail to correctly size the reservation. - A one line fix to improve the predictability of libnvdimm block device names. A common operation is to reconfigure /dev/pmem0 into a different mode. For example, a reconfiguration might set a new mode that reserves some of the capacity for a struct page memmap array. It surprises users if the device name changes to "/dev/pmem0.1" after the mode change and then back to /dev/pmem0 after a reboot. - Add 'const' to some function pointer tables" * 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: libnvdimm, pfn: fix memmap reservation size versus 4K alignment acpi, nfit: fix acpi_nfit_flush_probe() crash libnvdimm, namespace: do not delete namespace-id 0 nvdimm: constify device_type structures
2 parents f7d6040 + bfb3452 commit 8b1b41e

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

drivers/acpi/nfit/core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,7 @@ static int acpi_nfit_flush_probe(struct nvdimm_bus_descriptor *nd_desc)
27042704
struct acpi_nfit_desc *acpi_desc = to_acpi_nfit_desc(nd_desc);
27052705
struct device *dev = acpi_desc->dev;
27062706
struct acpi_nfit_flush_work flush;
2707+
int rc;
27072708

27082709
/* bounce the device lock to flush acpi_nfit_add / acpi_nfit_notify */
27092710
device_lock(dev);
@@ -2716,7 +2717,10 @@ static int acpi_nfit_flush_probe(struct nvdimm_bus_descriptor *nd_desc)
27162717
INIT_WORK_ONSTACK(&flush.work, flush_probe);
27172718
COMPLETION_INITIALIZER_ONSTACK(flush.cmp);
27182719
queue_work(nfit_wq, &flush.work);
2719-
return wait_for_completion_interruptible(&flush.cmp);
2720+
2721+
rc = wait_for_completion_interruptible(&flush.cmp);
2722+
cancel_work_sync(&flush.work);
2723+
return rc;
27202724
}
27212725

27222726
static int acpi_nfit_clear_to_send(struct nvdimm_bus_descriptor *nd_desc,

drivers/nvdimm/namespace_devs.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ static void namespace_blk_release(struct device *dev)
5252
kfree(nsblk);
5353
}
5454

55-
static struct device_type namespace_io_device_type = {
55+
static const struct device_type namespace_io_device_type = {
5656
.name = "nd_namespace_io",
5757
.release = namespace_io_release,
5858
};
5959

60-
static struct device_type namespace_pmem_device_type = {
60+
static const struct device_type namespace_pmem_device_type = {
6161
.name = "nd_namespace_pmem",
6262
.release = namespace_pmem_release,
6363
};
6464

65-
static struct device_type namespace_blk_device_type = {
65+
static const struct device_type namespace_blk_device_type = {
6666
.name = "nd_namespace_blk",
6767
.release = namespace_blk_release,
6868
};
@@ -962,8 +962,8 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
962962
struct nvdimm_drvdata *ndd;
963963
struct nd_label_id label_id;
964964
u32 flags = 0, remainder;
965+
int rc, i, id = -1;
965966
u8 *uuid = NULL;
966-
int rc, i;
967967

968968
if (dev->driver || ndns->claim)
969969
return -EBUSY;
@@ -972,11 +972,13 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
972972
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
973973

974974
uuid = nspm->uuid;
975+
id = nspm->id;
975976
} else if (is_namespace_blk(dev)) {
976977
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
977978

978979
uuid = nsblk->uuid;
979980
flags = NSLABEL_FLAG_LOCAL;
981+
id = nsblk->id;
980982
}
981983

982984
/*
@@ -1039,10 +1041,11 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
10391041

10401042
/*
10411043
* Try to delete the namespace if we deleted all of its
1042-
* allocation, this is not the seed device for the region, and
1043-
* it is not actively claimed by a btt instance.
1044+
* allocation, this is not the seed or 0th device for the
1045+
* region, and it is not actively claimed by a btt, pfn, or dax
1046+
* instance.
10441047
*/
1045-
if (val == 0 && nd_region->ns_seed != dev && !ndns->claim)
1048+
if (val == 0 && id != 0 && nd_region->ns_seed != dev && !ndns->claim)
10461049
nd_device_unregister(dev, ND_ASYNC);
10471050

10481051
return rc;

drivers/nvdimm/pfn_devs.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,15 +627,12 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
627627
size = resource_size(&nsio->res);
628628
npfns = (size - start_pad - end_trunc - SZ_8K) / SZ_4K;
629629
if (nd_pfn->mode == PFN_MODE_PMEM) {
630-
unsigned long memmap_size;
631-
632630
/*
633631
* vmemmap_populate_hugepages() allocates the memmap array in
634632
* HPAGE_SIZE chunks.
635633
*/
636-
memmap_size = ALIGN(64 * npfns, HPAGE_SIZE);
637-
offset = ALIGN(start + SZ_8K + memmap_size + dax_label_reserve,
638-
nd_pfn->align) - start;
634+
offset = ALIGN(start + SZ_8K + 64 * npfns + dax_label_reserve,
635+
max(nd_pfn->align, HPAGE_SIZE)) - start;
639636
} else if (nd_pfn->mode == PFN_MODE_RAM)
640637
offset = ALIGN(start + SZ_8K + dax_label_reserve,
641638
nd_pfn->align) - start;

0 commit comments

Comments
 (0)