drbd: Remove the terrible DEV hack
DRBD was using dev_err() and similar all over the code; instead of having to
write dev_err(disk_to_dev(device->vdisk), ...) to convert a drbd_device into a
kernel device, a DEV macro was used which implicitly references the device
variable. This is terrible; introduce separate drbd_err() and similar macros
with an explicit device parameter instead.
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 41dced1..d393f0b 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -100,9 +100,24 @@
struct drbd_device;
struct drbd_connection;
+#define drbd_printk(level, device, fmt, args...) \
+ dev_printk(level, disk_to_dev(device->vdisk), fmt, ## args)
-/* to shorten dev_warn(DEV, "msg"); and relatives statements */
-#define DEV (disk_to_dev(device->vdisk))
+#define drbd_dbg(device, fmt, args...) \
+ drbd_printk(KERN_DEBUG, device, fmt, ## args)
+#define drbd_alert(device, fmt, args...) \
+ drbd_printk(KERN_ALERT, device, fmt, ## args)
+#define drbd_err(device, fmt, args...) \
+ drbd_printk(KERN_ERR, device, fmt, ## args)
+#define drbd_warn(device, fmt, args...) \
+ drbd_printk(KERN_WARNING, device, fmt, ## args)
+#define drbd_info(device, fmt, args...) \
+ drbd_printk(KERN_INFO, device, fmt, ## args)
+#define drbd_emerg(device, fmt, args...) \
+ drbd_printk(KERN_EMERG, device, fmt, ## args)
+
+#define dynamic_drbd_dbg(device, fmt, args...) \
+ dynamic_dev_dbg(disk_to_dev(device->vdisk), fmt, ## args)
#define conn_printk(LEVEL, TCONN, FMT, ARGS...) \
printk(LEVEL "d-con %s: " FMT, TCONN->resource->name , ## ARGS)
@@ -115,7 +130,7 @@
#define conn_dbg(TCONN, FMT, ARGS...) conn_printk(KERN_DEBUG, TCONN, FMT, ## ARGS)
#define D_ASSERT(exp) if (!(exp)) \
- dev_err(DEV, "ASSERT( " #exp " ) in %s:%d\n", __FILE__, __LINE__)
+ drbd_err(device, "ASSERT( " #exp " ) in %s:%d\n", __FILE__, __LINE__)
/**
* expect - Make an assertion
@@ -125,7 +140,7 @@
#define expect(exp) ({ \
bool _bool = (exp); \
if (!_bool) \
- dev_err(DEV, "ASSERTION %s FAILED in %s\n", \
+ drbd_err(device, "ASSERTION %s FAILED in %s\n", \
#exp, __func__); \
_bool; \
})
@@ -1278,7 +1293,7 @@
static inline void ov_out_of_sync_print(struct drbd_device *device)
{
if (device->ov_last_oos_size) {
- dev_err(DEV, "Out of sync: start=%llu, size=%lu (sectors)\n",
+ drbd_err(device, "Out of sync: start=%llu, size=%lu (sectors)\n",
(unsigned long long)device->ov_last_oos_start,
(unsigned long)device->ov_last_oos_size);
}
@@ -1504,7 +1519,7 @@
case EP_PASS_ON: /* FIXME would this be better named "Ignore"? */
if (df == DRBD_READ_ERROR || df == DRBD_WRITE_ERROR) {
if (__ratelimit(&drbd_ratelimit_state))
- dev_err(DEV, "Local IO failed in %s.\n", where);
+ drbd_err(device, "Local IO failed in %s.\n", where);
if (device->state.disk > D_INCONSISTENT)
_drbd_set_state(_NS(device, disk, D_INCONSISTENT), CS_HARD, NULL);
break;
@@ -1539,7 +1554,7 @@
set_bit(FORCE_DETACH, &device->flags);
if (device->state.disk > D_FAILED) {
_drbd_set_state(_NS(device, disk, D_FAILED), CS_HARD, NULL);
- dev_err(DEV,
+ drbd_err(device,
"Local IO failed in %s. Detaching...\n", where);
}
break;
@@ -1755,7 +1770,7 @@
#define ERR_IF_CNT_IS_NEGATIVE(which, func, line) \
if (atomic_read(&device->which) < 0) \
- dev_err(DEV, "in %s:%d: " #which " = %d < 0 !\n", \
+ drbd_err(device, "in %s:%d: " #which " = %d < 0 !\n", \
func, line, \
atomic_read(&device->which))
@@ -1888,7 +1903,7 @@
* for now, just prevent in-kernel buffer overflow.
*/
smp_rmb();
- dev_warn(DEV, "cs:%s rs_left=%lu > rs_total=%lu (rs_failed %lu)\n",
+ drbd_warn(device, "cs:%s rs_left=%lu > rs_total=%lu (rs_failed %lu)\n",
drbd_conn_str(device->state.conn),
*bits_left, device->rs_total, device->rs_failed);
*per_mil_done = 0;
@@ -2103,7 +2118,7 @@
int r;
if (device->ldev == NULL) {
- dev_warn(DEV, "device->ldev == NULL in drbd_md_flush\n");
+ drbd_warn(device, "device->ldev == NULL in drbd_md_flush\n");
return;
}
@@ -2113,7 +2128,7 @@
r = blkdev_issue_flush(device->ldev->md_bdev, GFP_NOIO, NULL);
if (r) {
set_bit(MD_NO_FUA, &device->flags);
- dev_err(DEV, "meta data flush failed with status %d, disabling md-flushes\n", r);
+ drbd_err(device, "meta data flush failed with status %d, disabling md-flushes\n", r);
}
}