Commit a264cf5
scsi: ibmvfc: Fix command state accounting and stale response detection
Prior to commit 1f4a4a1 ("scsi: ibmvfc: Complete commands outside the
host/queue lock") responses to commands were completed sequentially with
the host lock held such that a command had a basic binary state of active
or free. It was therefore a simple affair of ensuring the assocaiated
ibmvfc_event to a VIOS response was valid by testing that it was not
already free. The lock relexation work to complete commands outside the
lock inadverdently made it a trinary command state such that a command is
either in flight, received and being completed, or completed and now
free. This breaks the stale command detection logic as a command may be
still marked active and been placed on the delayed completion list when a
second stale response for the same command arrives. This can lead to double
completions and list corruption. This issue was exposed by a recent VIOS
regression were a missing memory barrier could occasionally result in the
ibmvfc client receiving a duplicate response for the same command.
Fix the issue by introducing the atomic ibmvfc_event.active to track the
trinary state of a command. The state is explicitly set to 1 when a command
is successfully sent. The CRQ response handlers use
atomic_dec_if_positive() to test for stale responses and correctly
transition to the completion state when a active command is received.
Finally, atomic_dec_and_test() is used to sanity check transistions when
commands are freed as a result of a completion, or moved to the purge list
as a result of error handling or adapter reset.
Link: https://lore.kernel.org/r/20210716205220.1101150-1-tyreld@linux.ibm.com
Fixes: 1f4a4a1 ("scsi: ibmvfc: Complete commands outside the host/queue lock")
Cc: stable@vger.kernel.org
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>1 parent 70edd2e commit a264cf5
2 files changed
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
810 | 817 | | |
811 | 818 | | |
812 | 819 | | |
| |||
1017 | 1024 | | |
1018 | 1025 | | |
1019 | 1026 | | |
| 1027 | + | |
1020 | 1028 | | |
1021 | 1029 | | |
1022 | 1030 | | |
| |||
1072 | 1080 | | |
1073 | 1081 | | |
1074 | 1082 | | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1075 | 1089 | | |
1076 | 1090 | | |
1077 | 1091 | | |
| |||
1723 | 1737 | | |
1724 | 1738 | | |
1725 | 1739 | | |
| 1740 | + | |
1726 | 1741 | | |
1727 | 1742 | | |
1728 | 1743 | | |
| |||
3251 | 3266 | | |
3252 | 3267 | | |
3253 | 3268 | | |
3254 | | - | |
| 3269 | + | |
3255 | 3270 | | |
3256 | 3271 | | |
3257 | 3272 | | |
| |||
3778 | 3793 | | |
3779 | 3794 | | |
3780 | 3795 | | |
3781 | | - | |
| 3796 | + | |
3782 | 3797 | | |
3783 | 3798 | | |
3784 | 3799 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
| 748 | + | |
748 | 749 | | |
749 | 750 | | |
750 | 751 | | |
| |||
0 commit comments