Commit 665e022
scsi: ibmvscsi: Fix potential race after loss of transport
After a loss of transport due to an adapter migration or crash/disconnect
from the host partner there is a tiny window where we can race adjusting
the request_limit of the adapter. The request limit is atomically
increased/decreased to track the number of inflight requests against the
allowed limit of our VIOS partner.
After a transport loss we set the request_limit to zero to reflect this
state. However, there is a window where the adapter may attempt to queue a
command because the transport loss event hasn't been fully processed yet
and request_limit is still greater than zero. The hypercall to send the
event will fail and the error path will increment the request_limit as a
result. If the adapter processes the transport event prior to this
increment the request_limit becomes out of sync with the adapter state and
can result in SCSI commands being submitted on the now reset connection
prior to an SRP Login resulting in a protocol violation.
Fix this race by protecting request_limit with the host lock when changing
the value via atomic_set() to indicate no transport.
Link: https://lore.kernel.org/r/20201025001355.4527-1-tyreld@linux.ibm.com
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>1 parent 2f4843b commit 665e022
1 file changed
Lines changed: 26 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
809 | 825 | | |
810 | 826 | | |
811 | 827 | | |
812 | 828 | | |
813 | 829 | | |
814 | 830 | | |
815 | 831 | | |
816 | | - | |
| 832 | + | |
817 | 833 | | |
818 | 834 | | |
819 | 835 | | |
| |||
1146 | 1162 | | |
1147 | 1163 | | |
1148 | 1164 | | |
1149 | | - | |
| 1165 | + | |
1150 | 1166 | | |
1151 | 1167 | | |
1152 | 1168 | | |
1153 | 1169 | | |
1154 | 1170 | | |
1155 | | - | |
| 1171 | + | |
1156 | 1172 | | |
1157 | 1173 | | |
1158 | 1174 | | |
| |||
1163 | 1179 | | |
1164 | 1180 | | |
1165 | 1181 | | |
1166 | | - | |
| 1182 | + | |
1167 | 1183 | | |
1168 | 1184 | | |
1169 | 1185 | | |
| |||
1195 | 1211 | | |
1196 | 1212 | | |
1197 | 1213 | | |
1198 | | - | |
1199 | 1214 | | |
1200 | 1215 | | |
1201 | 1216 | | |
1202 | 1217 | | |
1203 | | - | |
| 1218 | + | |
1204 | 1219 | | |
| 1220 | + | |
1205 | 1221 | | |
1206 | 1222 | | |
1207 | 1223 | | |
| |||
1781 | 1797 | | |
1782 | 1798 | | |
1783 | 1799 | | |
1784 | | - | |
| 1800 | + | |
1785 | 1801 | | |
1786 | 1802 | | |
1787 | 1803 | | |
| |||
2137 | 2153 | | |
2138 | 2154 | | |
2139 | 2155 | | |
| 2156 | + | |
2140 | 2157 | | |
2141 | 2158 | | |
2142 | | - | |
| 2159 | + | |
2143 | 2160 | | |
2144 | 2161 | | |
2145 | | - | |
2146 | 2162 | | |
2147 | 2163 | | |
2148 | 2164 | | |
| |||
2226 | 2242 | | |
2227 | 2243 | | |
2228 | 2244 | | |
2229 | | - | |
| 2245 | + | |
2230 | 2246 | | |
2231 | 2247 | | |
2232 | 2248 | | |
| |||
0 commit comments