Skip to content

Commit 0869419

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: target: core: Add gfp_t arg to target_cmd_init_cdb()
tcm_loop could be used like a normal block device, so we can't use GFP_KERNEL and should use GFP_NOIO. This adds a gfp_t arg to target_cmd_init_cdb() and converts the users. For every driver but loop GFP_KERNEL is kept. This will also be useful in subsequent patches where loop needs to do target_submit_prep() from interrupt context to get a ref to the se_device, and so it will need to use GFP_ATOMIC. Link: https://lore.kernel.org/r/20210227170006.5077-16-michael.christie@oracle.com Tested-by: Laurence Oberman <loberman@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 0fa50a8 commit 0869419

10 files changed

Lines changed: 23 additions & 16 deletions

File tree

‎drivers/infiniband/ulp/srpt/ib_srpt.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,8 @@ static void srpt_handle_cmd(struct srpt_rdma_ch *ch,
15371537
goto busy;
15381538
}
15391539

1540-
if (target_submit_prep(cmd, srp_cmd->cdb, sg, sg_cnt, NULL, 0, NULL, 0))
1540+
if (target_submit_prep(cmd, srp_cmd->cdb, sg, sg_cnt, NULL, 0, NULL, 0,
1541+
GFP_KERNEL))
15411542
return;
15421543

15431544
target_submit(cmd);

‎drivers/scsi/qla2xxx/tcm_qla2xxx.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
492492
if (rc)
493493
return rc;
494494

495-
if (target_submit_prep(se_cmd, cdb, NULL, 0, NULL, 0, NULL, 0))
495+
if (target_submit_prep(se_cmd, cdb, NULL, 0, NULL, 0, NULL, 0,
496+
GFP_KERNEL))
496497
return 0;
497498

498499
target_submit(se_cmd);

‎drivers/target/iscsi/iscsi_target.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,8 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
11661166

11671167
target_get_sess_cmd(&cmd->se_cmd, true);
11681168

1169-
cmd->sense_reason = target_cmd_init_cdb(&cmd->se_cmd, hdr->cdb);
1169+
cmd->sense_reason = target_cmd_init_cdb(&cmd->se_cmd, hdr->cdb,
1170+
GFP_KERNEL);
11701171
if (cmd->sense_reason) {
11711172
if (cmd->sense_reason == TCM_OUT_OF_RESOURCES) {
11721173
return iscsit_add_reject_cmd(cmd,

‎drivers/target/loopback/tcm_loop.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ static void tcm_loop_submission_work(struct work_struct *work)
156156

157157
if (target_submit_prep(se_cmd, sc->cmnd, scsi_sglist(sc),
158158
scsi_sg_count(sc), sgl_bidi, sgl_bidi_count,
159-
scsi_prot_sglist(sc), scsi_prot_sg_count(sc)))
159+
scsi_prot_sglist(sc), scsi_prot_sg_count(sc),
160+
GFP_NOIO))
160161
return;
161162

162163
target_submit(se_cmd);

‎drivers/target/target_core_transport.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
14291429
}
14301430

