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);
}
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);
}
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);
{
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);
.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);
}
.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);
}