Skip to content

Commit e742fc3

Browse files
Mike Christieaxboe
authored andcommitted
target: use bio op accessors
Separate the op from the rq_flag_bits and have the target layer set/get the bio using bio_set_op_attrs/bio_op. Signed-off-by: Mike Christie <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 796a5cf commit e742fc3

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

drivers/target/target_core_iblock.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ static void iblock_bio_done(struct bio *bio)
312312
}
313313

314314
static struct bio *
315-
iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 sg_num, int rw)
315+
iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 sg_num, int op,
316+
int op_flags)
316317
{
317318
struct iblock_dev *ib_dev = IBLOCK_DEV(cmd->se_dev);
318319
struct bio *bio;
@@ -334,7 +335,7 @@ iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 sg_num, int rw)
334335
bio->bi_private = cmd;
335336
bio->bi_end_io = &iblock_bio_done;
336337
bio->bi_iter.bi_sector = lba;
337-
bio->bi_rw = rw;
338+
bio_set_op_attrs(bio, op, op_flags);
338339

339340
return bio;
340341
}
@@ -480,7 +481,7 @@ iblock_execute_write_same(struct se_cmd *cmd)
480481
goto fail;
481482
cmd->priv = ibr;
482483

483-
bio = iblock_get_bio(cmd, block_lba, 1, WRITE);
484+
bio = iblock_get_bio(cmd, block_lba, 1, REQ_OP_WRITE, 0);
484485
if (!bio)
485486
goto fail_free_ibr;
486487

@@ -493,7 +494,8 @@ iblock_execute_write_same(struct se_cmd *cmd)
493494
while (bio_add_page(bio, sg_page(sg), sg->length, sg->offset)
494495
!= sg->length) {
495496

496-
bio = iblock_get_bio(cmd, block_lba, 1, WRITE);
497+
bio = iblock_get_bio(cmd, block_lba, 1, REQ_OP_WRITE,
498+
0);
497499
if (!bio)
498500
goto fail_put_bios;
499501

@@ -679,8 +681,7 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
679681
struct scatterlist *sg;
680682
u32 sg_num = sgl_nents;
681683
unsigned bio_cnt;
682-
int rw = 0;
683-
int i;
684+
int i, op, op_flags = 0;
684685

685686
if (data_direction == DMA_TO_DEVICE) {
686687
struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
@@ -689,18 +690,15 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
689690
* Force writethrough using WRITE_FUA if a volatile write cache
690691
* is not enabled, or if initiator set the Force Unit Access bit.
691692
*/
693+
op = REQ_OP_WRITE;
692694
if (test_bit(QUEUE_FLAG_FUA, &q->queue_flags)) {
693695
if (cmd->se_cmd_flags & SCF_FUA)
694-
rw = WRITE_FUA;
696+
op_flags = WRITE_FUA;
695697
else if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags))
696-
rw = WRITE_FUA;
697-
else
698-
rw = WRITE;
699-
} else {
700-
rw = WRITE;
698+
op_flags = WRITE_FUA;
701699
}
702700
} else {
703-
rw = READ;
701+
op = REQ_OP_READ;
704702
}
705703

706704
ibr = kzalloc(sizeof(struct iblock_req), GFP_KERNEL);
@@ -714,7 +712,7 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
714712
return 0;
715713
}
716714

717-
bio = iblock_get_bio(cmd, block_lba, sgl_nents, rw);
715+
bio = iblock_get_bio(cmd, block_lba, sgl_nents, op, op_flags);
718716
if (!bio)
719717
goto fail_free_ibr;
720718

@@ -738,7 +736,8 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
738736
bio_cnt = 0;
739737
}
740738

741-
bio = iblock_get_bio(cmd, block_lba, sg_num, rw);
739+
bio = iblock_get_bio(cmd, block_lba, sg_num, op,
740+
op_flags);
742741
if (!bio)
743742
goto fail_put_bios;
744743

drivers/target/target_core_pscsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
922922
goto fail;
923923

924924
if (rw)
925-
bio->bi_rw |= REQ_WRITE;
925+
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
926926

927927
pr_debug("PSCSI: Allocated bio: %p,"
928928
" dir: %s nr_vecs: %d\n", bio,

0 commit comments

Comments
 (0)