util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libblkid: add dax capability detection in topology probing
@ 2020-05-05 14:31 Anthony Iliopoulos
  2020-05-06 13:08 ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Anthony Iliopoulos @ 2020-05-05 14:31 UTC (permalink / raw)
  To: util-linux; +Cc: ailiop

The dax (direct access) blockdev capability is exposed via sysfs, add it
to the list of topology values to be obtained while probing.

Expose blkid_topology_get_dax() symbol that programs can link against
for querying the capability.

Reorder the idinfos array to give precedence to the sysfs over ioctl so
that the dax probe has a chance to be executed, as there is no ioctl
interface for it.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
---
 libblkid/samples/topology.c      |  2 ++
 libblkid/src/blkid.h.in          |  2 ++
 libblkid/src/libblkid.sym        |  4 ++++
 libblkid/src/topology/sysfs.c    |  1 +
 libblkid/src/topology/topology.c | 21 ++++++++++++++++++++-
 libblkid/src/topology/topology.h |  1 +
 6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/libblkid/samples/topology.c b/libblkid/samples/topology.c
index 4112ba36e..7d21567d5 100644
--- a/libblkid/samples/topology.c
+++ b/libblkid/samples/topology.c
@@ -51,6 +51,8 @@ int main(int argc, char *argv[])
 				blkid_topology_get_logical_sector_size(tp));
 		printf("\tphysical sector size : %lu\n",
 				blkid_topology_get_physical_sector_size(tp));
+		printf("\tdax support          : %lu\n",
+				blkid_topology_get_dax(tp));
 	}
 
 	/*
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index d09d60c38..7328d0e30 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -325,6 +325,8 @@ extern unsigned long blkid_topology_get_logical_sector_size(blkid_topology tp)
 			__ul_attribute__((nonnull));
 extern unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
 			__ul_attribute__((nonnull));
+extern unsigned long blkid_topology_get_dax(blkid_topology tp)
+			__ul_attribute__((nonnull));
 
 /*
  * partitions probing
diff --git a/libblkid/src/libblkid.sym b/libblkid/src/libblkid.sym
index bac443823..eff1f7774 100644
--- a/libblkid/src/libblkid.sym
+++ b/libblkid/src/libblkid.sym
@@ -174,3 +174,7 @@ BLKID_2_31 {
 	blkid_probe_reset_buffers;
 	blkid_probe_hide_range;
 } BLKID_2.30;
+
+BLKID_2_35 {
+	blkid_topology_get_dax;
+} BLKID_2_31;
diff --git a/libblkid/src/topology/sysfs.c b/libblkid/src/topology/sysfs.c
index 0605c3558..745cd115a 100644
--- a/libblkid/src/topology/sysfs.c
+++ b/libblkid/src/topology/sysfs.c
@@ -37,6 +37,7 @@ static struct topology_val {
 	{ "queue/minimum_io_size", blkid_topology_set_minimum_io_size },
 	{ "queue/optimal_io_size", blkid_topology_set_optimal_io_size },
 	{ "queue/physical_block_size", blkid_topology_set_physical_sector_size },
+	{ "queue/dax", blkid_topology_set_dax },
 };
 
 static int probe_sysfs_tp(blkid_probe pr,
diff --git a/libblkid/src/topology/topology.c b/libblkid/src/topology/topology.c
index 38e4c950d..34ef40800 100644
--- a/libblkid/src/topology/topology.c
+++ b/libblkid/src/topology/topology.c
@@ -67,6 +67,7 @@ struct blkid_struct_topology {
 	unsigned long	optimal_io_size;
 	unsigned long	logical_sector_size;
 	unsigned long	physical_sector_size;
+	unsigned long   dax;
 };
 
 /*
@@ -75,8 +76,8 @@ struct blkid_struct_topology {
 static const struct blkid_idinfo *idinfos[] =
 {
 #ifdef __linux__
-	&ioctl_tp_idinfo,
 	&sysfs_tp_idinfo,
+	&ioctl_tp_idinfo,
 	&md_tp_idinfo,
 	&dm_tp_idinfo,
 	&lvm_tp_idinfo,
@@ -303,6 +304,14 @@ int blkid_topology_set_physical_sector_size(blkid_probe pr, unsigned long val)
 			val);
 }
 
+int blkid_topology_set_dax(blkid_probe pr, unsigned long val)
+{
+	return topology_set_value(pr,
+			"DAX",
+			offsetof(struct blkid_struct_topology, dax),
+			val);
+}
+
 /**
  * blkid_topology_get_alignment_offset:
  * @tp: topology
@@ -358,3 +367,13 @@ unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
 	return tp->physical_sector_size;
 }
 
+/**
+ * blkid_topology_get_dax
+ * @tp: topology
+ *
+ * Returns: 1 if dax is supported, 0 otherwise.
+ */
+unsigned long blkid_topology_get_dax(blkid_topology tp)
+{
+	return tp->dax;
+}
diff --git a/libblkid/src/topology/topology.h b/libblkid/src/topology/topology.h
index 6d2f43345..3e46af9ac 100644
--- a/libblkid/src/topology/topology.h
+++ b/libblkid/src/topology/topology.h
@@ -7,6 +7,7 @@ extern int blkid_topology_set_alignment_offset(blkid_probe pr, int val);
 extern int blkid_topology_set_minimum_io_size(blkid_probe pr, unsigned long val);
 extern int blkid_topology_set_optimal_io_size(blkid_probe pr, unsigned long val);
 extern int blkid_topology_set_physical_sector_size(blkid_probe pr, unsigned long val);
+extern int blkid_topology_set_dax(blkid_probe pr, unsigned long val);
 
 /*
  * topology probers
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-06 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 14:31 [PATCH] libblkid: add dax capability detection in topology probing Anthony Iliopoulos
2020-05-06 13:08 ` Karel Zak
2020-05-06 13:21   ` Anthony Iliopoulos
2020-05-06 13:29     ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).