aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-12-21 14:14:05 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2012-02-25 17:37:46 -0500
commit3d26fea01d5f80e3e585d69d8d73a60e1ca563a0 (patch)
tree6955955e14533854f9e9eaae7b7475e819bc53d5
parent7d680f3b74dd6f0f57569eeeee8c257790ceaa96 (diff)
target: remove the transport_lun_active field in struct se_cmd
There is no reason to have a flag telling if a command is on the per-lun list, we can simply do a list_empty check before removing it as long as we're careful to always use list_del_init. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/target_core_device.c5
-rw-r--r--drivers/target/target_core_transport.c13
-rw-r--r--include/target/target_core_base.h1
3 files changed, 3 insertions, 16 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index edbcabbf85f..0b25b50900e 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -159,13 +159,8 @@ int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
159 dev->read_bytes += se_cmd->data_length; 159 dev->read_bytes += se_cmd->data_length;
160 spin_unlock_irqrestore(&dev->stats_lock, flags); 160 spin_unlock_irqrestore(&dev->stats_lock, flags);
161 161
162 /*
163 * Add the iscsi_cmd_t to the struct se_lun's cmd list. This list is used
164 * for tracking state of struct se_cmds during LUN shutdown events.
165 */
166 spin_lock_irqsave(&se_lun->lun_cmd_lock, flags); 162 spin_lock_irqsave(&se_lun->lun_cmd_lock, flags);
167 list_add_tail(&se_cmd->se_lun_node, &se_lun->lun_cmd_list); 163 list_add_tail(&se_cmd->se_lun_node, &se_lun->lun_cmd_list);
168 atomic_set(&se_cmd->transport_lun_active, 1);
169 spin_unlock_irqrestore(&se_lun->lun_cmd_lock, flags); 164 spin_unlock_irqrestore(&se_lun->lun_cmd_lock, flags);
170 165
171 return 0; 166 return 0;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index f704123752c..78ea638aa3b 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -546,14 +546,8 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd)
546 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 546 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
547 547
548 spin_lock_irqsave(&lun->lun_cmd_lock, flags); 548 spin_lock_irqsave(&lun->lun_cmd_lock, flags);
549 if (atomic_read(&cmd->transport_lun_active)) { 549 if (!list_empty(&cmd->se_lun_node))
550 list_del(&cmd->se_lun_node); 550 list_del_init(&cmd->se_lun_node);
551 atomic_set(&cmd->transport_lun_active, 0);
552#if 0
553 pr_debug("Removed ITT: 0x%08x from LUN LIST[%d]\n"
554 cmd->se_tfo->get_task_tag(cmd), lun->unpacked_lun);
555#endif
556 }
557 spin_unlock_irqrestore(&lun->lun_cmd_lock, flags); 551 spin_unlock_irqrestore(&lun->lun_cmd_lock, flags);
558} 552}
559 553
@@ -4163,9 +4157,8 @@ static void __transport_clear_lun_from_sessions(struct se_lun *lun)
4163 while (!list_empty(&lun->lun_cmd_list)) { 4157 while (!list_empty(&lun->lun_cmd_list)) {
4164 cmd = list_first_entry(&lun->lun_cmd_list, 4158 cmd = list_first_entry(&lun->lun_cmd_list,
4165 struct se_cmd, se_lun_node); 4159 struct se_cmd, se_lun_node);
4166 list_del(&cmd->se_lun_node); 4160 list_del_init(&cmd->se_lun_node);
4167 4161
4168 atomic_set(&cmd->transport_lun_active, 0);
4169 /* 4162 /*
4170 * This will notify iscsi_target_transport.c: 4163 * This will notify iscsi_target_transport.c:
4171 * transport_cmd_check_stop() that a LUN shutdown is in 4164 * transport_cmd_check_stop() that a LUN shutdown is in
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 9e7a6a5451c..5b7d5f3dd24 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -572,7 +572,6 @@ struct se_cmd {
572#define CMD_T_LUN_STOP (1 << 7) 572#define CMD_T_LUN_STOP (1 << 7)
573#define CMD_T_LUN_FE_STOP (1 << 8) 573#define CMD_T_LUN_FE_STOP (1 << 8)
574#define CMD_T_DEV_ACTIVE (1 << 9) 574#define CMD_T_DEV_ACTIVE (1 << 9)
575 atomic_t transport_lun_active;
576 spinlock_t t_state_lock; 575 spinlock_t t_state_lock;
577 struct completion t_transport_stop_comp; 576 struct completion t_transport_stop_comp;
578 struct completion transport_lun_fe_stop_comp; 577 struct completion transport_lun_fe_stop_comp;