iscsi-target: Convert gfp_t parameter to task state bitmask

This patch propigates the use of task state bitmask now used by
percpu_ida_alloc() up the iscsi-target callchain, replacing the
use of GFP_ATOMIC for TASK_RUNNING, and GFP_KERNEL for
TASK_INTERRUPTIBLE.

Also, drop the unnecessary gfp_t parameter to isert_allocate_cmd(),
and just pass TASK_INTERRUPTIBLE into iscsit_allocate_cmd().

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
Nicholas Bellinger 2014-01-20 03:36:44 +00:00
parent 555b270e25
commit 676687c696
5 changed files with 19 additions and 20 deletions

View File

@ -1028,13 +1028,13 @@ isert_rx_login_req(struct iser_rx_desc *rx_desc, int rx_buflen,
} }
static struct iscsi_cmd static struct iscsi_cmd
*isert_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp) *isert_allocate_cmd(struct iscsi_conn *conn)
{ {
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct isert_cmd *isert_cmd; struct isert_cmd *isert_cmd;
struct iscsi_cmd *cmd; struct iscsi_cmd *cmd;
cmd = iscsit_allocate_cmd(conn, gfp); cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
if (!cmd) { if (!cmd) {
pr_err("Unable to allocate iscsi_cmd + isert_cmd\n"); pr_err("Unable to allocate iscsi_cmd + isert_cmd\n");
return NULL; return NULL;
@ -1223,7 +1223,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
switch (opcode) { switch (opcode) {
case ISCSI_OP_SCSI_CMD: case ISCSI_OP_SCSI_CMD:
cmd = isert_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn);
if (!cmd) if (!cmd)
break; break;
@ -1237,7 +1237,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
rx_desc, (unsigned char *)hdr); rx_desc, (unsigned char *)hdr);
break; break;
case ISCSI_OP_NOOP_OUT: case ISCSI_OP_NOOP_OUT:
cmd = isert_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn);
if (!cmd) if (!cmd)
break; break;
@ -1250,7 +1250,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
(unsigned char *)hdr); (unsigned char *)hdr);
break; break;
case ISCSI_OP_SCSI_TMFUNC: case ISCSI_OP_SCSI_TMFUNC:
cmd = isert_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn);
if (!cmd) if (!cmd)
break; break;
@ -1258,7 +1258,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
(unsigned char *)hdr); (unsigned char *)hdr);
break; break;
case ISCSI_OP_LOGOUT: case ISCSI_OP_LOGOUT:
cmd = isert_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn);
if (!cmd) if (!cmd)
break; break;
@ -1269,7 +1269,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
HZ); HZ);
break; break;
case ISCSI_OP_TEXT: case ISCSI_OP_TEXT:
cmd = isert_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn);
if (!cmd) if (!cmd)
break; break;

View File

@ -621,7 +621,7 @@ static int iscsit_add_reject(
{ {
struct iscsi_cmd *cmd; struct iscsi_cmd *cmd;
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
if (!cmd) if (!cmd)
return -1; return -1;
@ -2476,7 +2476,7 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
if (!conn_p) if (!conn_p)
return; return;
cmd = iscsit_allocate_cmd(conn_p, GFP_ATOMIC); cmd = iscsit_allocate_cmd(conn_p, TASK_RUNNING);
if (!cmd) { if (!cmd) {
iscsit_dec_conn_usage_count(conn_p); iscsit_dec_conn_usage_count(conn_p);
return; return;
@ -3952,7 +3952,7 @@ static int iscsi_target_rx_opcode(struct iscsi_conn *conn, unsigned char *buf)
switch (hdr->opcode & ISCSI_OPCODE_MASK) { switch (hdr->opcode & ISCSI_OPCODE_MASK) {
case ISCSI_OP_SCSI_CMD: case ISCSI_OP_SCSI_CMD:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
if (!cmd) if (!cmd)
goto reject; goto reject;
@ -3964,28 +3964,28 @@ static int iscsi_target_rx_opcode(struct iscsi_conn *conn, unsigned char *buf)
case ISCSI_OP_NOOP_OUT: case ISCSI_OP_NOOP_OUT:
cmd = NULL; cmd = NULL;
if (hdr->ttt == cpu_to_be32(0xFFFFFFFF)) { if (hdr->ttt == cpu_to_be32(0xFFFFFFFF)) {
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
if (!cmd) if (!cmd)
goto reject; goto reject;
} }
ret = iscsit_handle_nop_out(conn, cmd, buf); ret = iscsit_handle_nop_out(conn, cmd, buf);
break; break;
case ISCSI_OP_SCSI_TMFUNC: case ISCSI_OP_SCSI_TMFUNC:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
if (!cmd) if (!cmd)
goto reject; goto reject;
ret = iscsit_handle_task_mgt_cmd(conn, cmd, buf); ret = iscsit_handle_task_mgt_cmd(conn, cmd, buf);
break; break;
case ISCSI_OP_TEXT: case ISCSI_OP_TEXT:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
if (!cmd) if (!cmd)
goto reject; goto reject;
ret = iscsit_handle_text_cmd(conn, cmd, buf); ret = iscsit_handle_text_cmd(conn, cmd, buf);
break; break;
case ISCSI_OP_LOGOUT: case ISCSI_OP_LOGOUT:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
if (!cmd) if (!cmd)
goto reject; goto reject;

View File

@ -152,12 +152,11 @@ void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd)
* May be called from software interrupt (timer) context for allocating * May be called from software interrupt (timer) context for allocating
* iSCSI NopINs. * iSCSI NopINs.
*/ */
struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state)
{ {
struct iscsi_cmd *cmd; struct iscsi_cmd *cmd;
struct se_session *se_sess = conn->sess->se_sess; struct se_session *se_sess = conn->sess->se_sess;
int size, tag, state = (gfp_mask & __GFP_WAIT) ? TASK_INTERRUPTIBLE : int size, tag;
TASK_RUNNING;
tag = percpu_ida_alloc(&se_sess->sess_tag_pool, state); tag = percpu_ida_alloc(&se_sess->sess_tag_pool, state);
if (tag < 0) if (tag < 0)
@ -930,7 +929,7 @@ static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response)
u8 state; u8 state;
struct iscsi_cmd *cmd; struct iscsi_cmd *cmd;
cmd = iscsit_allocate_cmd(conn, GFP_ATOMIC); cmd = iscsit_allocate_cmd(conn, TASK_RUNNING);
if (!cmd) if (!cmd)
return -1; return -1;

View File

@ -9,7 +9,7 @@ extern struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *);
extern void iscsit_free_r2t(struct iscsi_r2t *, struct iscsi_cmd *); extern void iscsit_free_r2t(struct iscsi_r2t *, struct iscsi_cmd *);
extern void iscsit_free_r2ts_from_list(struct iscsi_cmd *); extern void iscsit_free_r2ts_from_list(struct iscsi_cmd *);
extern struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *, gfp_t); extern struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *, gfp_t);
extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t); extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int);
extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32); extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32);
extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *); extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *);
extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32); extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32);

View File

@ -94,7 +94,7 @@ extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
/* /*
* From iscsi_target_util.c * From iscsi_target_util.c
*/ */
extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t); extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int);
extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *, extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *,
unsigned char *, __be32); unsigned char *, __be32);
extern void iscsit_release_cmd(struct iscsi_cmd *); extern void iscsit_release_cmd(struct iscsi_cmd *);