[ndctl PATCH] ndctl: --enable-destructive implies --enable-test
by Dan Williams
Currently the build fails if --enable-destructive is specified without
--enable-test, but --enable-destructive assumes that --enable-test is
already specified. Just force --enable-test to satisfy the requirement.
Reported-by: Ross Zwisler <ross.zwisler(a)linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
configure.ac | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 01f4345fa263..126fc6bf16ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -92,13 +92,6 @@ AS_IF([test "x$enable_debug" = "xyes"], [
AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
])
-AC_ARG_ENABLE([test],
- AS_HELP_STRING([--enable-test], [enable ndctl test command @<:@default=disabled@:>@]),
- [], [enable_test=no])
-AS_IF([test "x$enable_test" = "xyes"],
- [AC_DEFINE([ENABLE_TEST], [1], [ndctl test support])])
-AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = "xyes"])
-
AC_ARG_ENABLE([destructive],
AS_HELP_STRING([--enable-destructive], [enable destructive functional tests @<:@default=disabled@:>@]),
[], [enable_destructive=no])
@@ -106,6 +99,13 @@ AS_IF([test "x$enable_destructive" = "xyes"],
[AC_DEFINE([ENABLE_DESTRUCTIVE], [1], [destructive functional tests support])])
AM_CONDITIONAL([ENABLE_DESTRUCTIVE], [test "x$enable_destructive" = "xyes"])
+AC_ARG_ENABLE([test],
+ AS_HELP_STRING([--enable-test], [enable ndctl test command @<:@default=disabled@:>@]),
+ [], [enable_test=$enable_destructive])
+AS_IF([test "x$enable_test" = "xyes"],
+ [AC_DEFINE([ENABLE_TEST], [1], [ndctl test support])])
+AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = "xyes"])
+
PKG_CHECK_MODULES([KMOD], [libkmod])
PKG_CHECK_MODULES([UDEV], [libudev])
PKG_CHECK_MODULES([UUID], [uuid])
5 years, 11 months
[PATCH] ndctl: fix --enable-destructive build failure
by Ross Zwisler
This commit:
commit 0d119368385a ("ndctl: reorganize file structure, use per sub-directory makefiles")
reorganized the file structure & makefiles in ndctl, but broke builds that
used the --enable-destructive option. Here are some of the failure
messages:
../test/blk_namespaces.o: In function `test_blk_namespaces':
/root/project/ndctl/ndctl/../test/blk_namespaces.c:222: undefined reference to `__ndctl_test_attempt'
/root/project/ndctl/ndctl/../test/blk_namespaces.c:250: undefined reference to `__ndctl_test_skip'
The root cause of this build failure was that when --enable-destructive was
being set, test/core.c wasn't being compiled and included in the build,
hence the undefined references.
Fix the makefile to include test/core.c.
Signed-off-by: Ross Zwisler <ross.zwisler(a)linux.intel.com>
---
ndctl/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
index 56cd929..47e0044 100644
--- a/ndctl/Makefile.am
+++ b/ndctl/Makefile.am
@@ -53,7 +53,8 @@ endif
if ENABLE_DESTRUCTIVE
ndctl_SOURCES += ../test/blk_namespaces.c \
../test/pmem_namespaces.c \
- ../test/pcommit.c
+ ../test/pcommit.c \
+ ../test/core.c
ndctl_SOURCES += builtin-bat.c
endif
--
2.9.0
5 years, 11 months
[PATCH] block: remove BLK_DEV_DAX config option
by Ross Zwisler
The functionality for block device DAX was already removed with this
commit:
commit acc93d30d7d4 ("Revert "block: enable dax for raw block devices"")
However, we still had a config option hanging around that was always
disabled because it depended on CONFIG_BROKEN. This config option was
introduced in this commit:
commit 03cdadb04077 ("block: disable block device DAX by default")
This change reverts that commit, removing the dead config option.
Signed-off-by: Ross Zwisler <ross.zwisler(a)linux.intel.com>
Cc: Dave Hansen <dave.hansen(a)linux.intel.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
---
block/Kconfig | 13 -------------
fs/block_dev.c | 5 +----
2 files changed, 1 insertion(+), 17 deletions(-)
diff --git a/block/Kconfig b/block/Kconfig
index 0363cd7..161491d 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -88,19 +88,6 @@ config BLK_DEV_INTEGRITY
T10/SCSI Data Integrity Field or the T13/ATA External Path
Protection. If in doubt, say N.
-config BLK_DEV_DAX
- bool "Block device DAX support"
- depends on FS_DAX
- depends on BROKEN
- help
- When DAX support is available (CONFIG_FS_DAX) raw block
- devices can also support direct userspace access to the
- storage capacity via MMAP(2) similar to a file on a
- DAX-enabled filesystem. However, the DAX I/O-path disables
- some standard I/O-statistics, and the MMAP(2) path has some
- operational differences due to bypassing the page
- cache. If in doubt, say N.
-
config BLK_DEV_THROTTLING
bool "Block layer bio throttling support"
depends on BLK_CGROUP=y
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 71ccab1..ab7ebee 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1287,10 +1287,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
bdev->bd_disk = disk;
bdev->bd_queue = disk->queue;
bdev->bd_contains = bdev;
- if (IS_ENABLED(CONFIG_BLK_DEV_DAX) && disk->fops->direct_access)
- bdev->bd_inode->i_flags = S_DAX;
- else
- bdev->bd_inode->i_flags = 0;
+ bdev->bd_inode->i_flags = 0;
if (!partno) {
ret = -ENXIO;
--
2.9.0
5 years, 11 months
[ndctl PATCH v2] ndctl: print 'size' when creating/listing BTT namespaces
by Vishal Verma
Print the usable size of a BTT namespace after removing driver overhead
in the json for listing/creating a BTT namespace. This makes it
consistent with other flavors of namespaces (dax, pfn).
Cc: Dan Williams <dan.j.williams(a)intel.com>
Reported-by: Linda Knippers <linda.knippers(a)hpe.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
v2:
- For a create-namespace command, size was not shown as expected, and as
it did for 'ndctl list'. This was because after creating the namespace,
the 'size' field in the existing list of BTTs in libndctl needed to be
updated with the new value found in sysfs. Add this missing update.
ndctl/lib/libndctl.c | 14 ++++++++++++++
ndctl/lib/libndctl.sym | 1 +
ndctl/libndctl.h.in | 1 +
ndctl/util/json.c | 1 +
4 files changed, 17 insertions(+)
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 0722f79..8ad62c6 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -271,6 +271,7 @@ struct ndctl_namespace {
* struct ndctl_btt - stacked block device provided sector atomicity
* @module: kernel module (nd_btt)
* @lbasize: sector size info
+ * @size: usable size of the btt after removing metadata etc
* @ndns: host namespace for the btt instance
* @region: parent region
* @btt_path: btt devpath
@@ -284,6 +285,7 @@ struct ndctl_btt {
struct ndctl_namespace *ndns;
struct list_node list;
struct ndctl_lbasize lbasize;
+ unsigned long long size;
char *btt_path;
char *btt_buf;
char *bdev;
@@ -3614,9 +3616,16 @@ static int add_btt(void *parent, int id, const char *btt_base)
if (parse_lbasize_supported(ctx, devname, buf, &btt->lbasize) < 0)
goto err_read;
+ sprintf(path, "%s/size", btt_base);
+ if (sysfs_read_attr(ctx, path, buf) < 0)
+ btt->size = ULLONG_MAX;
+ else
+ btt->size = strtoull(buf, NULL, 0);
+
free(path);
ndctl_btt_foreach(region, btt_dup)
if (btt->id == btt_dup->id) {
+ btt_dup->size = btt->size;
free_btt(btt, NULL);
return 1;
}
@@ -3705,6 +3714,11 @@ NDCTL_EXPORT void ndctl_btt_get_uuid(struct ndctl_btt *btt, uuid_t uu)
memcpy(uu, btt->uuid, sizeof(uuid_t));
}
+NDCTL_EXPORT unsigned long long ndctl_btt_get_size(struct ndctl_btt *btt)
+{
+ return btt->size;
+}
+
NDCTL_EXPORT int ndctl_btt_set_uuid(struct ndctl_btt *btt, uuid_t uu)
{
struct ndctl_ctx *ctx = ndctl_btt_get_ctx(btt);
diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index 6af267a..b5d2866 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -196,6 +196,7 @@ global:
ndctl_btt_get_num_sector_sizes;
ndctl_btt_get_namespace;
ndctl_btt_get_uuid;
+ ndctl_btt_get_size;
ndctl_btt_is_enabled;
ndctl_btt_is_valid;
ndctl_btt_get_devname;
diff --git a/ndctl/libndctl.h.in b/ndctl/libndctl.h.in
index 9e0e82a..451466a 100644
--- a/ndctl/libndctl.h.in
+++ b/ndctl/libndctl.h.in
@@ -521,6 +521,7 @@ unsigned int ndctl_btt_get_sector_size(struct ndctl_btt *btt);
int ndctl_btt_get_num_sector_sizes(struct ndctl_btt *btt);
struct ndctl_namespace *ndctl_btt_get_namespace(struct ndctl_btt *btt);
void ndctl_btt_get_uuid(struct ndctl_btt *btt, uuid_t uu);
+unsigned long long ndctl_btt_get_size(struct ndctl_btt *btt);
int ndctl_btt_is_enabled(struct ndctl_btt *btt);
int ndctl_btt_is_valid(struct ndctl_btt *btt);
const char *ndctl_btt_get_devname(struct ndctl_btt *btt);
diff --git a/ndctl/util/json.c b/ndctl/util/json.c
index a9c096c..c727bc2 100644
--- a/ndctl/util/json.c
+++ b/ndctl/util/json.c
@@ -174,6 +174,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns)
break;
case NDCTL_NS_MODE_SAFE:
jobj = json_object_new_string("sector");
+ size = ndctl_btt_get_size(btt);
break;
case NDCTL_NS_MODE_RAW:
size = ndctl_namespace_get_size(ndns);
--
2.7.4
5 years, 11 months
[PATCH] nfit: Get rid of CONFIG_ACPI_NFIT_DEBUG
by Johannes Thumshirn
CONFIG_ACPI_NFIT_DEBUG is currently used to dump the buffers used in NFIT _DSM
calls. Within the statements guarded by CONFIG_ACPI_NFIT_DEBUG we use dynamic
debugging as well as print_hex_dump_debug(). Change the print_hex_dump_debug()
call to dynamic_hex_dump() so we can enable it on demand and at runtime, not
dependend on a compile time option.
Signed-off-by: Johannes Thumshirn <jthumshirn(a)suse.de>
---
drivers/acpi/Kconfig | 12 ------------
drivers/acpi/nfit.c | 28 +++++++++++++---------------
2 files changed, 13 insertions(+), 27 deletions(-)
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index b7e2e77..659fb1c 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -462,18 +462,6 @@ config ACPI_NFIT
To compile this driver as a module, choose M here:
the module will be called nfit.
-config ACPI_NFIT_DEBUG
- bool "NFIT DSM debug"
- depends on ACPI_NFIT
- depends on DYNAMIC_DEBUG
- default n
- help
- Enabling this option causes the nfit driver to dump the
- input and output buffers of _DSM operations on the ACPI0012
- device and its children. This can be very verbose, so leave
- it disabled unless you are debugging a hardware / firmware
- issue.
-
source "drivers/acpi/apei/Kconfig"
config ACPI_EXTLOG
diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index 1f0e060..ddff49d 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -246,14 +246,13 @@ static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
in_buf.buffer.length = call_pkg->nd_size_in;
}
- if (IS_ENABLED(CONFIG_ACPI_NFIT_DEBUG)) {
- dev_dbg(dev, "%s:%s cmd: %d: func: %d input length: %d\n",
- __func__, dimm_name, cmd, func,
- in_buf.buffer.length);
- print_hex_dump_debug("nvdimm in ", DUMP_PREFIX_OFFSET, 4, 4,
- in_buf.buffer.pointer,
- min_t(u32, 256, in_buf.buffer.length), true);
- }
+ dev_dbg(dev, "%s:%s cmd: %d: func: %d input length: %d\n",
+ __func__, dimm_name, cmd, func,
+ in_buf.buffer.length);
+
+ dynamic_hex_dump("nvdimm in ", DUMP_PREFIX_OFFSET, 4, 4,
+ in_buf.buffer.pointer,
+ min_t(u32, 256, in_buf.buffer.length), true);
out_obj = acpi_evaluate_dsm(handle, uuid, 1, func, &in_obj);
if (!out_obj) {
@@ -285,13 +284,12 @@ static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
goto out;
}
- if (IS_ENABLED(CONFIG_ACPI_NFIT_DEBUG)) {
- dev_dbg(dev, "%s:%s cmd: %s output length: %d\n", __func__,
- dimm_name, cmd_name, out_obj->buffer.length);
- print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4,
- 4, out_obj->buffer.pointer, min_t(u32, 128,
- out_obj->buffer.length), true);
- }
+ dev_dbg(dev, "%s:%s cmd: %s output length: %d\n", __func__,
+ dimm_name, cmd_name, out_obj->buffer.length);
+
+ dynamic_hex_dump(cmd_name, DUMP_PREFIX_OFFSET, 4,
+ 4, out_obj->buffer.pointer,
+ min_t(u32, 128, out_obj->buffer.length), true);
for (i = 0, offset = 0; i < desc->out_num; i++) {
u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i, buf,
--
1.8.5.6
5 years, 11 months
[GIT PULL] libnvdimm for 4.8
by Williams, Dan J
Hi Linus, please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm tags/libnvdimm-for-4.8
...to receive the libnvdimm update for 4.8.
This has been in -next with the following reported conflicts:
1/ The __pmem address space has been removed. New usages of __pmem
came in through the DM tree this cycle.
2/ A minor conflict in the pmem driver with the device_add_disk()
changes that came in through the block layer.
3/ The removal of pcommit collided with new enabling in KVM. At the
time of writing you have not yet merged the KVM tree.
A test resolution for 1 and 2 is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-for-4.8-merge
Stephen's resolution of the KVM conflict is available here:
https://lkml.org/lkml/2016/7/25/11
The pcommit removal in arch/x86/ has an ack from Ingo.
---
The following changes since commit a72255983f12f31f0c8d8275fb1a781546cfacb7:
nfit: make DIMM DSMs optional (2016-07-19 12:32:39 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm tags/libnvdimm-for-4.8
for you to fetch changes up to 0606263f24f3d64960de742c55894190b5df903b:
Merge branch 'for-4.8/libnvdimm' into libnvdimm-for-next (2016-07-24 08:05:44 -0700)
----------------------------------------------------------------
libnvdimm for 4.8
1/ Replace pcommit with ADR / directed-flushing:
The pcommit instruction, which has not shipped on any product, is
deprecated. Instead, the requirement is that platforms implement either
ADR, or provide one or more flush addresses per nvdimm. ADR
(Asynchronous DRAM Refresh) flushes data in posted write buffers to the
memory controller on a power-fail event. Flush addresses are defined in
ACPI 6.x as an NVDIMM Firmware Interface Table (NFIT) sub-structure:
"Flush Hint Address Structure". A flush hint is an mmio address that
when written and fenced assures that all previous posted writes
targeting a given dimm have been flushed to media.
2/ On-demand ARS (address range scrub):
Linux uses the results of the ACPI ARS commands to track bad blocks
in pmem devices. When latent errors are detected we re-scrub the media
to refresh the bad block list, userspace can also request a re-scrub at
any time.
3/ Support for the Microsoft DSM (device specific method) command format.
4/ Support for EDK2/OVMF virtual disk device memory ranges.
5/ Various fixes and cleanups across the subsystem.
----------------------------------------------------------------
Dan Williams (32):
libnvdimm: use devm_add_action_or_reset()
libnvdimm: IS_ERR() usage cleanup
tools/testing/nvdimm: add pfn device dependency
libnvdimm, pmem: allow nfit_test to override pmem_direct_access()
tools/testing/nvdimm: replace CONFIG_DMA_CMA dependency with vmalloc()
tools/testing/nvdimm: remove __wrap_devm_memremap_pages placeholder
nfit: always associate flush hints
nfit: don't override return value of nfit_mem_init
libnvdimm: introduce devm_nvdimm_memremap(), convert nfit_spa_map() users
libnvdimm, nfit: remove nfit_spa_map() infrastructure
libnvdimm, nfit: move flush hint mapping to region-device driver-data
tools/testing/nvdimm: simulate multiple flush hints per-dimm
libnvdimm: keep region data alive over namespace removal
libnvdimm: introduce nvdimm_flush() and nvdimm_has_flush()
libnvdimm: cycle flush hints
libnvdimm, pmem: use REQ_FUA, REQ_FLUSH for nvdimm_flush()
libnvdimm, pmem: flush posted-write queues on shutdown
fs/dax: remove wmb_pmem()
libnvdimm, pmem: use nvdimm_flush() for namespace I/O writes
pmem: kill wmb_pmem()
pmem: kill __pmem address space
tools/testing/nvdimm: add virtual ramdisk range
tools/testing/nvdimm: add manufacturing_{date|location} dimm properties
nfit: fix _FIT evaluation memory leak + use after free
nfit: cleanup acpi_nfit_init calling convention
libnvdimm: move ->module to struct nvdimm_bus_descriptor
nfit, tools/testing/nvdimm/: unify shutdown paths
Revert "KVM: x86: add pcommit support"
x86/insn: remove pcommit
libnvdimm: register nvdimm_bus devices with an nd_bus driver
nfit: move to nfit/ sub-directory
Merge branch 'for-4.8/libnvdimm' into libnvdimm-for-next
Johannes Thumshirn (1):
libnvdimm: initialize struct blk_integrity with 0
Lee, Chun-Yi (1):
acpi, nfit: treat virtual ramdisk SPA as pmem region
Markus Elfring (1):
libnvdimm-btt: Delete an unnecessary check before the function call "__nd_device_register"
Sajjan, Vikas C (2):
nfit: use devm_add_action_or_reset()
dax: use devm_add_action_or_reset()
Vishal Verma (4):
libnvdimm, btt: update the usage section in Documentation
pmem: clarify a debug print in pmem_clear_poison
nfit, libnvdimm: allow an ARS scrub to be triggered on demand
nfit: do an ARS scrub on hitting a latent media error
stuart hayes (1):
nfit: add Microsoft NVDIMM DSM command set to white list
Documentation/filesystems/Locking | 2 +-
Documentation/nvdimm/btt.txt | 28 +-
arch/powerpc/sysdev/axonram.c | 4 +-
arch/x86/include/asm/cpufeatures.h | 1 -
arch/x86/include/asm/pmem.h | 77 +--
arch/x86/include/asm/special_insns.h | 46 --
arch/x86/include/asm/vmx.h | 1 -
arch/x86/include/uapi/asm/vmx.h | 4 +-
arch/x86/kvm/cpuid.c | 2 +-
arch/x86/kvm/cpuid.h | 8 -
arch/x86/kvm/vmx.c | 32 +-
arch/x86/lib/x86-opcode-map.txt | 2 +-
drivers/acpi/Kconfig | 27 +-
drivers/acpi/Makefile | 2 +-
drivers/acpi/nfit/Kconfig | 26 +
drivers/acpi/nfit/Makefile | 3 +
drivers/acpi/{nfit.c => nfit/core.c} | 647 ++++++++++++---------
drivers/acpi/nfit/mce.c | 89 +++
drivers/acpi/{ => nfit}/nfit.h | 60 +-
drivers/block/brd.c | 4 +-
drivers/dax/dax.c | 6 +-
drivers/dax/pmem.c | 14 +-
drivers/nvdimm/Kconfig | 2 +-
drivers/nvdimm/blk.c | 11 +-
drivers/nvdimm/btt_devs.c | 3 +-
drivers/nvdimm/bus.c | 212 ++++++-
drivers/nvdimm/claim.c | 7 +-
drivers/nvdimm/core.c | 253 ++++----
drivers/nvdimm/dimm_devs.c | 5 +-
drivers/nvdimm/e820.c | 1 +
drivers/nvdimm/nd-core.h | 5 +-
drivers/nvdimm/nd.h | 10 +-
drivers/nvdimm/pmem.c | 85 +--
drivers/nvdimm/pmem.h | 24 +
drivers/nvdimm/region.c | 19 +-
drivers/nvdimm/region_devs.c | 154 ++++-
drivers/s390/block/dcssblk.c | 6 +-
fs/dax.c | 13 +-
include/linux/blkdev.h | 6 +-
include/linux/compiler.h | 2 -
include/linux/libnvdimm.h | 24 +-
include/linux/nd.h | 3 +-
include/linux/pfn_t.h | 5 +-
include/linux/pmem.h | 117 +---
include/uapi/linux/ndctl.h | 1 +
kernel/memremap.c | 6 -
scripts/checkpatch.pl | 1 -
tools/objtool/arch/x86/insn/x86-opcode-map.txt | 2 +-
tools/perf/arch/x86/tests/insn-x86-dat-32.c | 2 -
tools/perf/arch/x86/tests/insn-x86-dat-64.c | 2 -
tools/perf/arch/x86/tests/insn-x86-dat-src.c | 4 -
.../perf/util/intel-pt-decoder/x86-opcode-map.txt | 2 +-
tools/testing/nvdimm/Kbuild | 10 +-
tools/testing/nvdimm/config_check.c | 1 +
tools/testing/nvdimm/pmem-dax.c | 54 ++
tools/testing/nvdimm/test/Kbuild | 2 +-
tools/testing/nvdimm/test/iomap.c | 38 +-
tools/testing/nvdimm/test/nfit.c | 199 +++----
tools/testing/nvdimm/test/nfit_test.h | 2 +
59 files changed, 1369 insertions(+), 1009 deletions(-)
create mode 100644 drivers/acpi/nfit/Kconfig
create mode 100644 drivers/acpi/nfit/Makefile
rename drivers/acpi/{nfit.c => nfit/core.c} (87%)
create mode 100644 drivers/acpi/nfit/mce.c
rename drivers/acpi/{ => nfit}/nfit.h (82%)
create mode 100644 drivers/nvdimm/pmem.h
create mode 100644 tools/testing/nvdimm/pmem-dax.c
5 years, 11 months
[PATCH v2] nvdimm, btt: add a size attribute for BTTs
by Vishal Verma
To be consistent with other namespaces, expose a 'size' attribute for
BTT devices also.
Cc: Dan Williams <dan.j.williams(a)intel.com>
Reported-by: Linda Knippers <linda.knippers(a)hpe.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
v2:
- Use the correct locking in size_show (Dan)
- Use a typecast for 64b multiplication
drivers/nvdimm/btt.c | 1 +
drivers/nvdimm/btt_devs.c | 20 ++++++++++++++++++++
drivers/nvdimm/nd.h | 1 +
3 files changed, 22 insertions(+)
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 68a7c3c..e0084ae 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1270,6 +1270,7 @@ static int btt_blk_init(struct btt *btt)
}
}
set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
+ btt->nd_btt->size = btt->nlba * (u64)btt->sector_size;
revalidate_disk(btt->btt_disk);
return 0;
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 3fa7919..97dd292 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -140,10 +140,30 @@ static ssize_t namespace_store(struct device *dev,
}
static DEVICE_ATTR_RW(namespace);
+static ssize_t size_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct nd_btt *nd_btt = to_nd_btt(dev);
+ ssize_t rc;
+
+ device_lock(dev);
+ if (dev->driver)
+ rc = sprintf(buf, "%llu\n", nd_btt->size);
+ else {
+ /* no size to convey if the btt instance is disabled */
+ rc = -ENXIO;
+ }
+ device_unlock(dev);
+
+ return rc;
+}
+static DEVICE_ATTR_RO(size);
+
static struct attribute *nd_btt_attributes[] = {
&dev_attr_sector_size.attr,
&dev_attr_namespace.attr,
&dev_attr_uuid.attr,
+ &dev_attr_size.attr,
NULL,
};
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 4047639..8024a0e 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -143,6 +143,7 @@ struct nd_btt {
struct nd_namespace_common *ndns;
struct btt *btt;
unsigned long lbasize;
+ u64 size;
u8 *uuid;
int id;
};
--
2.7.4
5 years, 11 months
Re: btt ndctl question
by Vishal Verma
On 07/26, Linda Knippers wrote:
> My system has 4 8G NVDIMMs and I have them configured in different ways, as you can
> see from the ndctl output:
>
> $ ndctl list
> [
> {
> "dev":"namespace3.0",
> "mode":"raw",
> "size":8589934592,
> "blockdev":"pmem3"
> },
> {
> "dev":"namespace2.0",
> "mode":"memory",
> "size":8587837440,
> "uuid":"2567d762-68ae-486b-a6eb-2d3ab1b9dca9",
> "blockdev":"pmem2"
> },
> {
> "dev":"namespace1.0",
> "mode":"sector",
> "uuid":"44fb474e-7db8-4438-ad95-05ecb9f2075e",
> "sector_size":4096,
> "blockdev":"pmem1s"
> },
> {
> "dev":"namespace0.0",
> "mode":"memory",
> "size":8453619712,
> "uuid":"933ed54b-5b64-47f1-8409-c88f7c846522",
> "blockdev":"pmem0"
> }
> ]
>
> The two memory namespaces have different sizes because one is --map=dev and the other is --map=mem.
> It would be nice if the map option was displayed but my question is about the size value for the
> btt device, or lack of one.
>
> All the namespaces show a size except for the btt. The btt only shows a sector size. There
> is no size value exposed by the btt sysfs information, which is probably why it's not in ndctl.
>
> I know the size can be gotten from the block device but it looks like an omission here.
> Is this a bug or a feature?
Probably an omission :)
This patch should expose a size attribute in sysfs:
$ cat /sys/bus/nd/devices/btt7.0/size
32440320
I can look at the 'ndctl list' enabling too if this looks good.
8<------
>From fb119bf4380d1d65d82754e581bbd41161c2100f Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.verma(a)intel.com>
Date: Tue, 26 Jul 2016 14:54:39 -0600
Subject: [PATCH] nvdimm, btt: add a size attribute for BTTs
To be consistent with other namespaces, expose a 'size' attribute for
BTT devices also.
Cc: Dan Williams <dan.j.williams(a)intel.com>
Reported-by: Linda Knippers <linda.knippers(a)hpe.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
drivers/nvdimm/btt.c | 1 +
drivers/nvdimm/btt_devs.c | 15 +++++++++++++++
drivers/nvdimm/nd.h | 1 +
3 files changed, 17 insertions(+)
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 68a7c3c..71ce0dc 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1270,6 +1270,7 @@ static int btt_blk_init(struct btt *btt)
}
}
set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
+ btt->nd_btt->size = btt->nlba * btt->sector_size;
revalidate_disk(btt->btt_disk);
return 0;
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 3fa7919..b54cfc7 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -140,10 +140,25 @@ static ssize_t namespace_store(struct device *dev,
}
static DEVICE_ATTR_RW(namespace);
+
+static ssize_t size_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct nd_btt *nd_btt = to_nd_btt(dev);
+ ssize_t rc;
+
+ nvdimm_bus_lock(dev);
+ rc = sprintf(buf, "%llu\n", nd_btt->size);
+ nvdimm_bus_unlock(dev);
+ return rc;
+}
+static DEVICE_ATTR_RO(size);
+
static struct attribute *nd_btt_attributes[] = {
&dev_attr_sector_size.attr,
&dev_attr_namespace.attr,
&dev_attr_uuid.attr,
+ &dev_attr_size.attr,
NULL,
};
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 4047639..8024a0e 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -143,6 +143,7 @@ struct nd_btt {
struct nd_namespace_common *ndns;
struct btt *btt;
unsigned long lbasize;
+ u64 size;
u8 *uuid;
int id;
};
--
2.7.4
>
> -- ljk
5 years, 11 months
[ndctl PATCH] ndctl: print 'size' when creating/listing BTT namespaces
by Vishal Verma
Print the usable size of a BTT namespace after removing driver overhead
in the json for listing/creating a BTT namespace. This makes it
consistent with other flavors of namespaces (dax, pfn).
Cc: Dan Williams <dan.j.williams(a)intel.com>
Reported-by: Linda Knippers <linda.knippers(a)hpe.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
ndctl/lib/libndctl.c | 13 +++++++++++++
ndctl/lib/libndctl.sym | 1 +
ndctl/libndctl.h.in | 1 +
ndctl/util/json.c | 1 +
4 files changed, 16 insertions(+)
This is a bit of an RFC patch as I have a couple of open questions/issues:
1. If this is used with an older kernel that doesn't expose btt/size in
sysfs, and if a user uses the new API (ndctl_btt_get_size), they will
get ULLONG_MAX. Should we change this, or otherwise version the API..
2. In the json printed right after namespace creation, 'size' will show
up as zero, and subsequent listings will show the right size:
# ndctl create-namespace --mode=sector
{
"dev":"namespace7.0",
"mode":"sector",
"size":0,
"uuid":"ae706db9-55a0-48e0-8579-ccd717a2b6c1",
"sector_size":4096,
"blockdev":"pmem7s"
}
# ndctl list --namespace=namespace7.0
{
"dev":"namespace7.0",
"mode":"sector",
"size":32440320,
"uuid":"ae706db9-55a0-48e0-8579-ccd717a2b6c1",
"sector_size":4096,
"blockdev":"pmem7s"
}
I'm not sure how to fix this - still looking into it.
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 0722f79..ece3c4a 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -271,6 +271,7 @@ struct ndctl_namespace {
* struct ndctl_btt - stacked block device provided sector atomicity
* @module: kernel module (nd_btt)
* @lbasize: sector size info
+ * @size: usable size of the btt after removing metadata etc
* @ndns: host namespace for the btt instance
* @region: parent region
* @btt_path: btt devpath
@@ -284,6 +285,7 @@ struct ndctl_btt {
struct ndctl_namespace *ndns;
struct list_node list;
struct ndctl_lbasize lbasize;
+ unsigned long long size;
char *btt_path;
char *btt_buf;
char *bdev;
@@ -3614,6 +3616,12 @@ static int add_btt(void *parent, int id, const char *btt_base)
if (parse_lbasize_supported(ctx, devname, buf, &btt->lbasize) < 0)
goto err_read;
+ sprintf(path, "%s/size", btt_base);
+ if (sysfs_read_attr(ctx, path, buf) < 0)
+ btt->size = ULLONG_MAX;
+ else
+ btt->size = strtoull(buf, NULL, 0);
+
free(path);
ndctl_btt_foreach(region, btt_dup)
if (btt->id == btt_dup->id) {
@@ -3705,6 +3713,11 @@ NDCTL_EXPORT void ndctl_btt_get_uuid(struct ndctl_btt *btt, uuid_t uu)
memcpy(uu, btt->uuid, sizeof(uuid_t));
}
+NDCTL_EXPORT unsigned long long ndctl_btt_get_size(struct ndctl_btt *btt)
+{
+ return btt->size;
+}
+
NDCTL_EXPORT int ndctl_btt_set_uuid(struct ndctl_btt *btt, uuid_t uu)
{
struct ndctl_ctx *ctx = ndctl_btt_get_ctx(btt);
diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index 6af267a..b5d2866 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -196,6 +196,7 @@ global:
ndctl_btt_get_num_sector_sizes;
ndctl_btt_get_namespace;
ndctl_btt_get_uuid;
+ ndctl_btt_get_size;
ndctl_btt_is_enabled;
ndctl_btt_is_valid;
ndctl_btt_get_devname;
diff --git a/ndctl/libndctl.h.in b/ndctl/libndctl.h.in
index 9e0e82a..451466a 100644
--- a/ndctl/libndctl.h.in
+++ b/ndctl/libndctl.h.in
@@ -521,6 +521,7 @@ unsigned int ndctl_btt_get_sector_size(struct ndctl_btt *btt);
int ndctl_btt_get_num_sector_sizes(struct ndctl_btt *btt);
struct ndctl_namespace *ndctl_btt_get_namespace(struct ndctl_btt *btt);
void ndctl_btt_get_uuid(struct ndctl_btt *btt, uuid_t uu);
+unsigned long long ndctl_btt_get_size(struct ndctl_btt *btt);
int ndctl_btt_is_enabled(struct ndctl_btt *btt);
int ndctl_btt_is_valid(struct ndctl_btt *btt);
const char *ndctl_btt_get_devname(struct ndctl_btt *btt);
diff --git a/ndctl/util/json.c b/ndctl/util/json.c
index a9c096c..c727bc2 100644
--- a/ndctl/util/json.c
+++ b/ndctl/util/json.c
@@ -174,6 +174,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns)
break;
case NDCTL_NS_MODE_SAFE:
jobj = json_object_new_string("sector");
+ size = ndctl_btt_get_size(btt);
break;
case NDCTL_NS_MODE_RAW:
size = ndctl_namespace_get_size(ndns);
--
2.7.4
5 years, 11 months