OSDN Git Service

scsi: zfcp: Avoid benign overflow of the Request Queue's free-level
authorJulian Wiedmann <jwi@linux.ibm.com>
Fri, 3 Jul 2020 13:20:03 +0000 (15:20 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 8 Jul 2020 04:50:56 +0000 (00:50 -0400)
commitc3bfffa5ec6901f758160edfb046bdc56d89e8d2
treee2aaadb89761b255669bd3234b1d95f8d6e632b7
parent6bcb7c171a0ce0b0114aa088404e552b49d85576
scsi: zfcp: Avoid benign overflow of the Request Queue's free-level

zfcp_qdio_send() and zfcp_qdio_int_req() run concurrently, adding and
completing SBALs on the Request Queue. There's a theoretical race where
zfcp_qdio_int_req() completes a number of SBALs & increments the queue's
free-level _before_ zfcp_qdio_send() was able to decrement it.

This can cause ->req_q_free to momentarily hold a value larger than
QDIO_MAX_BUFFERS_PER_Q. Luckily zfcp_qdio_send() is always called under
->req_q_lock, and all readers of the free-level also take this lock. So we
can trust that zfcp_qdio_send() will clean up such a temporary overflow
before anyone can actually observe it.

But it's still confusing and annoying to worry about. So adjust the code to
avoid this race.

Link: https://lore.kernel.org/r/7f61f59a1f8db270312e64644f9173b8f1ac895f.1593780621.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/s390/scsi/zfcp_qdio.c