Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7042cae authored by Nicholas Bellinger's avatar Nicholas Bellinger
Browse files

target: Fix target_submit_tmr se_tmr_req allocation failures



This patch makes target_submit_tmr() se_tmr_req allocation occur before
target_get_sess_cmd(), and changes target_submit_tmr() to return a failure
w/ non zero status to the fabric caller upon core_tmr_alloc_req() failure.

Cc: Andy Grover <agrover@redhat.com>
Cc: Kiran Patil <kiran.patil@intel.com>
Cc: Arun Easi <arun.easi@qlogic.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 3de55ec7
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -1704,11 +1704,12 @@ EXPORT_SYMBOL(target_submit_cmd);
 * @unpacked_lun: unpacked LUN to reference for struct se_lun
 * @unpacked_lun: unpacked LUN to reference for struct se_lun
 * @fabric_context: fabric context for TMR req
 * @fabric_context: fabric context for TMR req
 * @tm_type: Type of TM request
 * @tm_type: Type of TM request
 * @flags: submit cmd flags
 *
 *
 * Callable from all contexts.
 * Callable from all contexts.
 **/
 **/


void target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,
int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,
		unsigned char *sense, u32 unpacked_lun,
		unsigned char *sense, u32 unpacked_lun,
		void *fabric_tmr_ptr, unsigned char tm_type, int flags)
		void *fabric_tmr_ptr, unsigned char tm_type, int flags)
{
{
@@ -1720,25 +1721,26 @@ void target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,


	transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess,
	transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess,
			      0, DMA_NONE, MSG_SIMPLE_TAG, sense);
			      0, DMA_NONE, MSG_SIMPLE_TAG, sense);
	/*
	 * FIXME: Currently expect caller to handle se_cmd->se_tmr_req
	 * allocation failure.
	 */
	ret = core_tmr_alloc_req(se_cmd, fabric_tmr_ptr, tm_type, GFP_KERNEL);
	if (ret < 0)
		return -ENOMEM;


	/* See target_submit_cmd for commentary */
	/* See target_submit_cmd for commentary */
	target_get_sess_cmd(se_sess, se_cmd, (flags & TARGET_SCF_ACK_KREF));
	target_get_sess_cmd(se_sess, se_cmd, (flags & TARGET_SCF_ACK_KREF));


	ret = core_tmr_alloc_req(se_cmd, fabric_tmr_ptr, tm_type, GFP_KERNEL);
	if (ret < 0) {
		dump_stack();
		/* FIXME XXX */
		return;
	}

	ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun);
	ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun);
	if (ret) {
	if (ret) {
		se_cmd->se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST;
		se_cmd->se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST;
		se_cmd->se_tfo->queue_tm_rsp(se_cmd);
		se_cmd->se_tfo->queue_tm_rsp(se_cmd);
		transport_generic_free_cmd(se_cmd, 0);
		transport_generic_free_cmd(se_cmd, 0);
		return;
		return 0;
	}
	}
	transport_generic_handle_tmr(se_cmd);
	transport_generic_handle_tmr(se_cmd);
	return 0;
}
}
EXPORT_SYMBOL(target_submit_tmr);
EXPORT_SYMBOL(target_submit_tmr);


+1 −1
Original line number Original line Diff line number Diff line
@@ -116,7 +116,7 @@ int transport_lookup_cmd_lun(struct se_cmd *, u32);
int	transport_generic_allocate_tasks(struct se_cmd *, unsigned char *);
int	transport_generic_allocate_tasks(struct se_cmd *, unsigned char *);
void	target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *,
void	target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *,
		unsigned char *, u32, u32, int, int, int);
		unsigned char *, u32, u32, int, int, int);
void	target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,
int	target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,
		unsigned char *sense, u32 unpacked_lun,
		unsigned char *sense, u32 unpacked_lun,
		void *fabric_tmr_ptr, unsigned char tm_type, int flags);
		void *fabric_tmr_ptr, unsigned char tm_type, int flags);
int	transport_handle_cdb_direct(struct se_cmd *);
int	transport_handle_cdb_direct(struct se_cmd *);