Skip to content

Commit b75a80f

Browse files
author
Mike Snitzer
committed
dm bufio: don't bug for clear developer oversight
Reasonable to relax to WARN_ON because these are easily avoided but do offer some assurance future coding mistakes won't occur (if changes tested properly). Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent 0511228 commit b75a80f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/md/dm-bufio.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ static void adjust_total_allocated(struct dm_buffer *b, bool unlink)
378378
*/
379379
static void __cache_size_refresh(void)
380380
{
381-
BUG_ON(!mutex_is_locked(&dm_bufio_clients_lock));
382-
BUG_ON(dm_bufio_client_count < 0);
381+
if (WARN_ON(!mutex_is_locked(&dm_bufio_clients_lock)))
382+
return;
383+
if (WARN_ON(dm_bufio_client_count < 0))
384+
return;
383385

384386
dm_bufio_cache_size_latch = READ_ONCE(dm_bufio_cache_size);
385387

@@ -1536,7 +1538,8 @@ static void drop_buffers(struct dm_bufio_client *c)
15361538
int i;
15371539
bool warned = false;
15381540

1539-
BUG_ON(dm_bufio_in_request());
1541+
if (WARN_ON(dm_bufio_in_request()))
1542+
return; /* should never happen */
15401543

15411544
/*
15421545
* An optimization so that the buffers are not written one-by-one.
@@ -1556,7 +1559,7 @@ static void drop_buffers(struct dm_bufio_client *c)
15561559
(unsigned long long)b->block, b->hold_count, i);
15571560
#ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
15581561
stack_trace_print(b->stack_entries, b->stack_len, 1);
1559-
/* mark unclaimed to avoid BUG_ON below */
1562+
/* mark unclaimed to avoid WARN_ON below */
15601563
b->hold_count = 0;
15611564
#endif
15621565
}
@@ -1567,7 +1570,7 @@ static void drop_buffers(struct dm_bufio_client *c)
15671570
#endif
15681571

15691572
for (i = 0; i < LIST_SIZE; i++)
1570-
BUG_ON(!list_empty(&c->lru[i]));
1573+
WARN_ON(!list_empty(&c->lru[i]));
15711574

15721575
dm_bufio_unlock(c);
15731576
}

0 commit comments

Comments
 (0)