libndctl: Use the supported_alignment attribute
PATCH v5 1/7 libndctl: Use the supported_alignment attribute
Newer kernels provide the "supported_alignments" sysfs attribute that indicates what alignments can be used with a PFN or DAX namespace. This patch adds the plumbing inside of libndctl to allow users to query this information through using:
ndctl_{dax|pfn}_get_supported_alignment(), and ndctl_{dax|pfn}_get_num_alignments()
---
v5: Fixed comment wording
v4: Changed return code of ndctl_pfn_get_supported_alignment from -1 to
-1 to -EINVAL.
Reworded comment about why we default to 4K and 2M alignments when the sysfs attribute is missing.
Shuffled around prototypes in ndctl.h.
80 char compliance fixes.
rebased onto pending branch
v3: Changed the return type of the *_get_supported_alignment() functions
to unsigned long to match the existing *_get_alignment() functions.
--- ndctl/lib/libndctl.c | 43 ++++++++++++++++++++++++++++++++++++++++++ ndctl/lib/libndctl.sym | 4 ++++ ndctl/libndctl.h | 4 ++++ 3 files changed, 51 insertions(+)
ndctl/lib/libndctl.c +43 -0
@@ -31,6 +31,7 @@#include <ccan/build_assert/build_assert.h> #include <ndctl.h> +#include <util/size.h> #include <util/sysfs.h> #include <ndctl/libndctl.h> #include <ndctl/namespace.h>
@@ -237,6 +238,7 @@ struct ndctl_pfn {int buf_len;uuid_t uuid;int id, generation; +struct ndctl_lbasize alignments; };struct ndctl_dax {
@@ -4814,6 +4816,19 @@ static void *__add_pfn(struct ndctl_pfn *pfn, const char *pfn_base)else pfn->size =strtoull (buf,NULL ,0 ); +/* +* The supported_alignments attribute was added before arches other +* than x86 had pmem support. If the kernel doesn't provide the +* attribute then it's safe to assume that we running on x86 where +* 4KiB and 2MiB have always been supported. +*/ +sprintf (path,"%s/supported_alignments" , pfn_base); +if (sysfs_read_attr (ctx, path, buf) <0 ) +sprintf (buf,"%d %d" ,SZ_4K ,SZ_2M ); + +if (parse_lbasize_supported (ctx, pfn_base, buf, &pfn->alignments) <0 ) + goto err_read; +free (path);return pfn;
@@ -5048,6 +5063,23 @@ NDCTL_EXPORT int ndctl_pfn_set_align(struct ndctl_pfn *pfn, unsigned long align)return 0 ; } +NDCTL_EXPORT int ndctl_pfn_get_num_alignments(struct ndctl_pfn *pfn) +{ +return pfn->alignments.num; +} + +NDCTL_EXPORT unsigned long ndctl_pfn_get_supported_alignment ( +struct ndctl_pfn *pfn,int i) +{ +if (pfn->alignments.num ==0 ) +return 0 ; + +if (i <0 || i > pfn->alignments.num) +return -EINVAL ; +else +return pfn->alignments.supported[i]; +} + NDCTL_EXPORT int ndctl_pfn_set_namespace(struct ndctl_pfn *pfn,struct ndctl_namespace *ndns) {
@@ -5270,6 +5302,17 @@ NDCTL_EXPORT unsigned long ndctl_dax_get_align(struct ndctl_dax *dax)return ndctl_pfn_get_align (&dax->pfn); } +NDCTL_EXPORT int ndctl_dax_get_num_alignments(struct ndctl_dax *dax) +{ +return ndctl_pfn_get_num_alignments (&dax->pfn); +} + +NDCTL_EXPORT unsigned long ndctl_dax_get_supported_alignment ( +struct ndctl_dax *dax,int i) +{ +return ndctl_pfn_get_supported_alignment (&dax->pfn, i); +} + NDCTL_EXPORT int ndctl_dax_has_align(struct ndctl_dax *dax) {return ndctl_pfn_has_align (&dax->pfn);
ndctl/lib/libndctl.sym +4 -0
@@ -390,4 +390,8 @@ LIBNDCTL_19 { global: ndctl_cmd_xlat_firmware_status; ndctl_cmd_submit_xlat; + ndctl_pfn_get_supported_alignment; + ndctl_pfn_get_num_alignments; + ndctl_dax_get_supported_alignment; + ndctl_dax_get_num_alignments; } LIBNDCTL_18;
ndctl/libndctl.h +4 -0
@@ -597,7 +597,9 @@ int ndctl_pfn_set_uuid(struct ndctl_pfn *pfn, uuid_t uu);void ndctl_pfn_get_uuid (struct ndctl_pfn *pfn,uuid_t uu);int ndctl_pfn_has_align (struct ndctl_pfn *pfn);int ndctl_pfn_set_align (struct ndctl_pfn *pfn,unsigned long align); +int ndctl_pfn_get_num_alignments (struct ndctl_pfn *pfn);unsigned long ndctl_pfn_get_align (struct ndctl_pfn *pfn); +unsigned long ndctl_pfn_get_supported_alignment (struct ndctl_pfn *pfn,int i);unsigned long long ndctl_pfn_get_resource (struct ndctl_pfn *pfn);unsigned long long ndctl_pfn_get_size (struct ndctl_pfn *pfn);int ndctl_pfn_set_namespace (struct ndctl_pfn *pfn,struct ndctl_namespace *ndns);
@@ -628,7 +630,9 @@ unsigned long long ndctl_dax_get_resource(struct ndctl_dax *dax);int ndctl_dax_set_uuid (struct ndctl_dax *dax,uuid_t uu);enum ndctl_pfn_loc ndctl_dax_get_location (struct ndctl_dax *dax);int ndctl_dax_set_location (struct ndctl_dax *dax,enum ndctl_pfn_loc loc); +int ndctl_dax_get_num_alignments (struct ndctl_dax *dax);unsigned long ndctl_dax_get_align (struct ndctl_dax *dax); +unsigned long ndctl_dax_get_supported_alignment (struct ndctl_dax *dax,int i);int ndctl_dax_has_align (struct ndctl_dax *dax);int ndctl_dax_set_align (struct ndctl_dax *dax,unsigned long align); int ndctl_dax_set_namespace(struct ndctl_dax *dax,
Signature · 6 lines
2.20.1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v5 2/7 ndctl/namespace: Check for seed namespaces earlier
When creating an fsdax or devdax namespace we need to verify that the seed namespaces exist. This patch reworks the validation so that it's done earlier to simplify the subsequent patches in the series.
---
No functional changes, I hope.
v3: Don't fail early if the user specifies fsdax mode without pfn
support. Instead, if we try to validate a feature that requires pfn support, fail the validation at that point.
--- ndctl/namespace.c | 48 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 25 deletions(-)
ndctl/namespace.c +23 -25
@@ -469,6 +469,8 @@ static int validate_namespace_options(struct ndctl_region *region, {const char *region_name =ndctl_region_get_devname (region);unsigned long long size_align =SZ_4K , units =1 , resource; +struct ndctl_pfn *pfn =NULL ; +struct ndctl_dax *dax =NULL ;unsigned int ways;int rc =0 ;
@@ -525,10 +527,24 @@ static int validate_namespace_options(struct ndctl_region *region, }else if (ndns) p->mode =ndctl_namespace_get_mode (ndns); -if (param.align) { -struct ndctl_pfn *pfn =ndctl_region_get_pfn_seed (region); -struct ndctl_dax *dax =ndctl_region_get_dax_seed (region); +if (p->mode ==NDCTL_NS_MODE_MEMORY ) { + pfn =ndctl_region_get_pfn_seed (region); +if (!pfn && param.mode_default) { +debug ("%s fsdax mode not available\n" , region_name); + p->mode =NDCTL_NS_MODE_RAW ; + } +/* +* NB: We only fail validation if a pfn-specific option is used +*/ + }else if (p->mode ==NDCTL_NS_MODE_DAX ) { + dax =ndctl_region_get_dax_seed (region); +if (!dax) { +error ("Kernel does not support devdax mode\n" ); +return -ENODEV ; + } + } +if (param.align) { p->align =parse_size64 (param.align); if (p->mode == NDCTL_NS_MODE_MEMORY && p->align != SZ_2M
@@ -709,30 +725,12 @@ static int validate_namespace_options(struct ndctl_region *region, || p->mode == NDCTL_NS_MODE_DAX) p->loc =NDCTL_PFN_LOC_PMEM ; -/* check if we need, and whether the kernel supports, pfn devices */ -if (do_setup_pfn (ndns, p)) { -struct ndctl_pfn *pfn =ndctl_region_get_pfn_seed (region); - -if (!pfn && param.mode_default) { -debug ("%s fsdax mode not available\n" , region_name); - p->mode =NDCTL_NS_MODE_RAW ; - }else if (!pfn) { -error ("operation failed, %s fsdax mode not available\n" , - region_name); -return -EINVAL ; - } +if (!pfn &&do_setup_pfn (ndns, p)) { +error ("operation failed, %s cannot support requested mode\n" , + region_name); +return -EINVAL ; } -/* check if we need, and whether the kernel supports, dax devices */ -if (p->mode ==NDCTL_NS_MODE_DAX ) { -struct ndctl_dax *dax =ndctl_region_get_dax_seed (region); - -if (!dax) { -error ("operation failed, %s devdax mode not available\n" , - region_name); -return -EINVAL ; - } - } p->autolabel = param.autolabel;
Signature · 6 lines
2.20.1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v5 3/7 ndctl/namespace: Use seed alignment as the default
In reply to Oliver O'HalloranWhen creating a pfn or dax namespace ndctl uses a default alignment of 2MB when the user does not explicitly supply one. This works on most systems (x86, ARM, PPC64 with radix MMU), but it fails when the kernel does not support a 2MB page size (PPC64 with hash MMU).
This patch makes ndctl use the alignment of the relevant seed namespace as the default instead. The kernel will always pick a valid default alignment so this should be a bit more portable.
---
v3: Only use the pfn seed for the default alignment if there is a pfn
seed.
--- ndctl/namespace.c | 96 +++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 53 deletions(-)
ndctl/namespace.c +43 -53
@@ -39,7 +39,6 @@ static bool logfix; static struct parameters { bool do_scan; bool mode_default; - bool align_default; bool autolabel; const char *bus; const char *map;
@@ -226,9 +225,6 @@ static int set_defaults(enum device_action mode)error ("failed to parse namespace alignment '%s'\n" , param.align); rc = -EINVAL ; - }else if (!param.align) { - param.align ="2M" ; - param.align_default = true; }if (param.uuid) {
@@ -468,7 +464,7 @@ static int validate_namespace_options(struct ndctl_region *region, struct ndctl_namespace *ndns, struct parsed_parameters *p) { const char *region_name = ndctl_region_get_devname(region); -unsigned long long size_align =SZ_4K , units =1 , resource; +unsigned long long size_align, units =1 , resource;struct ndctl_pfn *pfn =NULL ;struct ndctl_dax *dax =NULL ;unsigned int ways;
@@ -545,53 +541,15 @@ static int validate_namespace_options(struct ndctl_region *region, }if (param.align) { - p->align =parse_size64 (param.align); - -if (p->mode ==NDCTL_NS_MODE_MEMORY && p->align !=SZ_2M - && (!pfn || !ndctl_pfn_has_align (pfn))) { -/* -* Initial pfn device support in the kernel -* supported a 2M default alignment when -* ndctl_pfn_has_align() returns false. -*/ -debug ("%s not support 'align' for fsdax mode\n" , - region_name); -return -EAGAIN ; - }else if (p->mode ==NDCTL_NS_MODE_DAX - && (!dax || !ndctl_dax_has_align (dax))) { -/* -* Unlike the pfn case, we require the kernel to -* have 'align' support for device-dax. -*/ -debug ("%s not support 'align' for devdax mode\n" , - region_name); -return -EAGAIN ; - }else if (!param.align_default - && (p->mode ==NDCTL_NS_MODE_SAFE - || p->mode ==NDCTL_NS_MODE_RAW )) { -/* -* Specifying an alignment has no effect for -* raw, or btt mode namespaces. -*/ +if (p->mode !=NDCTL_NS_MODE_MEMORY && + p->mode !=NDCTL_NS_MODE_DAX ) {error ("%s mode does not support setting an alignment\n" , p->mode ==NDCTL_NS_MODE_SAFE ?"sector" :"raw" );return -ENXIO ; } -/* -* Fallback to a 4K default alignment if the region is -* not 2MB (typical default) aligned. This mainly helps -* the nfit_test use case where it is backed by vmalloc -* memory. -*/ - resource =ndctl_region_get_resource (region); -if (param.align_default && resource <ULLONG_MAX - && (resource & (SZ_2M -1 ))) { -debug ("%s: falling back to a 4K alignment\n" , - region_name); - p->align =SZ_4K ; - } + p->align =parse_size64 (param.align);switch (p->align) {case SZ_4K :
@@ -602,16 +560,48 @@ static int validate_namespace_options(struct ndctl_region *region,error ("unsupported align: %s\n" , param.align);return -ENXIO ; } + }else { +/* +* Use the seed namespace alignment as the default if we need +* one. If we don't then use PAGE_SIZE so the size_align +* checking works. +*/ +if (p->mode ==NDCTL_NS_MODE_MEMORY ) { +/* +* The initial pfn device support in the kernel didn't +* have the 'align' sysfs attribute and assumed a 2MB +* alignment. Fall back to that if we don't have the +* attribute. +*/ +if (pfn &&ndctl_pfn_has_align (pfn)) + p->align =ndctl_pfn_get_align (pfn); +else + p->align =SZ_2M ; + }else if (p->mode ==NDCTL_NS_MODE_DAX ) { +/* +* device dax mode was added after the align attribute +* so checking for it is unnecessary. +*/ + p->align =ndctl_dax_get_align (dax); + }else { + p->align =sysconf (_SC_PAGE_SIZE); + }/* -* 'raw' and 'sector' mode namespaces don't support an -* alignment attribute. +* Fallback to a page alignment if the region is not aligned +* to the default. This is mainly useful for the nfit_test +* use case where it is backed by vmalloc memory. */ -if (p->mode ==NDCTL_NS_MODE_MEMORY - || p->mode ==NDCTL_NS_MODE_DAX ) - size_align = p->align; + resource =ndctl_region_get_resource (region); +if (resource <ULLONG_MAX && (resource & (p->align -1 ))) { +debug ("%s: falling back to a page alignment\n" , + region_name); + p->align =sysconf (_SC_PAGE_SIZE); + } } + size_align = p->align; +/* (re-)validate that the size satisfies the alignment */ ways =ndctl_region_get_interleave_ways (region);if (p->size % (size_align * ways)) {
@@ -637,8 +627,8 @@ static int validate_namespace_options(struct ndctl_region *region, p->size *= size_align; p->size /= units;error ("'--size=' must align to interleave-width: %d and alignment: %ld\n" -" did you intend --size=%lld%s?\n" , ways, param.align - ? p->align :SZ_4K , p->size, suffix); +"did you intend --size=%lld%s?\n" , + ways, p->align, p->size, suffix);return -EINVAL ; }
Signature · 6 lines
2.20.1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v5 4/7 ndctl/namespace: Validate alignment from the {pfn|dax} seed
In reply to Oliver O'HalloranThis patch adds support to the ndctl tool for validating that the namespace alignment is valid.
---
v3: Fail validation if an alignment is specified, but pfn mode is
not supported.
--- ndctl/namespace.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
ndctl/namespace.c +29 -8
@@ -541,8 +541,23 @@ static int validate_namespace_options(struct ndctl_region *region, }if (param.align) { -if (p->mode !=NDCTL_NS_MODE_MEMORY && - p->mode !=NDCTL_NS_MODE_DAX ) { +int i, alignments; + +switch (p->mode) { +case NDCTL_NS_MODE_MEMORY : +if (!pfn) { +error ("Kernel does not support setting an alignment in fsdax mode\n" ); +return -EINVAL ; + } + + alignments =ndctl_pfn_get_num_alignments (pfn); +break ; + +case NDCTL_NS_MODE_DAX : + alignments =ndctl_dax_get_num_alignments (dax); +break ; + +default :error ("%s mode does not support setting an alignment\n" , p->mode ==NDCTL_NS_MODE_SAFE ?"sector" :"raw" );
@@ -550,13 +565,19 @@ static int validate_namespace_options(struct ndctl_region *region, } p->align =parse_size64 (param.align); +for (i =0 ; i < alignments; i++) { +uint64_t a; -switch (p->align) { -case SZ_4K : -case SZ_2M : -case SZ_1G : -break ; -default : +if (p->mode ==NDCTL_NS_MODE_MEMORY ) + a =ndctl_pfn_get_supported_alignment (pfn, i); +else + a =ndctl_dax_get_supported_alignment (dax, i); + +if (p->align == a) +break ; + } + +if (i >= alignments) {error ("unsupported align: %s\n" , param.align);return -ENXIO ; }
Signature · 6 lines
2.20.1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v5 5/7 ndctl: Add alignment to the namespace JSON output
In reply to Oliver O'HalloranAutomated tooling probably wants to know this and it's helpful output for command line users for ndctl.
--- util/json.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
util/json.c +10 -0
@@ -753,6 +753,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,struct ndctl_btt *btt;struct ndctl_pfn *pfn;struct ndctl_dax *dax; +unsigned long align =0 ;char buf[40 ];uuid_t uuid;int numa;
@@ -825,6 +826,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,util_raw_uuid_to_json (ndns, flags, jndns); bdev =ndctl_btt_get_block_device (btt); }else if (pfn) { + align =ndctl_pfn_get_align (pfn);ndctl_pfn_get_uuid (pfn, uuid);uuid_unparse (uuid, buf); jobj =json_object_new_string (buf);
@@ -837,6 +839,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,struct daxctl_region *dax_region; dax_region =ndctl_dax_get_daxctl_region (dax); + align =ndctl_dax_get_align (dax);ndctl_dax_get_uuid (dax, uuid);uuid_unparse (uuid, buf); jobj =json_object_new_string (buf);
@@ -897,6 +900,13 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,json_object_object_add (jndns,"sector_size" , jobj); } +if (align) { + jobj =json_object_new_int64 (align); +if (!jobj) + goto err; +json_object_object_add (jndns,"align" , jobj); + } +if (bdev && bdev[0 ]) { jobj =json_object_new_string (bdev);if (!jobj)
Signature · 6 lines
2.20.1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v5 6/7 ndctl/namespace: Make the create-region JSON output non-verbose
In reply to Oliver O'HalloranThe ndctl unit tests parse the output of the create-region commands using a pile of regexs which makes adding new fields to create-namespace output blob a somewhat fraught activity. By moving the existing "verbose" fields into the normal output we keep the unit tests happy and allow ourselves to add more fields in the future.
This patch also makes the 'sector_size' field non-verbose since the BTT unit tests require it.
---
Ccurrently ndctl list has the -v flag to make the output more verbose, however every other ndctl command uses -v as a switch to enable debug output. We probably don't want to change the CLI much, but considering debug output requires running configure with --enable-debug it might be a good idea to change it to -d or something and free up the switch for actual verbosity.
---
--- ndctl/namespace.c | 2 +- util/json.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
ndctl/namespace.c +1 -1
@@ -424,7 +424,7 @@ static int setup_namespace(struct ndctl_region *region,error ("%s: failed to enable\n" ,ndctl_namespace_get_devname (ndns)); }else { -unsigned long flags =UTIL_JSON_DAX |UTIL_JSON_DAX_DEVS |UTIL_JSON_VERBOSE ; +unsigned long flags =UTIL_JSON_DAX |UTIL_JSON_DAX_DEVS ;struct json_object *jndns;if (isatty (1 ))
util/json.c +1 -1
@@ -893,7 +893,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,* happens because they use pre-v1.2 labels or because they * don't have a label space (devtype=nd_namespace_io). */ -if (sector_size <UINT_MAX && flags &UTIL_JSON_VERBOSE ) { +if (sector_size <UINT_MAX ) { jobj =json_object_new_int (sector_size);if (!jobj) goto err;
Signature · 6 lines
2.20.1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v5 7/7 ndctl: Add supported_alignments to the JSON output
In reply to Oliver O'HalloranAdd the list of supported alignemnts to PFN and DAX namespaces. Also add the list of supported sector sizes to BTT namespaces.
---
v5: Added again. The supported_size array is now only included in the
verbose JSON output. This means it won't be included in the JSON output from setup_namespace() so to see the list of supported alignments you need to use ndctl list -v.
v4: Dropped due to unit test breakage.
v3: Added
Not sure the namespace JSON blob are the best place to put these. The region might be better, but slightly less accessable to users.
--- util/json.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
util/json.c +47 -1
@@ -303,6 +303,38 @@ struct json_object *util_daxctl_devs_to_list(struct daxctl_region *region,return jdevs; } +#define _SZ (get_max, get_elem, type) \ +static struct json_object *type##_build_size_array(struct type *arg) \ +{ \ + struct json_object *arr = json_object_new_array(); \ + int i; \ + \ + if (!arr) \ + return NULL; \ + \ + for (i = 0; i < get_max(arg); i++) { \ + struct json_object *jobj; \ + int64_t align; \ + \ + align = get_elem(arg, i); \ + jobj = json_object_new_int64(align); \ + if (!jobj) \ + goto err; \ + json_object_array_add(arr, jobj); \ + } \ + \ + return arr; \ +err: \ + json_object_put(arr); \ + return NULL; \ +} +#define SZ (type, kind) _SZ(ndctl_##type##_get_num_##kind##s, \ + ndctl_##type##_get_supported_##kind, ndctl_##type) +SZ(pfn, alignment) +SZ(dax, alignment) +SZ (btt, sector_size) +//SZ(namespace, sector_size) +struct json_object *util_daxctl_region_to_json (struct daxctl_region *region,const char *ident,unsigned long flags) {
@@ -739,7 +771,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, {struct json_object *jndns =json_object_new_object ();enum ndctl_pfn_loc loc =NDCTL_PFN_LOC_NONE ; -struct json_object *jobj, *jbbs =NULL ; +struct json_object *jobj, *jbbs =NULL , *size_array =NULL ;const char *locations[] = { [NDCTL_PFN_LOC_NONE ] ="none" , [NDCTL_PFN_LOC_RAM ] ="mem" ,
@@ -749,6 +781,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,unsigned int sector_size =UINT_MAX ;enum ndctl_namespace_mode mode;const char *bdev =NULL , *name; +const char *size_array_name;unsigned int bb_count =0 ;struct ndctl_btt *btt;struct ndctl_pfn *pfn;
@@ -936,6 +969,19 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,json_object_object_add (jndns,"numa_node" , jobj); } +if (pfn) { + size_array_name ="supported_alignments" ; + size_array =ndctl_pfn_build_size_array (pfn); + }else if (dax) { + size_array_name ="supported_alignments" ; + size_array =ndctl_dax_build_size_array (dax); + }else if (btt) { + size_array_name ="supported sector sizes" ; + size_array =ndctl_btt_build_size_array (btt); + } +if (size_array && flags &UTIL_JSON_VERBOSE ) +json_object_object_add (jndns, size_array_name, size_array); +if (pfn) jbbs =util_pfn_badblocks_to_json (pfn, &bb_count, flags);else if (dax)
Signature · 6 lines
2.20.1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Verma, Vishal L
maintainerQuoted 23 lines · Oliver O'Halloran
Newer kernels provide the "
supported_alignments" sysfs attribute that indicates what alignments can be used with a PFN or DAX namespace. This patch adds the plumbing inside of libndctl to allow users to query this information through using:
ndctl_{dax|pfn}_get_supported_alignment(), and ndctl_{dax|pfn}_get_num_alignments()Signed-off-by Oliver O'Halloran <[email protected]>---
v5: Fixed comment wordingv4: Changed return code of
ndctl_pfn_get_supported_alignmentfrom -1 to
-1 to-EINVAL.Reworded comment about why we default to 4K and 2M alignments when the sysfs attribute is missing.
Shuffled around prototypes in
ndctl.h.80 char compliance fixes.
rebased onto pending branch
Quoted 8 lines
v3: Changed the return type of the
*_get_supported_alignment()functions
to unsigned long to match the existing*_get_alignment()functions.--- ndctl/lib/libndctl.c | 43 ++++++++++++++++++++++++++++++++++++++++++ ndctl/lib/libndctl.sym | 4 ++++ ndctl/libndctl.h | 4 ++++ 3 files changed, 51 insertions(+)
Thanks for the reworks, Oliver. I've applied the series.
_______________________________________________
Linux-nvdimm mailing list [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 18 lines · Oliver O'Halloran
Newer kernels provide the "
supported_alignments" sysfs attribute that indicates what alignments can be used with a PFN or DAX namespace. This patch adds the plumbing inside of libndctl to allow users to query this information through using:
ndctl_{dax|pfn}_get_supported_alignment(), and ndctl_{dax|pfn}_get_num_alignments()Signed-off-by Oliver O'Halloran <[email protected]>---
v5: Fixed comment wordingv4: Changed return code of
ndctl_pfn_get_supported_alignmentfrom -1 to
-1 to-EINVAL.Reworded comment about why we default to 4K and 2M alignments when the sysfs attribute is missing.
Quoted 8 lines
Shuffled around prototypes in
ndctl.h.80 char compliance fixes.
rebased onto pending branch
v3: Changed the return type of the
*_get_supported_alignment()functions
to unsigned long to match the existing*_get_alignment()functions.
After playing with this facility in the v64 release I think it needs a redo for the following reasons:
* It's a bit too chatty and redundant even behind a "-v" because all namespaces share the same attributes,
* this breaks the long standing, but admittedly not documented, style guideline that all json values have an associated key, even if the key is effectively just a generic index value. There are common methods to enumerate the key space, but key-less arrays need to be handled explicitly.
* It's the only field in the json that does not reflect the current state of a device. For this reason I think it should be moved behind a --capabilities flag and a named "capability" object as a child of a region. This would also help with the redundant "supported" prefix.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm