]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: add dax capability detection in topology probing
authorAnthony Iliopoulos <ailiop@suse.com>
Tue, 5 May 2020 14:31:45 +0000 (16:31 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 6 May 2020 13:27:29 +0000 (15:27 +0200)
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
libblkid/src/blkid.h.in
libblkid/src/libblkid.sym
libblkid/src/topology/sysfs.c
libblkid/src/topology/topology.c
libblkid/src/topology/topology.h

index 4112ba36e2bfc0aa2710a7080726ebfe534cd73f..7d21567d5408198365a51ff9f5179bf5ad815533 100644 (file)
@@ -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));
        }
 
        /*
index d09d60c38bdc7c5fce1e606235a3492ea2e045a8..7328d0e30687da39ca49163593adc7cceb2256ca 100644 (file)
@@ -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
index bac443823b67669b5a6877abd5e087126eb32cc5..eff1f7774df2089c698659bd8908ad9a216be307 100644 (file)
@@ -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;
index 0605c355861d5f032d716d210db83070e61fee80..745cd115aaf87cafbc0126707bee56e4ea78b9e5 100644 (file)
@@ -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,
index 38e4c950d461b603387163e853d672e3574173f9..34ef408004011169fa9aed97e6b6e2d5dbaf93d3 100644 (file)
@@ -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;
+}
index 6d2f433450df84c583a674942d4f7a3218b32a23..3e46af9ac5c3efacc21531c896d73613d23c97da 100644 (file)
@@ -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