Use exported symbol bdevname() instead of disk_name()
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 2 Jul 2020 16:06:42 +0000 (12:06 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 6 Jul 2020 21:26:45 +0000 (17:26 -0400)
bdevname() is a simple wrapper over disk_name() but has the honor to be
exported. Using it removes the need for a kallsym wrapper.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic2b2233c4db7826175c68edea69751ddcb17a5e6

lttng-statedump-impl.c
wrapper/genhd.h

index 5225186be48b6c24a7a282a16caddc4955e6b590..54a309d15b879d92ca251dacb916c250dc6ba745 100644 (file)
@@ -138,10 +138,19 @@ int lttng_enumerate_block_devices(struct lttng_session *session)
 
                disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
                while ((part = disk_part_iter_next(&piter))) {
+                       struct block_device bdev;
                        char name_buf[BDEVNAME_SIZE];
-                       char *p;
+                       const char *p;
 
-                       p = wrapper_disk_name(disk, part->partno, name_buf);
+                       /*
+                        * Create a partial 'struct blockdevice' to use
+                        * 'bdevname()' which is a simple wrapper over
+                        * 'disk_name()' but has the honor to be EXPORT_SYMBOL.
+                        */
+                       bdev.bd_disk = disk;
+                       bdev.bd_part = part;
+
+                       p = bdevname(&bdev, name_buf);
                        if (!p) {
                                disk_part_iter_exit(&piter);
                                class_dev_iter_exit(&iter);
index a44198a7eb138f6698c7495ccb059a0370a91026..4eac2c1a14c62ed74a316a98ff4228f4478352da 100644 (file)
 
 #include <linux/genhd.h>
 
-#ifdef CONFIG_KALLSYMS
+#ifdef CONFIG_KALLSYMS_ALL
 
 #include <linux/kallsyms.h>
 #include <wrapper/kallsyms.h>
 
-static inline
-char *wrapper_disk_name(struct gendisk *hd, int partno, char *buf)
-{
-       char *(*disk_name_sym)(struct gendisk *hd, int partno, char *buf);
-
-       disk_name_sym = (void *) kallsyms_lookup_funcptr("disk_name");
-       if (disk_name_sym) {
-               return disk_name_sym(hd, partno, buf);
-       } else {
-               printk_once(KERN_WARNING "LTTng: disk_name symbol lookup failed.\n");
-               return NULL;
-       }
-}
-
-#else
-
-static inline
-char *wrapper_disk_name(struct gendisk *hd, int partno, char *buf)
-{
-       return disk_name(hd, partno, buf);
-}
-
-#endif
-
-#ifdef CONFIG_KALLSYMS_ALL
-
 static inline
 struct class *wrapper_get_block_class(void)
 {
This page took 0.027526 seconds and 4 git commands to generate.