Skip to content

Commit 7ea88e2

Browse files
ChaitanayaKulkarniaxboe
authored andcommitted
null_blk: create a helper for mem-backed ops
This patch creates a helper for handling requests when null_blk is memory backed in the null_handle_cmd(). Although the helper is very simple right now, it makes the code flow consistent with the rest of code in the null_handle_cmd() and provides a uniform code structure for future code. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8f94d1c commit 7ea88e2

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

‎drivers/block/null_blk_main.c‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,13 +1168,26 @@ static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd,
11681168
return BLK_STS_OK;
11691169
}
11701170

1171+
static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd,
1172+
enum req_opf op)
1173+
{
1174+
struct nullb_device *dev = cmd->nq->dev;
1175+
int err;
1176+
1177+
if (dev->queue_mode == NULL_Q_BIO)
1178+
err = null_handle_bio(cmd);
1179+
else
1180+
err = null_handle_rq(cmd);
1181+
1182+
return errno_to_blk_status(err);
1183+
}
1184+
11711185
static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
11721186
sector_t nr_sectors, enum req_opf op)
11731187
{
11741188
struct nullb_device *dev = cmd->nq->dev;
11751189
struct nullb *nullb = dev->nullb;
11761190
blk_status_t sts;
1177-
int err = 0;
11781191

11791192
if (test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) {
11801193
sts = null_handle_throttled(cmd);
@@ -1193,14 +1206,8 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
11931206
goto out;
11941207
}
11951208

1196-
if (dev->memory_backed) {
1197-
if (dev->queue_mode == NULL_Q_BIO)
1198-
err = null_handle_bio(cmd);
1199-
else
1200-
err = null_handle_rq(cmd);
1201-
}
1202-
1203-
cmd->error = errno_to_blk_status(err);
1209+
if (dev->memory_backed)
1210+
cmd->error = null_handle_memory_backed(cmd, op);
12041211

12051212
if (!cmd->error && dev->zoned) {
12061213
if (op == REQ_OP_WRITE)

0 commit comments

Comments
 (0)