Commit e3fa02d7 authored by Christoph Böhmwalder's avatar Christoph Böhmwalder Committed by Jens Axboe
Browse files

drbd: introduce drbd_ratelimit()



Use call site specific ratelimit instead of one single static global.
Also ratelimit ASSERTION messages generated by expect().

Originally-from: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: default avatarChristoph Böhmwalder <christoph.boehmwalder@linbit.com>
Link: https://lore.kernel.org/r/20221201110349.1282687-5-christoph.boehmwalder@linbit.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent aa034695
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1143,7 +1143,7 @@ void drbd_rs_complete_io(struct drbd_device *device, sector_t sector)
	bm_ext = e ? lc_entry(e, struct bm_extent, lce) : NULL;
	if (!bm_ext) {
		spin_unlock_irqrestore(&device->al_lock, flags);
		if (__ratelimit(&drbd_ratelimit_state))
		if (drbd_ratelimit())
			drbd_err(device, "drbd_rs_complete_io() called, but extent not found\n");
		return;
	}
+3 −3
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ struct drbd_bitmap {
static void __bm_print_lock_info(struct drbd_device *device, const char *func)
{
	struct drbd_bitmap *b = device->bitmap;
	if (!__ratelimit(&drbd_ratelimit_state))
	if (!drbd_ratelimit())
		return;
	drbd_err(device, "FIXME %s[%d] in %s, bitmap locked for '%s' by %s[%d]\n",
		 current->comm, task_pid_nr(current),
@@ -952,7 +952,7 @@ static void drbd_bm_endio(struct bio *bio)
		bm_set_page_io_err(b->bm_pages[idx]);
		/* Not identical to on disk version of it.
		 * Is BM_PAGE_IO_ERROR enough? */
		if (__ratelimit(&drbd_ratelimit_state))
		if (drbd_ratelimit())
			drbd_err(device, "IO ERROR %d on bitmap page idx %u\n",
					bio->bi_status, idx);
	} else {
@@ -1013,7 +1013,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_ho
		else
			len = PAGE_SIZE;
	} else {
		if (__ratelimit(&drbd_ratelimit_state)) {
		if (drbd_ratelimit()) {
			drbd_err(device, "Invalid offset during on-disk bitmap access: "
				 "page idx %u, sector %llu\n", page_nr, on_disk_sector);
		}
+1 −1
Original line number Diff line number Diff line
@@ -1658,7 +1658,7 @@ static inline void __drbd_chk_io_error_(struct drbd_device *device,
	switch (ep) {
	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))
			if (drbd_ratelimit())
				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);
+1 −1
Original line number Diff line number Diff line
@@ -3767,7 +3767,7 @@ _drbd_insert_fault(struct drbd_device *device, unsigned int type)
	if (ret) {
		drbd_fault_count++;

		if (__ratelimit(&drbd_ratelimit_state))
		if (drbd_ratelimit())
			drbd_warn(device, "***Simulating %s failure\n",
				_drbd_fault_str(type));
	}
+9 −1
Original line number Diff line number Diff line
@@ -110,6 +110,14 @@ void drbd_dyn_dbg_with_wrong_object_type(void);
	drbd_printk(KERN_INFO, device, fmt, ## args)


#define drbd_ratelimit() \
({						\
	static DEFINE_RATELIMIT_STATE(_rs,	\
		DEFAULT_RATELIMIT_INTERVAL,	\
		DEFAULT_RATELIMIT_BURST);	\
	__ratelimit(&_rs);			\
})

#define D_ASSERT(x, exp)							\
	do {									\
		if (!(exp))							\
@@ -124,7 +132,7 @@ void drbd_dyn_dbg_with_wrong_object_type(void);
 */
#define expect(exp) ({								\
		bool _bool = (exp);						\
		if (!_bool)							\
		if (!_bool && drbd_ratelimit())					\
			drbd_err(device, "ASSERTION %s FAILED in %s\n",		\
				#exp, __func__);				\
		_bool;								\
Loading