Commit 05112287 authored by Mike Snitzer's avatar Mike Snitzer

dm bufio: never crash if dm_bufio_in_request()

All these instances are entirely avoidable given that they speak to
coding mistakes that result in inappropriate use. Proper testing during
development will catch any such coding bug so its best to relax all of
these from BUG_ON to WARN_ON_ONCE.
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent 555977dd
......@@ -1152,7 +1152,8 @@ EXPORT_SYMBOL_GPL(dm_bufio_get);
void *dm_bufio_read(struct dm_bufio_client *c, sector_t block,
struct dm_buffer **bp)
{
BUG_ON(dm_bufio_in_request());
if (WARN_ON_ONCE(dm_bufio_in_request()))
return ERR_PTR(-EINVAL);
return new_read(c, block, NF_READ, bp);
}
......@@ -1161,7 +1162,8 @@ EXPORT_SYMBOL_GPL(dm_bufio_read);
void *dm_bufio_new(struct dm_bufio_client *c, sector_t block,
struct dm_buffer **bp)
{
BUG_ON(dm_bufio_in_request());
if (WARN_ON_ONCE(dm_bufio_in_request()))
return ERR_PTR(-EINVAL);
return new_read(c, block, NF_FRESH, bp);
}
......@@ -1174,7 +1176,8 @@ void dm_bufio_prefetch(struct dm_bufio_client *c,
LIST_HEAD(write_list);
BUG_ON(dm_bufio_in_request());
if (WARN_ON_ONCE(dm_bufio_in_request()))
return; /* should never happen */
blk_start_plug(&plug);
dm_bufio_lock(c);
......@@ -1281,7 +1284,8 @@ void dm_bufio_write_dirty_buffers_async(struct dm_bufio_client *c)
{
LIST_HEAD(write_list);
BUG_ON(dm_bufio_in_request());
if (WARN_ON_ONCE(dm_bufio_in_request()))
return; /* should never happen */
dm_bufio_lock(c);
__write_dirty_buffers_async(c, 0, &write_list);
......@@ -1386,7 +1390,8 @@ int dm_bufio_issue_flush(struct dm_bufio_client *c)
.count = 0,
};
BUG_ON(dm_bufio_in_request());
if (WARN_ON_ONCE(dm_bufio_in_request()))
return -EINVAL;
return dm_io(&io_req, 1, &io_reg, NULL);
}
......@@ -1409,7 +1414,8 @@ int dm_bufio_issue_discard(struct dm_bufio_client *c, sector_t block, sector_t c
.count = block_to_sector(c, count),
};
BUG_ON(dm_bufio_in_request());
if (WARN_ON_ONCE(dm_bufio_in_request()))
return -EINVAL; /* discards are optional */
return dm_io(&io_req, 1, &io_reg, NULL);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment