* [PATCH 0/3] tcm_fc: Review cleanups and LUN_RESET bugfix
@ 2011-05-27 21:41 Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 1/3] tcm_fc: Makefile cleanups Nicholas A. Bellinger
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Nicholas A. Bellinger @ 2011-05-27 21:41 UTC (permalink / raw)
To: linux-scsi, Christoph Hellwig
Cc: James Bottomley, Kiran Patil, Open-FCoE devel, Nicholas Bellinger
From: Nicholas Bellinger <nab@linux-iscsi.org>
Hi Christoph,
The following is short cleanup series for tcm_fc based upon your feedback
this morning, and includes the outstanding LUN_RESET bugfix patch that
did not make it in with the initial merge.
Kiran needs to review and test the second patch, but I think the conversion
if pretty obvious.
These patches have been pushed in lio-core-2.6.git/master on .40-rc0,
and this series applies on top of the latest linux-2.6.git/HEAD.
Thanks,
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Nicholas Bellinger (3):
tcm_fc: Makefile cleanups
tcm_fc: Convert to wake_up_process and schedule_timeout_interruptible
tcm_fc: Fix ft_send_tm bug and drop ft_lookup_cmd_lun usage
drivers/target/tcm_fc/Makefile | 17 +++----------
drivers/target/tcm_fc/tcm_fc.h | 2 +-
drivers/target/tcm_fc/tfc_cmd.c | 46 ++++++++++----------------------------
drivers/target/tcm_fc/tfc_conf.c | 4 +-
4 files changed, 19 insertions(+), 50 deletions(-)
--
1.7.5.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] tcm_fc: Makefile cleanups
2011-05-27 21:41 [PATCH 0/3] tcm_fc: Review cleanups and LUN_RESET bugfix Nicholas A. Bellinger
@ 2011-05-27 21:41 ` Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 2/3] tcm_fc: Convert to wake_up_process and schedule_timeout_interruptible Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 3/3] tcm_fc: Fix ft_send_tm bug and drop ft_lookup_cmd_lun usage Nicholas A. Bellinger
2 siblings, 0 replies; 5+ messages in thread
From: Nicholas A. Bellinger @ 2011-05-27 21:41 UTC (permalink / raw)
To: linux-scsi, Christoph Hellwig
Cc: James Bottomley, Kiran Patil, Open-FCoE devel, Nicholas Bellinger
From: Nicholas Bellinger <nab@linux-iscsi.org>
This patch removes the unnecessary EXTRA_CFLAGS includes, and drops the
unused -DTCM_FC_DEBUG define.
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
drivers/target/tcm_fc/Makefile | 17 ++++-------------
1 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/target/tcm_fc/Makefile b/drivers/target/tcm_fc/Makefile
index 7a5c2b6..20b14bb 100644
--- a/drivers/target/tcm_fc/Makefile
+++ b/drivers/target/tcm_fc/Makefile
@@ -1,15 +1,6 @@
-EXTRA_CFLAGS += -I$(srctree)/drivers/target/ \
- -I$(srctree)/drivers/scsi/ \
- -I$(srctree)/include/scsi/ \
- -I$(srctree)/drivers/target/tcm_fc/
-
-tcm_fc-y += tfc_cmd.o \
- tfc_conf.o \
- tfc_io.o \
- tfc_sess.o
+tcm_fc-y += tfc_cmd.o \
+ tfc_conf.o \
+ tfc_io.o \
+ tfc_sess.o
obj-$(CONFIG_TCM_FC) += tcm_fc.o
-
-ifdef CONFIGFS_TCM_FC_DEBUG
-EXTRA_CFLAGS += -DTCM_FC_DEBUG
-endif
--
1.7.5.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] tcm_fc: Convert to wake_up_process and schedule_timeout_interruptible
2011-05-27 21:41 [PATCH 0/3] tcm_fc: Review cleanups and LUN_RESET bugfix Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 1/3] tcm_fc: Makefile cleanups Nicholas A. Bellinger
@ 2011-05-27 21:41 ` Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 3/3] tcm_fc: Fix ft_send_tm bug and drop ft_lookup_cmd_lun usage Nicholas A. Bellinger
2 siblings, 0 replies; 5+ messages in thread
From: Nicholas A. Bellinger @ 2011-05-27 21:41 UTC (permalink / raw)
To: linux-scsi, Christoph Hellwig
Cc: James Bottomley, Kiran Patil, Open-FCoE devel, Nicholas Bellinger
From: Nicholas Bellinger <nab@linux-iscsi.org>
This patch converts ft_queue_cmd() to use wake_up_process() and
ft_thread() to use schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT)
instead of wait_event_interruptible(). This fixes a potential race with
the wait_event_interruptible() conditional with qobj->queue_cnt in
ft_thread().
This patch also drops the unnecessary set_user_nice(current, -20) in
ft_thread(), and drops extra () around two if (!(acl)) conditionals in
tfc_conf.c.
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
drivers/target/tcm_fc/tfc_cmd.c | 17 ++++++++---------
drivers/target/tcm_fc/tfc_conf.c | 4 ++--
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index c056a11..b8345cc 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -119,15 +119,17 @@ static int ft_get_lun_for_cmd(struct ft_cmd *cmd, u8 *lunp)
static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd)
{
- struct se_queue_obj *qobj;
+ struct ft_tpg *tpg = sess->tport->tpg;
+ struct se_queue_obj *qobj = &tpg->qobj;
unsigned long flags;
qobj = &sess->tport->tpg->qobj;
spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
list_add_tail(&cmd->se_req.qr_list, &qobj->qobj_list);
- spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
atomic_inc(&qobj->queue_cnt);
- wake_up_interruptible(&qobj->thread_wq);
+ spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
+
+ wake_up_process(tpg->thread);
}
static struct ft_cmd *ft_dequeue_cmd(struct se_queue_obj *qobj)
@@ -695,15 +697,12 @@ int ft_thread(void *arg)
struct ft_tpg *tpg = arg;
struct se_queue_obj *qobj = &tpg->qobj;
struct ft_cmd *cmd;
- int ret;
-
- set_user_nice(current, -20);
while (!kthread_should_stop()) {
- ret = wait_event_interruptible(qobj->thread_wq,
- atomic_read(&qobj->queue_cnt) || kthread_should_stop());
- if (ret < 0 || kthread_should_stop())
+ schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT);
+ if (kthread_should_stop())
goto out;
+
cmd = ft_dequeue_cmd(qobj);
if (cmd)
ft_exec_req(cmd);
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index 84e868c..aa2f33f 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -223,7 +223,7 @@ static struct se_node_acl *ft_add_acl(
return ERR_PTR(-EINVAL);
acl = kzalloc(sizeof(struct ft_node_acl), GFP_KERNEL);
- if (!(acl))
+ if (!acl)
return ERR_PTR(-ENOMEM);
acl->node_auth.port_name = wwpn;
@@ -280,7 +280,7 @@ struct se_node_acl *ft_tpg_alloc_fabric_acl(struct se_portal_group *se_tpg)
struct ft_node_acl *acl;
acl = kzalloc(sizeof(*acl), GFP_KERNEL);
- if (!(acl)) {
+ if (!acl) {
printk(KERN_ERR "Unable to allocate struct ft_node_acl\n");
return NULL;
}
--
1.7.5.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] tcm_fc: Fix ft_send_tm bug and drop ft_lookup_cmd_lun usage
2011-05-27 21:41 [PATCH 0/3] tcm_fc: Review cleanups and LUN_RESET bugfix Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 1/3] tcm_fc: Makefile cleanups Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 2/3] tcm_fc: Convert to wake_up_process and schedule_timeout_interruptible Nicholas A. Bellinger
@ 2011-05-27 21:41 ` Nicholas A. Bellinger
2011-05-27 21:50 ` Nicholas A. Bellinger
2 siblings, 1 reply; 5+ messages in thread
From: Nicholas A. Bellinger @ 2011-05-27 21:41 UTC (permalink / raw)
To: linux-scsi, Christoph Hellwig
Cc: James Bottomley, Kiran Patil, Open-FCoE devel, Nicholas Bellinger
From: Nicholas Bellinger <nab@linux-iscsi.org>
This patch fixes a bug in ft_send_tm() that was incorrectly calling
ft_lookup_cmd_lun() -> transport_lookup_cmd_lun(), instead of using
transport_lookup_tmr_lun() for the proper struct se_lun lookup.
It also drops the now unnecessary ft_lookup_cmd_lun() code, and uses
scsilun_to_int() directly ahead of direct transport_lookup_cmd_lun()
and transport_lookup_tmr_lun() usage.
Reported-by: Patil, Kiran <kiran.patil@intel.com>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
drivers/target/tcm_fc/tcm_fc.h | 2 +-
drivers/target/tcm_fc/tfc_cmd.c | 29 ++++-------------------------
2 files changed, 5 insertions(+), 26 deletions(-)
diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
index defff32..a0b4d5c 100644
--- a/drivers/target/tcm_fc/tcm_fc.h
+++ b/drivers/target/tcm_fc/tcm_fc.h
@@ -144,7 +144,7 @@ enum ft_cmd_state {
*/
struct ft_cmd {
enum ft_cmd_state state;
- u16 lun; /* LUN from request */
+ u32 lun; /* LUN from request */
struct ft_sess *sess; /* session held for cmd */
struct fc_seq *seq; /* sequence in exchange mgr */
struct se_cmd se_cmd; /* Local TCM I/O descriptor */
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index b8345cc..09204f7 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -94,29 +94,6 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
16, 4, cmd->cdb, MAX_COMMAND_SIZE, 0);
}
-/*
- * Get LUN from CDB.
- */
-static int ft_get_lun_for_cmd(struct ft_cmd *cmd, u8 *lunp)
-{
- u64 lun;
-
- lun = lunp[1];
- switch (lunp[0] >> 6) {
- case 0:
- break;
- case 1:
- lun |= (lunp[0] & 0x3f) << 8;
- break;
- default:
- return -1;
- }
- if (lun >= TRANSPORT_MAX_LUNS_PER_TPG)
- return -1;
- cmd->lun = lun;
- return transport_get_lun_for_cmd(&cmd->se_cmd, NULL, lun);
-}
-
static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd)
{
struct ft_tpg *tpg = sess->tport->tpg;
@@ -427,7 +404,8 @@ static void ft_send_tm(struct ft_cmd *cmd)
switch (fcp->fc_tm_flags) {
case FCP_TMF_LUN_RESET:
tm_func = TMR_LUN_RESET;
- if (ft_get_lun_for_cmd(cmd, fcp->fc_lun) < 0) {
+ cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
+ if (transport_lookup_tmr_lun(&cmd->se_cmd, cmd->lun) < 0) {
ft_dump_cmd(cmd, __func__);
transport_send_check_condition_and_sense(&cmd->se_cmd,
cmd->se_cmd.scsi_sense_reason, 0);
@@ -637,7 +615,8 @@ static void ft_send_cmd(struct ft_cmd *cmd)
fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd);
- ret = ft_get_lun_for_cmd(cmd, fcp->fc_lun);
+ cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
+ ret = transport_lookup_cmd_lun(&cmd->se_cmd, cmd->lun);
if (ret < 0) {
ft_dump_cmd(cmd, __func__);
transport_send_check_condition_and_sense(&cmd->se_cmd,
--
1.7.5.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] tcm_fc: Fix ft_send_tm bug and drop ft_lookup_cmd_lun usage
2011-05-27 21:41 ` [PATCH 3/3] tcm_fc: Fix ft_send_tm bug and drop ft_lookup_cmd_lun usage Nicholas A. Bellinger
@ 2011-05-27 21:50 ` Nicholas A. Bellinger
0 siblings, 0 replies; 5+ messages in thread
From: Nicholas A. Bellinger @ 2011-05-27 21:50 UTC (permalink / raw)
To: linux-scsi
Cc: Christoph Hellwig, James Bottomley, Kiran Patil, Open-FCoE devel
Please disregard this patch, as it uses LIO v4.1
transport_lookup_*_lun() naming change instead of what's current in
mainline..
On Fri, 2011-05-27 at 14:41 -0700, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
>
> This patch fixes a bug in ft_send_tm() that was incorrectly calling
> ft_lookup_cmd_lun() -> transport_lookup_cmd_lun(), instead of using
> transport_lookup_tmr_lun() for the proper struct se_lun lookup.
>
> It also drops the now unnecessary ft_lookup_cmd_lun() code, and uses
> scsilun_to_int() directly ahead of direct transport_lookup_cmd_lun()
> and transport_lookup_tmr_lun() usage.
>
Please disregard this patch and use PATCH-v2, as the rev below uses the
target core v4.1 transport_lookup_*_lun() naming changes instead of
what's currently in mainline target core.
Thanks,
--nab
> Reported-by: Patil, Kiran <kiran.patil@intel.com>
> Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
> ---
> drivers/target/tcm_fc/tcm_fc.h | 2 +-
> drivers/target/tcm_fc/tfc_cmd.c | 29 ++++-------------------------
> 2 files changed, 5 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
> index defff32..a0b4d5c 100644
> --- a/drivers/target/tcm_fc/tcm_fc.h
> +++ b/drivers/target/tcm_fc/tcm_fc.h
> @@ -144,7 +144,7 @@ enum ft_cmd_state {
> */
> struct ft_cmd {
> enum ft_cmd_state state;
> - u16 lun; /* LUN from request */
> + u32 lun; /* LUN from request */
> struct ft_sess *sess; /* session held for cmd */
> struct fc_seq *seq; /* sequence in exchange mgr */
> struct se_cmd se_cmd; /* Local TCM I/O descriptor */
> diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
> index b8345cc..09204f7 100644
> --- a/drivers/target/tcm_fc/tfc_cmd.c
> +++ b/drivers/target/tcm_fc/tfc_cmd.c
> @@ -94,29 +94,6 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
> 16, 4, cmd->cdb, MAX_COMMAND_SIZE, 0);
> }
>
> -/*
> - * Get LUN from CDB.
> - */
> -static int ft_get_lun_for_cmd(struct ft_cmd *cmd, u8 *lunp)
> -{
> - u64 lun;
> -
> - lun = lunp[1];
> - switch (lunp[0] >> 6) {
> - case 0:
> - break;
> - case 1:
> - lun |= (lunp[0] & 0x3f) << 8;
> - break;
> - default:
> - return -1;
> - }
> - if (lun >= TRANSPORT_MAX_LUNS_PER_TPG)
> - return -1;
> - cmd->lun = lun;
> - return transport_get_lun_for_cmd(&cmd->se_cmd, NULL, lun);
> -}
> -
> static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd)
> {
> struct ft_tpg *tpg = sess->tport->tpg;
> @@ -427,7 +404,8 @@ static void ft_send_tm(struct ft_cmd *cmd)
> switch (fcp->fc_tm_flags) {
> case FCP_TMF_LUN_RESET:
> tm_func = TMR_LUN_RESET;
> - if (ft_get_lun_for_cmd(cmd, fcp->fc_lun) < 0) {
> + cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
> + if (transport_lookup_tmr_lun(&cmd->se_cmd, cmd->lun) < 0) {
> ft_dump_cmd(cmd, __func__);
> transport_send_check_condition_and_sense(&cmd->se_cmd,
> cmd->se_cmd.scsi_sense_reason, 0);
> @@ -637,7 +615,8 @@ static void ft_send_cmd(struct ft_cmd *cmd)
>
> fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd);
>
> - ret = ft_get_lun_for_cmd(cmd, fcp->fc_lun);
> + cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
> + ret = transport_lookup_cmd_lun(&cmd->se_cmd, cmd->lun);
> if (ret < 0) {
> ft_dump_cmd(cmd, __func__);
> transport_send_check_condition_and_sense(&cmd->se_cmd,
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-05-27 21:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27 21:41 [PATCH 0/3] tcm_fc: Review cleanups and LUN_RESET bugfix Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 1/3] tcm_fc: Makefile cleanups Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 2/3] tcm_fc: Convert to wake_up_process and schedule_timeout_interruptible Nicholas A. Bellinger
2011-05-27 21:41 ` [PATCH 3/3] tcm_fc: Fix ft_send_tm bug and drop ft_lookup_cmd_lun usage Nicholas A. Bellinger
2011-05-27 21:50 ` Nicholas A. Bellinger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.