Commit cb9e5273 authored by Damien Le Moal's avatar Damien Le Moal Committed by Jens Axboe

null_blk: Have all null_handle_xxx() return a blk_status_t

Modify the null_handle_flush() and null_handle_rq() functions to return
a blk_status_t instead of an errno to simplify the call sites of these
functions and to be consistant with other null_handle_xxx() functions.
Signed-off-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarNitesh Shetty <nj.shetty@samsung.com>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20240411085502.728558-2-dlemoal@kernel.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 99a9476b
...@@ -1167,7 +1167,7 @@ blk_status_t null_handle_discard(struct nullb_device *dev, ...@@ -1167,7 +1167,7 @@ blk_status_t null_handle_discard(struct nullb_device *dev,
return BLK_STS_OK; return BLK_STS_OK;
} }
static int null_handle_flush(struct nullb *nullb) static blk_status_t null_handle_flush(struct nullb *nullb)
{ {
int err; int err;
...@@ -1184,7 +1184,7 @@ static int null_handle_flush(struct nullb *nullb) ...@@ -1184,7 +1184,7 @@ static int null_handle_flush(struct nullb *nullb)
WARN_ON(!radix_tree_empty(&nullb->dev->cache)); WARN_ON(!radix_tree_empty(&nullb->dev->cache));
spin_unlock_irq(&nullb->lock); spin_unlock_irq(&nullb->lock);
return err; return errno_to_blk_status(err);
} }
static int null_transfer(struct nullb *nullb, struct page *page, static int null_transfer(struct nullb *nullb, struct page *page,
...@@ -1222,7 +1222,7 @@ static int null_handle_rq(struct nullb_cmd *cmd) ...@@ -1222,7 +1222,7 @@ static int null_handle_rq(struct nullb_cmd *cmd)
{ {
struct request *rq = blk_mq_rq_from_pdu(cmd); struct request *rq = blk_mq_rq_from_pdu(cmd);
struct nullb *nullb = cmd->nq->dev->nullb; struct nullb *nullb = cmd->nq->dev->nullb;
int err; int err = 0;
unsigned int len; unsigned int len;
sector_t sector = blk_rq_pos(rq); sector_t sector = blk_rq_pos(rq);
struct req_iterator iter; struct req_iterator iter;
...@@ -1234,15 +1234,13 @@ static int null_handle_rq(struct nullb_cmd *cmd) ...@@ -1234,15 +1234,13 @@ static int null_handle_rq(struct nullb_cmd *cmd)
err = null_transfer(nullb, bvec.bv_page, len, bvec.bv_offset, err = null_transfer(nullb, bvec.bv_page, len, bvec.bv_offset,
op_is_write(req_op(rq)), sector, op_is_write(req_op(rq)), sector,
rq->cmd_flags & REQ_FUA); rq->cmd_flags & REQ_FUA);
if (err) { if (err)
spin_unlock_irq(&nullb->lock); break;
return err;
}
sector += len >> SECTOR_SHIFT; sector += len >> SECTOR_SHIFT;
} }
spin_unlock_irq(&nullb->lock); spin_unlock_irq(&nullb->lock);
return 0; return errno_to_blk_status(err);
} }
static inline blk_status_t null_handle_throttled(struct nullb_cmd *cmd) static inline blk_status_t null_handle_throttled(struct nullb_cmd *cmd)
...@@ -1289,8 +1287,8 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, ...@@ -1289,8 +1287,8 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd,
if (op == REQ_OP_DISCARD) if (op == REQ_OP_DISCARD)
return null_handle_discard(dev, sector, nr_sectors); return null_handle_discard(dev, sector, nr_sectors);
return errno_to_blk_status(null_handle_rq(cmd));
return null_handle_rq(cmd);
} }
static void nullb_zero_read_cmd_buffer(struct nullb_cmd *cmd) static void nullb_zero_read_cmd_buffer(struct nullb_cmd *cmd)
...@@ -1359,7 +1357,7 @@ static void null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, ...@@ -1359,7 +1357,7 @@ static void null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
blk_status_t sts; blk_status_t sts;
if (op == REQ_OP_FLUSH) { if (op == REQ_OP_FLUSH) {
cmd->error = errno_to_blk_status(null_handle_flush(nullb)); cmd->error = null_handle_flush(nullb);
goto out; goto out;
} }
......
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