aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-15 20:04:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-15 20:04:56 -0400
commitfe83558a33f509277aa07566d484096cc7149807 (patch)
treecde95a043410e70600f17363ffab474d13a0f5db
parentf1cbd03f5eabb75ea8ace23b47d2209f10871c16 (diff)
parent00fdc6bbef77844ce397a7de7acfaf25e8e2e4eb (diff)
Merge branch '3.3-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull target fixes from Nicholas Bellinger: "This series addresses two recently reported regression bugs related to legacy SCSI reservation usage in target core, and iscsi-target reservation conflict handling. The second patch in particular addresses possible data-corruption with SCSI reservations that is specific to iscsi-target fabric LUNs with multiple client writers. Both patches need to go into v3.2 stable ASAP, and the branch based on the last target-pending/3.3-rc-fixes HEAD. Again, thanks to Martin Svec for his help to identify and address this regression bug with iscsi-target." * '3.3-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: iscsi-target: Fix reservation conflict -EBUSY response handling bug target: Fix compatible reservation handling (CRH=1) with legacy RESERVE/RELEASE
-rw-r--r--drivers/target/iscsi/iscsi_target.c2
-rw-r--r--drivers/target/target_core_pr.c34
-rw-r--r--drivers/target/target_core_transport.c1
3 files changed, 24 insertions, 13 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 44262908def..501b27c1814 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1028,7 +1028,7 @@ done:
1028 return iscsit_add_reject_from_cmd( 1028 return iscsit_add_reject_from_cmd(
1029 ISCSI_REASON_BOOKMARK_NO_RESOURCES, 1029 ISCSI_REASON_BOOKMARK_NO_RESOURCES,
1030 1, 1, buf, cmd); 1030 1, 1, buf, cmd);
1031 } else if (transport_ret == -EINVAL) { 1031 } else if (transport_ret < 0) {
1032 /* 1032 /*
1033 * Unsupported SAM Opcode. CHECK_CONDITION will be sent 1033 * Unsupported SAM Opcode. CHECK_CONDITION will be sent
1034 * in iscsit_execute_cmd() during the CmdSN OOO Execution 1034 * in iscsit_execute_cmd() during the CmdSN OOO Execution
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index b7c779389ee..63e703bb6ac 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -117,7 +117,7 @@ static struct t10_pr_registration *core_scsi3_locate_pr_reg(struct se_device *,
117 struct se_node_acl *, struct se_session *); 117 struct se_node_acl *, struct se_session *);
118static void core_scsi3_put_pr_reg(struct t10_pr_registration *); 118static void core_scsi3_put_pr_reg(struct t10_pr_registration *);
119 119
120static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret) 120static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd)
121{ 121{
122 struct se_session *se_sess = cmd->se_sess; 122 struct se_session *se_sess = cmd->se_sess;
123 struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev; 123 struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
@@ -127,7 +127,7 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret)
127 int conflict = 0; 127 int conflict = 0;
128 128
129 if (!crh) 129 if (!crh)
130 return false; 130 return -EINVAL;
131 131
132 pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl, 132 pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl,
133 se_sess); 133 se_sess);
@@ -155,16 +155,14 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret)
155 */ 155 */
156 if (pr_reg->pr_res_holder) { 156 if (pr_reg->pr_res_holder) {
157 core_scsi3_put_pr_reg(pr_reg); 157 core_scsi3_put_pr_reg(pr_reg);
158 *ret = 0; 158 return 1;
159 return false;
160 } 159 }
161 if ((pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY) || 160 if ((pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY) ||
162 (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY) || 161 (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY) ||
163 (pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG) || 162 (pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG) ||
164 (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG)) { 163 (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG)) {
165 core_scsi3_put_pr_reg(pr_reg); 164 core_scsi3_put_pr_reg(pr_reg);
166 *ret = 0; 165 return 1;
167 return true;
168 } 166 }
169 core_scsi3_put_pr_reg(pr_reg); 167 core_scsi3_put_pr_reg(pr_reg);
170 conflict = 1; 168 conflict = 1;
@@ -189,10 +187,10 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret)
189 " while active SPC-3 registrations exist," 187 " while active SPC-3 registrations exist,"
190 " returning RESERVATION_CONFLICT\n"); 188 " returning RESERVATION_CONFLICT\n");
191 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; 189 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
192 return true; 190 return -EBUSY;
193 } 191 }
194 192
195 return false; 193 return 0;
196} 194}
197 195
198int target_scsi2_reservation_release(struct se_task *task) 196int target_scsi2_reservation_release(struct se_task *task)
@@ -201,12 +199,18 @@ int target_scsi2_reservation_release(struct se_task *task)
201 struct se_device *dev = cmd->se_dev; 199 struct se_device *dev = cmd->se_dev;
202 struct se_session *sess = cmd->se_sess; 200 struct se_session *sess = cmd->se_sess;
203 struct se_portal_group *tpg = sess->se_tpg; 201 struct se_portal_group *tpg = sess->se_tpg;
204 int ret = 0; 202 int ret = 0, rc;
205 203
206 if (!sess || !tpg) 204 if (!sess || !tpg)
207 goto out; 205 goto out;
208 if (target_check_scsi2_reservation_conflict(cmd, &ret)) 206 rc = target_check_scsi2_reservation_conflict(cmd);
207 if (rc == 1)
208 goto out;
209 else if (rc < 0) {
210 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
211 ret = -EINVAL;
209 goto out; 212 goto out;
213 }
210 214
211 ret = 0; 215 ret = 0;
212 spin_lock(&dev->dev_reservation_lock); 216 spin_lock(&dev->dev_reservation_lock);
@@ -243,7 +247,7 @@ int target_scsi2_reservation_reserve(struct se_task *task)
243 struct se_device *dev = cmd->se_dev; 247 struct se_device *dev = cmd->se_dev;
244 struct se_session *sess = cmd->se_sess; 248 struct se_session *sess = cmd->se_sess;
245 struct se_portal_group *tpg = sess->se_tpg; 249 struct se_portal_group *tpg = sess->se_tpg;
246 int ret = 0; 250 int ret = 0, rc;
247 251
248 if ((cmd->t_task_cdb[1] & 0x01) && 252 if ((cmd->t_task_cdb[1] & 0x01) &&
249 (cmd->t_task_cdb[1] & 0x02)) { 253 (cmd->t_task_cdb[1] & 0x02)) {
@@ -259,8 +263,14 @@ int target_scsi2_reservation_reserve(struct se_task *task)
259 */ 263 */
260 if (!sess || !tpg) 264 if (!sess || !tpg)
261 goto out; 265 goto out;
262 if (target_check_scsi2_reservation_conflict(cmd, &ret)) 266 rc = target_check_scsi2_reservation_conflict(cmd);
267 if (rc == 1)
263 goto out; 268 goto out;
269 else if (rc < 0) {
270 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
271 ret = -EINVAL;
272 goto out;
273 }
264 274
265 ret = 0; 275 ret = 0;
266 spin_lock(&dev->dev_reservation_lock); 276 spin_lock(&dev->dev_reservation_lock);
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 58cea07b12f..cd5cd95812b 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2539,6 +2539,7 @@ static int transport_generic_cmd_sequencer(
2539 cmd, cdb, pr_reg_type) != 0) { 2539 cmd, cdb, pr_reg_type) != 0) {
2540 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 2540 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
2541 cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT; 2541 cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT;
2542 cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT;
2542 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; 2543 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
2543 return -EBUSY; 2544 return -EBUSY;
2544 } 2545 }