scsi: target: Abstract tag freeing
authorMatthew Wilcox <willy@infradead.org>
Tue, 12 Jun 2018 19:05:43 +0000 (12:05 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 20 Jun 2018 02:02:25 +0000 (22:02 -0400)
Introduce target_free_tag() and convert all drivers to use it.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_target.c
drivers/target/iscsi/iscsi_target_util.c
drivers/target/sbp/sbp_target.c
drivers/target/tcm_fc/tfc_cmd.c
drivers/usb/gadget/function/f_tcm.c
drivers/vhost/scsi.c
drivers/xen/xen-scsiback.c
include/target/target_core_base.h

index 0fea2e2326becbf4993dd7cc216e36dad529d678..11274317118aa0c6d17a0109b678db3579bdb2a0 100644 (file)
@@ -3783,7 +3783,7 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd)
                return;
        }
        cmd->jiffies_at_free = get_jiffies_64();
-       percpu_ida_free(&sess->se_sess->sess_tag_pool, cmd->se_cmd.map_tag);
+       target_free_tag(sess->se_sess, &cmd->se_cmd);
 }
 EXPORT_SYMBOL(qlt_free_cmd);
 
@@ -4146,7 +4146,7 @@ out_term:
        qlt_send_term_exchange(qpair, NULL, &cmd->atio, 1, 0);
 
        qlt_decr_num_pend_cmds(vha);
-       percpu_ida_free(&sess->se_sess->sess_tag_pool, cmd->se_cmd.map_tag);
+       target_free_tag(sess->se_sess, &cmd->se_cmd);
        spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
 
        spin_lock_irqsave(&ha->tgt.sess_lock, flags);
index 4435bf374d2d55fd79d9dc75dbd086a7ba6dbc28..7e98697cfb8e0a7f2d67bd4d97331130dc301040 100644 (file)
@@ -711,7 +711,7 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd)
        kfree(cmd->iov_data);
        kfree(cmd->text_in_ptr);
 
-       percpu_ida_free(&sess->se_sess->sess_tag_pool, se_cmd->map_tag);
+       target_free_tag(sess->se_sess, se_cmd);
 }
 EXPORT_SYMBOL(iscsit_release_cmd);
 
index fb1003921d85af2313bae2a6197e50957f08d5da..679ae29d25ab6d4358ebbe88c11b7dca07d2f9aa 100644 (file)
@@ -1460,7 +1460,7 @@ static void sbp_free_request(struct sbp_target_request *req)
        kfree(req->pg_tbl);
        kfree(req->cmd_buf);
 
-       percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
+       target_free_tag(se_sess, se_cmd);
 }
 
 static void sbp_mgt_agent_process(struct work_struct *work)
index ec372860106f1219ec4fe1a9d5e156ae0475a551..13e4efbe1ce7379c1a816c9b9f52a5e60ba1a60b 100644 (file)
@@ -92,7 +92,7 @@ static void ft_free_cmd(struct ft_cmd *cmd)
        if (fr_seq(fp))
                fc_seq_release(fr_seq(fp));
        fc_frame_free(fp);
-       percpu_ida_free(&sess->se_sess->sess_tag_pool, cmd->se_cmd.map_tag);
+       target_free_tag(sess->se_sess, &cmd->se_cmd);
        ft_sess_put(sess);      /* undo get from lookup at recv */
 }
 
@@ -461,7 +461,7 @@ static void ft_recv_cmd(struct ft_sess *sess, struct fc_frame *fp)
        cmd->sess = sess;
        cmd->seq = fc_seq_assign(lport, fp);
        if (!cmd->seq) {
-               percpu_ida_free(&se_sess->sess_tag_pool, tag);
+               target_free_tag(se_sess, &cmd->se_cmd);
                goto busy;
        }
        cmd->req_frame = fp;            /* hold frame during cmd */
index d78dbb73bde856477f5d3bdee9f4a9a304bf8a17..9f670d9224b96965eb5ca43268d36eddc0b665ac 100644 (file)
@@ -1288,7 +1288,7 @@ static void usbg_release_cmd(struct se_cmd *se_cmd)
        struct se_session *se_sess = se_cmd->se_sess;
 
        kfree(cmd->data_buf);
-       percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
+       target_free_tag(se_sess, se_cmd);
 }
 
 static u32 usbg_sess_get_index(struct se_session *se_sess)
index 17fcd3b2e68668ec12e51680dde8a04673979555..7aaf0e5512ed58992200dfd2675463003d84b646 100644 (file)
@@ -324,7 +324,7 @@ static void vhost_scsi_release_cmd(struct se_cmd *se_cmd)
        }
 
        vhost_scsi_put_inflight(tv_cmd->inflight);
-       percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
+       target_free_tag(se_sess, se_cmd);
 }
 
 static u32 vhost_scsi_sess_get_index(struct se_session *se_sess)
index 7bc88fd43cfc84d05873893ef4ddec8307e76c2a..ec6635258ed8b75e199f6163a9174e0ecf13dfe0 100644 (file)
@@ -1377,9 +1377,7 @@ static int scsiback_check_stop_free(struct se_cmd *se_cmd)
 
 static void scsiback_release_cmd(struct se_cmd *se_cmd)
 {
-       struct se_session *se_sess = se_cmd->se_sess;
-
-       percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
+       target_free_tag(se_cmd->se_sess, se_cmd);
 }
 
 static u32 scsiback_sess_get_index(struct se_session *se_sess)
index 922a39f45abcffc96f06c4c6b491e9a9b9f20576..260c2f3e9460724836068b0665f911c7369337ab 100644 (file)
@@ -934,4 +934,9 @@ static inline void atomic_dec_mb(atomic_t *v)
        smp_mb__after_atomic();
 }
 
+static inline void target_free_tag(struct se_session *sess, struct se_cmd *cmd)
+{
+       percpu_ida_free(&sess->sess_tag_pool, cmd->map_tag);
+}
+
 #endif /* TARGET_CORE_BASE_H */