dm: improve abnormal bio processing
Read/write/flush are the most common operations, optimize switch in is_abnormal_io() for those cases. Follows same pattern established in block perf-wip commit ("block: optimise blk_may_split for normal rw") Also, push is_abnormal_io() check and blk_queue_split() down from dm_submit_bio() to dm_split_and_process_bio() and set new 'is_abnormal_io' flag in clone_info. Optimize __split_and_process_bio and __process_abnormal_io by leveraging ci.is_abnormal_io flag. Signed-off-by: Mike Snitzer <snitzer@kernel.org>
This commit is contained in:
parent
9d20653fe8
commit
4edadf6dcb
@ -84,7 +84,8 @@ struct clone_info {
|
|||||||
struct dm_io *io;
|
struct dm_io *io;
|
||||||
sector_t sector;
|
sector_t sector;
|
||||||
unsigned sector_count;
|
unsigned sector_count;
|
||||||
bool submit_as_polled;
|
bool is_abnormal_io:1;
|
||||||
|
bool submit_as_polled:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DM_TARGET_IO_BIO_OFFSET (offsetof(struct dm_target_io, clone))
|
#define DM_TARGET_IO_BIO_OFFSET (offsetof(struct dm_target_io, clone))
|
||||||
@ -1491,21 +1492,24 @@ static void __send_changing_extent_only(struct clone_info *ci, struct dm_target
|
|||||||
|
|
||||||
static bool is_abnormal_io(struct bio *bio)
|
static bool is_abnormal_io(struct bio *bio)
|
||||||
{
|
{
|
||||||
bool r = false;
|
unsigned int op = bio_op(bio);
|
||||||
|
|
||||||
switch (bio_op(bio)) {
|
if (op != REQ_OP_READ && op != REQ_OP_WRITE && op != REQ_OP_FLUSH) {
|
||||||
case REQ_OP_DISCARD:
|
switch (op) {
|
||||||
case REQ_OP_SECURE_ERASE:
|
case REQ_OP_DISCARD:
|
||||||
case REQ_OP_WRITE_ZEROES:
|
case REQ_OP_SECURE_ERASE:
|
||||||
r = true;
|
case REQ_OP_WRITE_ZEROES:
|
||||||
break;
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti,
|
static blk_status_t __process_abnormal_io(struct clone_info *ci,
|
||||||
blk_status_t *status)
|
struct dm_target *ti)
|
||||||
{
|
{
|
||||||
unsigned num_bios = 0;
|
unsigned num_bios = 0;
|
||||||
|
|
||||||
@ -1519,8 +1523,6 @@ static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti,
|
|||||||
case REQ_OP_WRITE_ZEROES:
|
case REQ_OP_WRITE_ZEROES:
|
||||||
num_bios = ti->num_write_zeroes_bios;
|
num_bios = ti->num_write_zeroes_bios;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1530,12 +1532,10 @@ static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti,
|
|||||||
* check was performed.
|
* check was performed.
|
||||||
*/
|
*/
|
||||||
if (unlikely(!num_bios))
|
if (unlikely(!num_bios))
|
||||||
*status = BLK_STS_NOTSUPP;
|
return BLK_STS_NOTSUPP;
|
||||||
else {
|
|
||||||
__send_changing_extent_only(ci, ti, num_bios);
|
__send_changing_extent_only(ci, ti, num_bios);
|
||||||
*status = BLK_STS_OK;
|
return BLK_STS_OK;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1588,11 +1588,12 @@ static blk_status_t __split_and_process_bio(struct clone_info *ci)
|
|||||||
struct bio *clone;
|
struct bio *clone;
|
||||||
struct dm_target *ti;
|
struct dm_target *ti;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
blk_status_t error = BLK_STS_IOERR;
|
|
||||||
|
|
||||||
ti = dm_table_find_target(ci->map, ci->sector);
|
ti = dm_table_find_target(ci->map, ci->sector);
|
||||||
if (unlikely(!ti || __process_abnormal_io(ci, ti, &error)))
|
if (unlikely(!ti))
|
||||||
return error;
|
return BLK_STS_IOERR;
|
||||||
|
else if (unlikely(ci->is_abnormal_io))
|
||||||
|
return __process_abnormal_io(ci, ti);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only support bio polling for normal IO, and the target io is
|
* Only support bio polling for normal IO, and the target io is
|
||||||
@ -1612,11 +1613,12 @@ static blk_status_t __split_and_process_bio(struct clone_info *ci)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void init_clone_info(struct clone_info *ci, struct mapped_device *md,
|
static void init_clone_info(struct clone_info *ci, struct mapped_device *md,
|
||||||
struct dm_table *map, struct bio *bio)
|
struct dm_table *map, struct bio *bio, bool is_abnormal)
|
||||||
{
|
{
|
||||||
ci->map = map;
|
ci->map = map;
|
||||||
ci->io = alloc_io(md, bio);
|
ci->io = alloc_io(md, bio);
|
||||||
ci->bio = bio;
|
ci->bio = bio;
|
||||||
|
ci->is_abnormal_io = is_abnormal;
|
||||||
ci->submit_as_polled = false;
|
ci->submit_as_polled = false;
|
||||||
ci->sector = bio->bi_iter.bi_sector;
|
ci->sector = bio->bi_iter.bi_sector;
|
||||||
ci->sector_count = bio_sectors(bio);
|
ci->sector_count = bio_sectors(bio);
|
||||||
@ -1636,8 +1638,18 @@ static void dm_split_and_process_bio(struct mapped_device *md,
|
|||||||
struct clone_info ci;
|
struct clone_info ci;
|
||||||
struct dm_io *io;
|
struct dm_io *io;
|
||||||
blk_status_t error = BLK_STS_OK;
|
blk_status_t error = BLK_STS_OK;
|
||||||
|
bool is_abnormal;
|
||||||
|
|
||||||
init_clone_info(&ci, md, map, bio);
|
is_abnormal = is_abnormal_io(bio);
|
||||||
|
if (unlikely(is_abnormal)) {
|
||||||
|
/*
|
||||||
|
* Use blk_queue_split() for abnormal IO (e.g. discard, etc)
|
||||||
|
* otherwise associated queue_limits won't be imposed.
|
||||||
|
*/
|
||||||
|
blk_queue_split(&bio);
|
||||||
|
}
|
||||||
|
|
||||||
|
init_clone_info(&ci, md, map, bio, is_abnormal);
|
||||||
io = ci.io;
|
io = ci.io;
|
||||||
|
|
||||||
if (bio->bi_opf & REQ_PREFLUSH) {
|
if (bio->bi_opf & REQ_PREFLUSH) {
|
||||||
@ -1697,13 +1709,6 @@ static void dm_submit_bio(struct bio *bio)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Use blk_queue_split() for abnormal IO (e.g. discard, writesame, etc)
|
|
||||||
* otherwise associated queue_limits won't be imposed.
|
|
||||||
*/
|
|
||||||
if (unlikely(is_abnormal_io(bio)))
|
|
||||||
blk_queue_split(&bio);
|
|
||||||
|
|
||||||
dm_split_and_process_bio(md, map, bio);
|
dm_split_and_process_bio(md, map, bio);
|
||||||
out:
|
out:
|
||||||
dm_put_live_table_bio(md, srcu_idx, bio);
|
dm_put_live_table_bio(md, srcu_idx, bio);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user