]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drbd: split polymorph printk to its own file
authorChristoph Böhmwalder <christoph.boehmwalder@linbit.com>
Thu, 1 Dec 2022 11:03:47 +0000 (12:03 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 1 Dec 2022 18:33:49 +0000 (11:33 -0700)
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Link: https://lore.kernel.org/r/20221201110349.1282687-3-christoph.boehmwalder@linbit.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_polymorph_printk.h [new file with mode: 0644]

index ea92df778c66e9c64a1ee0f540bdd996b6546f9d..1734a7f8a096f56117f78d48a01c2476c3d6778d 100644 (file)
@@ -37,6 +37,7 @@
 #include "drbd_strings.h"
 #include "drbd_state.h"
 #include "drbd_protocol.h"
+#include "drbd_polymorph_printk.h"
 
 #ifdef __CHECKER__
 # define __protected_by(x)       __attribute__((require_context(x,1,999,"rdwr")))
@@ -75,73 +76,6 @@ extern int drbd_proc_details;
 struct drbd_device;
 struct drbd_connection;
 
-#define __drbd_printk_device(level, device, fmt, args...) \
-       dev_printk(level, disk_to_dev((device)->vdisk), fmt, ## args)
-#define __drbd_printk_peer_device(level, peer_device, fmt, args...) \
-       dev_printk(level, disk_to_dev((peer_device)->device->vdisk), fmt, ## args)
-#define __drbd_printk_resource(level, resource, fmt, args...) \
-       printk(level "drbd %s: " fmt, (resource)->name, ## args)
-#define __drbd_printk_connection(level, connection, fmt, args...) \
-       printk(level "drbd %s: " fmt, (connection)->resource->name, ## args)
-
-void drbd_printk_with_wrong_object_type(void);
-
-#define __drbd_printk_if_same_type(obj, type, func, level, fmt, args...) \
-       (__builtin_types_compatible_p(typeof(obj), type) || \
-        __builtin_types_compatible_p(typeof(obj), const type)), \
-       func(level, (const type)(obj), fmt, ## args)
-
-#define drbd_printk(level, obj, fmt, args...) \
-       __builtin_choose_expr( \
-         __drbd_printk_if_same_type(obj, struct drbd_device *, \
-                            __drbd_printk_device, level, fmt, ## args), \
-         __builtin_choose_expr( \
-           __drbd_printk_if_same_type(obj, struct drbd_resource *, \
-                              __drbd_printk_resource, level, fmt, ## args), \
-           __builtin_choose_expr( \
-             __drbd_printk_if_same_type(obj, struct drbd_connection *, \
-                                __drbd_printk_connection, level, fmt, ## args), \
-             __builtin_choose_expr( \
-               __drbd_printk_if_same_type(obj, struct drbd_peer_device *, \
-                                __drbd_printk_peer_device, level, fmt, ## args), \
-               drbd_printk_with_wrong_object_type()))))
-
-#define drbd_dbg(obj, fmt, args...) \
-       drbd_printk(KERN_DEBUG, obj, fmt, ## args)
-#define drbd_alert(obj, fmt, args...) \
-       drbd_printk(KERN_ALERT, obj, fmt, ## args)
-#define drbd_err(obj, fmt, args...) \
-       drbd_printk(KERN_ERR, obj, fmt, ## args)
-#define drbd_warn(obj, fmt, args...) \
-       drbd_printk(KERN_WARNING, obj, fmt, ## args)
-#define drbd_info(obj, fmt, args...) \
-       drbd_printk(KERN_INFO, obj, fmt, ## args)
-#define drbd_emerg(obj, fmt, args...) \
-       drbd_printk(KERN_EMERG, obj, fmt, ## args)
-
-#define dynamic_drbd_dbg(device, fmt, args...) \
-       dynamic_dev_dbg(disk_to_dev(device->vdisk), fmt, ## args)
-
-#define D_ASSERT(x, exp)                                                       \
-       do {                                                                    \
-               if (!(exp))                                                     \
-                       drbd_err(x, "ASSERTION %s FAILED in %s\n",              \
-                                #exp, __func__);                               \
-       } while (0)
-
-/**
- * expect  -  Make an assertion
- *
- * Unlike the assert macro, this macro returns a boolean result.
- */
-#define expect(exp) ({                                                         \
-               bool _bool = (exp);                                             \
-               if (!_bool)                                                     \
-                       drbd_err(device, "ASSERTION %s FAILED in %s\n",         \
-                               #exp, __func__);                                \
-               _bool;                                                          \
-               })
-
 /* Defines to control fault insertion */
 enum {
        DRBD_FAULT_MD_WR = 0,   /* meta data write */
diff --git a/drivers/block/drbd/drbd_polymorph_printk.h b/drivers/block/drbd/drbd_polymorph_printk.h
new file mode 100644 (file)
index 0000000..13cc1b3
--- /dev/null
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef DRBD_POLYMORPH_PRINTK_H
+#define DRBD_POLYMORPH_PRINTK_H
+
+#define __drbd_printk_device(level, device, fmt, args...) \
+       dev_printk(level, disk_to_dev((device)->vdisk), fmt, ## args)
+#define __drbd_printk_peer_device(level, peer_device, fmt, args...) \
+       dev_printk(level, disk_to_dev((peer_device)->device->vdisk), fmt, ## args)
+#define __drbd_printk_resource(level, resource, fmt, args...) \
+       printk(level "drbd %s: " fmt, (resource)->name, ## args)
+#define __drbd_printk_connection(level, connection, fmt, args...) \
+       printk(level "drbd %s: " fmt, (connection)->resource->name, ## args)
+
+void drbd_printk_with_wrong_object_type(void);
+
+#define __drbd_printk_if_same_type(obj, type, func, level, fmt, args...) \
+       (__builtin_types_compatible_p(typeof(obj), type) || \
+        __builtin_types_compatible_p(typeof(obj), const type)), \
+       func(level, (const type)(obj), fmt, ## args)
+
+#define drbd_printk(level, obj, fmt, args...) \
+       __builtin_choose_expr( \
+         __drbd_printk_if_same_type(obj, struct drbd_device *, \
+                            __drbd_printk_device, level, fmt, ## args), \
+         __builtin_choose_expr( \
+           __drbd_printk_if_same_type(obj, struct drbd_resource *, \
+                              __drbd_printk_resource, level, fmt, ## args), \
+           __builtin_choose_expr( \
+             __drbd_printk_if_same_type(obj, struct drbd_connection *, \
+                                __drbd_printk_connection, level, fmt, ## args), \
+             __builtin_choose_expr( \
+               __drbd_printk_if_same_type(obj, struct drbd_peer_device *, \
+                                __drbd_printk_peer_device, level, fmt, ## args), \
+               drbd_printk_with_wrong_object_type()))))
+
+#define drbd_dbg(obj, fmt, args...) \
+       drbd_printk(KERN_DEBUG, obj, fmt, ## args)
+#define drbd_alert(obj, fmt, args...) \
+       drbd_printk(KERN_ALERT, obj, fmt, ## args)
+#define drbd_err(obj, fmt, args...) \
+       drbd_printk(KERN_ERR, obj, fmt, ## args)
+#define drbd_warn(obj, fmt, args...) \
+       drbd_printk(KERN_WARNING, obj, fmt, ## args)
+#define drbd_info(obj, fmt, args...) \
+       drbd_printk(KERN_INFO, obj, fmt, ## args)
+#define drbd_emerg(obj, fmt, args...) \
+       drbd_printk(KERN_EMERG, obj, fmt, ## args)
+
+#define dynamic_drbd_dbg(device, fmt, args...) \
+       dynamic_dev_dbg(disk_to_dev(device->vdisk), fmt, ## args)
+
+#define D_ASSERT(x, exp)                                                       \
+       do {                                                                    \
+               if (!(exp))                                                     \
+                       drbd_err(x, "ASSERTION %s FAILED in %s\n",              \
+                               #exp, __func__);                                \
+       } while (0)
+
+/**
+ * expect  -  Make an assertion
+ *
+ * Unlike the assert macro, this macro returns a boolean result.
+ */
+#define expect(exp) ({                                                         \
+               bool _bool = (exp);                                             \
+               if (!_bool)                                                     \
+                       drbd_err(device, "ASSERTION %s FAILED in %s\n",         \
+                               #exp, __func__);                                \
+               _bool;                                                          \
+               })
+
+#endif