Skip to content

Commit cb9e527

Browse files
damien-lemoalaxboe
authored andcommitted
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: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20240411085502.728558-2-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 99a9476 commit cb9e527

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

drivers/block/null_blk/main.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ blk_status_t null_handle_discard(struct nullb_device *dev,
11671167
return BLK_STS_OK;
11681168
}
11691169

1170-
static int null_handle_flush(struct nullb *nullb)
1170+
static blk_status_t null_handle_flush(struct nullb *nullb)
11711171
{
11721172
int err;
11731173

@@ -1184,7 +1184,7 @@ static int null_handle_flush(struct nullb *nullb)
11841184

11851185
WARN_ON(!radix_tree_empty(&nullb->dev->cache));
11861186
spin_unlock_irq(&nullb->lock);
1187-
return err;
1187+
return errno_to_blk_status(err);
11881188
}
11891189

11901190
static int null_transfer(struct nullb *nullb, struct page *page,
@@ -1222,7 +1222,7 @@ static int null_handle_rq(struct nullb_cmd *cmd)
12221222
{
12231223
struct request *rq = blk_mq_rq_from_pdu(cmd);
12241224
struct nullb *nullb = cmd->nq->dev->nullb;
1225-
int err;
1225+
int err = 0;
12261226
unsigned int len;
12271227
sector_t sector = blk_rq_pos(rq);
12281228
struct req_iterator iter;
@@ -1234,15 +1234,13 @@ static int null_handle_rq(struct nullb_cmd *cmd)
12341234
err = null_transfer(nullb, bvec.bv_page, len, bvec.bv_offset,
12351235
op_is_write(req_op(rq)), sector,
12361236
rq->cmd_flags & REQ_FUA);
1237-
if (err) {
1238-
spin_unlock_irq(&nullb->lock);
1239-
return err;
1240-
}
1237+
if (err)
1238+
break;
12411239
sector += len >> SECTOR_SHIFT;
12421240
}
12431241
spin_unlock_irq(&nullb->lock);
12441242

1245-
return 0;
1243+
return errno_to_blk_status(err);
12461244
}
12471245

12481246
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,
12891287

12901288
if (op == REQ_OP_DISCARD)
12911289
return null_handle_discard(dev, sector, nr_sectors);
1292-
return errno_to_blk_status(null_handle_rq(cmd));
12931290

1291+
return null_handle_rq(cmd);
12941292
}
12951293

12961294
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,
13591357
blk_status_t sts;
13601358

13611359
if (op == REQ_OP_FLUSH) {
1362-
cmd->error = errno_to_blk_status(null_handle_flush(nullb));
1360+
cmd->error = null_handle_flush(nullb);
13631361
goto out;
13641362
}
13651363

0 commit comments

Comments
 (0)