mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-18 03:06:43 +00:00
drbd: split polymorph printk to its own file
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>
This commit is contained in:
parent
c3f8974198
commit
136160c173
@ -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 */
|
||||
|
72
drivers/block/drbd/drbd_polymorph_printk.h
Normal file
72
drivers/block/drbd/drbd_polymorph_printk.h
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user