Util-Linux Archive on lore.kernel.org
 help / color / 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	[flat|nested] 4+ messages in thread

* Re: [PATCH] libblkid: add dax capability detection in topology probing
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Karel Zak @ 2020-05-06 13:08 UTC (permalink / raw)
  To: Anthony Iliopoulos; +Cc: util-linux

On Tue, May 05, 2020 at 04:31:45PM +0200, Anthony Iliopoulos wrote:
> 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.

Do we have any use-case for this change? 

We maintain blkid_topology_* mostly for mkfs-like programs portability 
(years ago we had only ioctls, etc..). You can see that libblkid export
only small subset topology stuff, so why we need DAX there? ;-)

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


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

* Re: [PATCH] libblkid: add dax capability detection in topology probing
  2020-05-06 13:08 ` Karel Zak
@ 2020-05-06 13:21   ` Anthony Iliopoulos
  2020-05-06 13:29     ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Anthony Iliopoulos @ 2020-05-06 13:21 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Wed, May 06, 2020 at 03:08:47PM +0200, Karel Zak wrote:
> On Tue, May 05, 2020 at 04:31:45PM +0200, Anthony Iliopoulos wrote:
> > 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.
> 
> Do we have any use-case for this change? 
> 
> We maintain blkid_topology_* mostly for mkfs-like programs portability 
> (years ago we had only ioctls, etc..). You can see that libblkid export
> only small subset topology stuff, so why we need DAX there? ;-)

The use-case is indeed mkfs. I am planning to submit a patch to xfsprogs
that warns if the blockdev is dax-capable but the default or specified
fs blocksize isn't matching the platform page size (in which case the fs
cannot be used/mounted with dax). This comes up with archs like ppc64
where the page size is larger than the default (usually 4K) fs blocksize.

I wanted to avoid parsing sysfs from xfsprogs, especially given that
libblkid is already leveraged there to obtain the topology, and I assume
it may be handy for e2fsprogs too, as ext4 (and any other fs that may
support dax in the future) is bound to the same restriction.

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

* Re: [PATCH] libblkid: add dax capability detection in topology probing
  2020-05-06 13:21   ` Anthony Iliopoulos
@ 2020-05-06 13:29     ` Karel Zak
  0 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2020-05-06 13:29 UTC (permalink / raw)
  To: Anthony Iliopoulos; +Cc: util-linux

On Wed, May 06, 2020 at 03:21:41PM +0200, Anthony Iliopoulos wrote:
> On Wed, May 06, 2020 at 03:08:47PM +0200, Karel Zak wrote:
> > On Tue, May 05, 2020 at 04:31:45PM +0200, Anthony Iliopoulos wrote:
> > > 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.
> > 
> > Do we have any use-case for this change? 
> > 
> > We maintain blkid_topology_* mostly for mkfs-like programs portability 
> > (years ago we had only ioctls, etc..). You can see that libblkid export
> > only small subset topology stuff, so why we need DAX there? ;-)
> 
> The use-case is indeed mkfs. I am planning to submit a patch to xfsprogs

Yes, hch is the reason why we have topology API in libblkid :-)

Applied, thanks.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


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

end of thread, back to index

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

Util-Linux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/util-linux/0 util-linux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 util-linux util-linux/ https://lore.kernel.org/util-linux \
		util-linux@vger.kernel.org
	public-inbox-index util-linux

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.util-linux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git