mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-17 18:56:24 +00:00
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: Christoph Böhmwalder <christoph.boehmwalder@linbit.com> Link: https://lore.kernel.org/r/20221201110349.1282687-5-christoph.boehmwalder@linbit.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
aa03469597
commit
e3fa02d7d4
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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; \
|
||||
|
@ -2165,7 +2165,7 @@ static int receive_RSDataReply(struct drbd_connection *connection, struct packet
|
||||
* or in drbd_peer_request_endio. */
|
||||
err = recv_resync_read(peer_device, sector, pi);
|
||||
} else {
|
||||
if (__ratelimit(&drbd_ratelimit_state))
|
||||
if (drbd_ratelimit())
|
||||
drbd_err(device, "Can not write resync data to local disk.\n");
|
||||
|
||||
err = drbd_drain_block(peer_device, pi->size);
|
||||
@ -2846,7 +2846,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
if (verb && __ratelimit(&drbd_ratelimit_state))
|
||||
if (verb && drbd_ratelimit())
|
||||
drbd_err(device, "Can not satisfy peer's read request, "
|
||||
"no local data.\n");
|
||||
|
||||
|
@ -144,7 +144,7 @@ void drbd_req_destroy(struct kref *kref)
|
||||
if (get_ldev_if_state(device, D_FAILED)) {
|
||||
drbd_al_complete_io(device, &req->i);
|
||||
put_ldev(device);
|
||||
} else if (__ratelimit(&drbd_ratelimit_state)) {
|
||||
} else if (drbd_ratelimit()) {
|
||||
drbd_warn(device, "Should have called drbd_al_complete_io(, %llu, %u), "
|
||||
"but my Disk seems to have failed :(\n",
|
||||
(unsigned long long) req->i.sector, req->i.size);
|
||||
@ -518,7 +518,7 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
|
||||
|
||||
static void drbd_report_io_error(struct drbd_device *device, struct drbd_request *req)
|
||||
{
|
||||
if (!__ratelimit(&drbd_ratelimit_state))
|
||||
if (!drbd_ratelimit())
|
||||
return;
|
||||
|
||||
drbd_warn(device, "local %s IO error sector %llu+%u on %pg\n",
|
||||
@ -1402,7 +1402,7 @@ static void drbd_send_and_submit(struct drbd_device *device, struct drbd_request
|
||||
submit_private_bio = true;
|
||||
} else if (no_remote) {
|
||||
nodata:
|
||||
if (__ratelimit(&drbd_ratelimit_state))
|
||||
if (drbd_ratelimit())
|
||||
drbd_err(device, "IO ERROR: neither local nor remote data, sector %llu+%u\n",
|
||||
(unsigned long long)req->i.sector, req->i.size >> 9);
|
||||
/* A write may have been queued for send_oos, however.
|
||||
|
@ -176,7 +176,7 @@ void drbd_peer_request_endio(struct bio *bio)
|
||||
bool is_discard = bio_op(bio) == REQ_OP_WRITE_ZEROES ||
|
||||
bio_op(bio) == REQ_OP_DISCARD;
|
||||
|
||||
if (bio->bi_status && __ratelimit(&drbd_ratelimit_state))
|
||||
if (bio->bi_status && drbd_ratelimit())
|
||||
drbd_warn(device, "%s: error=%d s=%llus\n",
|
||||
is_write ? (is_discard ? "discard" : "write")
|
||||
: "read", bio->bi_status,
|
||||
@ -240,7 +240,7 @@ void drbd_request_endio(struct bio *bio)
|
||||
* though we still will complain noisily about it.
|
||||
*/
|
||||
if (unlikely(req->rq_state & RQ_LOCAL_ABORTED)) {
|
||||
if (__ratelimit(&drbd_ratelimit_state))
|
||||
if (drbd_ratelimit())
|
||||
drbd_emerg(device, "delayed completion of aborted local request; disk-timeout may be too aggressive\n");
|
||||
|
||||
if (!bio->bi_status)
|
||||
@ -1062,7 +1062,7 @@ int w_e_end_data_req(struct drbd_work *w, int cancel)
|
||||
if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
|
||||
err = drbd_send_block(peer_device, P_DATA_REPLY, peer_req);
|
||||
} else {
|
||||
if (__ratelimit(&drbd_ratelimit_state))
|
||||
if (drbd_ratelimit())
|
||||
drbd_err(device, "Sending NegDReply. sector=%llus.\n",
|
||||
(unsigned long long)peer_req->i.sector);
|
||||
|
||||
@ -1135,13 +1135,13 @@ int w_e_end_rsdata_req(struct drbd_work *w, int cancel)
|
||||
else
|
||||
err = drbd_send_block(peer_device, P_RS_DATA_REPLY, peer_req);
|
||||
} else {
|
||||
if (__ratelimit(&drbd_ratelimit_state))
|
||||
if (drbd_ratelimit())
|
||||
drbd_err(device, "Not sending RSDataReply, "
|
||||
"partner DISKLESS!\n");
|
||||
err = 0;
|
||||
}
|
||||
} else {
|
||||
if (__ratelimit(&drbd_ratelimit_state))
|
||||
if (drbd_ratelimit())
|
||||
drbd_err(device, "Sending NegRSDReply. sector %llus.\n",
|
||||
(unsigned long long)peer_req->i.sector);
|
||||
|
||||
@ -1212,7 +1212,7 @@ int w_e_end_csum_rs_req(struct drbd_work *w, int cancel)
|
||||
}
|
||||
} else {
|
||||
err = drbd_send_ack(peer_device, P_NEG_RS_DREPLY, peer_req);
|
||||
if (__ratelimit(&drbd_ratelimit_state))
|
||||
if (drbd_ratelimit())
|
||||
drbd_err(device, "Sending NegDReply. I guess it gets messy.\n");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user