Skip to content

Commit 801e0ce

Browse files
Christof SchmittJames Bottomley
authored andcommitted
[SCSI] zfcp: Locking for req_no and req_seq_no
There is a possible race condition while generating the unique request ids and sequence numbers. Both might be read at the same time and have the same value. Fix this by serializing the access through the queue lock of the adapter: First call zfcp_fsf_req_sbal_get that acquires the lock, then read and increment the unique ids. Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1 parent 1d589ed commit 801e0ce

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/s390/scsi/zfcp_fsf.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4645,23 +4645,22 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
46454645
fsf_req->adapter = adapter;
46464646
fsf_req->fsf_command = fsf_cmd;
46474647
INIT_LIST_HEAD(&fsf_req->list);
4648-
4649-
/* this is serialized (we are holding req_queue-lock of adapter */
4650-
if (adapter->req_no == 0)
4651-
adapter->req_no++;
4652-
fsf_req->req_id = adapter->req_no++;
4653-
46544648
init_timer(&fsf_req->timer);
4655-
zfcp_fsf_req_qtcb_init(fsf_req);
46564649

46574650
/* initialize waitqueue which may be used to wait on
46584651
this request completion */
46594652
init_waitqueue_head(&fsf_req->completion_wq);
46604653

46614654
ret = zfcp_fsf_req_sbal_get(adapter, req_flags, lock_flags);
4662-
if(ret < 0) {
4655+
if (ret < 0)
46634656
goto failed_sbals;
4664-
}
4657+
4658+
/* this is serialized (we are holding req_queue-lock of adapter) */
4659+
if (adapter->req_no == 0)
4660+
adapter->req_no++;
4661+
fsf_req->req_id = adapter->req_no++;
4662+
4663+
zfcp_fsf_req_qtcb_init(fsf_req);
46654664

46664665
/*
46674666
* We hold queue_lock here. Check if QDIOUP is set and let request fail

0 commit comments

Comments
 (0)