14311431
sense_reason_t
1432-
target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb)
1432+
target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb, gfp_t gfp)
14331433
{
14341434
sense_reason_t ret;
14351435

@@ -1450,8 +1450,7 @@ target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb)
14501450
* setup the pointer from __t_task_cdb to t_task_cdb.
14511451
*/
14521452
if (scsi_command_size(cdb) > sizeof(cmd->__t_task_cdb)) {
1453-
cmd->t_task_cdb = kzalloc(scsi_command_size(cdb),
1454-
GFP_KERNEL);
1453+
cmd->t_task_cdb = kzalloc(scsi_command_size(cdb), gfp);
14551454
if (!cmd->t_task_cdb) {
14561455
pr_err("Unable to allocate cmd->t_task_cdb"
14571456
" %u > sizeof(cmd->__t_task_cdb): %lu ops\n",
@@ -1640,6 +1639,7 @@ EXPORT_SYMBOL_GPL(target_init_cmd);
16401639
* @sgl_bidi_count: scatterlist count for bidirectional READ mapping
16411640
* @sgl_prot: struct scatterlist memory protection information
16421641
* @sgl_prot_count: scatterlist count for protection information
1642+
* @gfp: gfp allocation type
16431643
*
16441644
* Returns:
16451645
* - less than zero to signal failure.
@@ -1650,11 +1650,12 @@ EXPORT_SYMBOL_GPL(target_init_cmd);
16501650
int target_submit_prep(struct se_cmd *se_cmd, unsigned char *cdb,
16511651
struct scatterlist *sgl, u32 sgl_count,
16521652
struct scatterlist *sgl_bidi, u32 sgl_bidi_count,
1653-
struct scatterlist *sgl_prot, u32 sgl_prot_count)
1653+
struct scatterlist *sgl_prot, u32 sgl_prot_count,
1654+
gfp_t gfp)
16541655
{
16551656
sense_reason_t rc;
16561657

1657-
rc = target_cmd_init_cdb(se_cmd, cdb);
1658+
rc = target_cmd_init_cdb(se_cmd, cdb, gfp);
16581659
if (rc)
16591660
goto send_cc_direct;
16601661

@@ -1790,7 +1791,8 @@ void target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
17901791
if (rc)
17911792
return;
17921793

1793-
if (target_submit_prep(se_cmd, cdb, NULL, 0, NULL, 0, NULL, 0))
1794+
if (target_submit_prep(se_cmd, cdb, NULL, 0, NULL, 0, NULL, 0,
1795+
GFP_KERNEL))
17941796
return;
17951797

17961798
target_submit(se_cmd);

‎drivers/target/target_core_xcopy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ static int target_xcopy_setup_pt_cmd(
554554
}
555555
cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
556556

557-
if (target_cmd_init_cdb(cmd, cdb))
557+
if (target_cmd_init_cdb(cmd, cdb, GFP_KERNEL))
558558
return -EINVAL;
559559

560560
cmd->tag = 0;

‎drivers/target/tcm_fc/tfc_cmd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ static void ft_send_work(struct work_struct *work)
555555
goto err;
556556

557557
if (target_submit_prep(&cmd->se_cmd, fcp->fc_cdb, NULL, 0, NULL, 0,
558-
NULL, 0))
558+
NULL, 0, GFP_KERNEL))
559559
return;
560560

561561
target_submit(&cmd->se_cmd);

‎drivers/vhost/scsi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ static void vhost_scsi_submission_work(struct work_struct *work)
811811

812812
if (target_submit_prep(se_cmd, cmd->tvc_cdb, sg_ptr,
813813
cmd->tvc_sgl_count, NULL, 0, sg_prot_ptr,
814-
cmd->tvc_prot_sgl_count))
814+
cmd->tvc_prot_sgl_count, GFP_KERNEL))
815815
return;
816816

817817
target_submit(se_cmd);

‎drivers/xen/xen-scsiback.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static void scsiback_cmd_exec(struct vscsibk_pend *pending_req)
368368
pending_req->sc_data_direction, TARGET_SCF_ACK_KREF);
369369

370370
if (target_submit_prep(se_cmd, pending_req->cmnd, pending_req->sgl,
371-
pending_req->n_sg, NULL, 0, NULL, 0))
371+
pending_req->n_sg, NULL, 0, NULL, 0, GFP_KERNEL))
372372
return;
373373

374374
target_submit(se_cmd);

‎include/target/target_core_fabric.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,11 @@ int target_init_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
157157
int target_submit_prep(struct se_cmd *se_cmd, unsigned char *cdb,
158158
struct scatterlist *sgl, u32 sgl_count,
159159
struct scatterlist *sgl_bidi, u32 sgl_bidi_count,
160-
struct scatterlist *sgl_prot, u32 sgl_prot_count);
160+
struct scatterlist *sgl_prot, u32 sgl_prot_count, gfp_t gfp);
161161
void target_submit(struct se_cmd *se_cmd);
162162
sense_reason_t transport_lookup_cmd_lun(struct se_cmd *);
163-
sense_reason_t target_cmd_init_cdb(struct se_cmd *, unsigned char *);
163+
sense_reason_t target_cmd_init_cdb(struct se_cmd *se_cmd, unsigned char *cdb,
164+
gfp_t gfp);
164165
sense_reason_t target_cmd_parse_cdb(struct se_cmd *);
165166
void target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *,
166167
unsigned char *, u64, u32, int, int, int);

0 commit comments

Comments
 (0)