Commit d1e3ea0
committed
kvm: fix storage pool refcount race and false umount success
Two bugs in the storage pool teardown path.
adjustStoragePoolRefCount() means to lock on the single String instance
held as the map key, so that all callers share a monitor. When the entry
is absent, orElse(uuid) returns the caller's own instance instead and the
synchronized block guards nothing. The entry is absent exactly when the
count has just dropped to zero, which is the moment the lock is there to
protect. Increments are lost, the count reaches zero while the pool is
still in use, and the agent tries to unmount a pool that other VMs are
still using. On one host every one of the 22 teardowns in a day failed
with "device is busy". Use ConcurrentHashMap.compute(), which is atomic
for the key, and drop the lock.
deleteStoragePool() treats a null return from runSimpleBashScript() as a
successful umount, but null means either that the command failed or that
it succeeded and printed nothing on stdout. umount reports its errors on
stderr, so a failed umount is indistinguishable from a successful one and
is logged and returned as a success. Check the exit status instead.
Signed-off-by: Brad House <bhouse@nexthop.ai>1 parent 10037c8 commit d1e3ea0
2 files changed
Lines changed: 77 additions & 20 deletions
File tree
- plugins/hypervisors/kvm/src
- main/java/com/cloud/hypervisor/kvm/storage
- test/java/com/cloud/hypervisor/kvm/storage
Lines changed: 21 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
700 | 700 | | |
701 | 701 | | |
702 | 702 | | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
718 | 713 | | |
719 | 714 | | |
720 | 715 | | |
721 | 716 | | |
722 | 717 | | |
723 | | - | |
| 718 | + | |
724 | 719 | | |
725 | 720 | | |
726 | 721 | | |
727 | 722 | | |
728 | 723 | | |
729 | 724 | | |
730 | 725 | | |
731 | | - | |
| 726 | + | |
732 | 727 | | |
733 | 728 | | |
734 | 729 | | |
| |||
948 | 943 | | |
949 | 944 | | |
950 | 945 | | |
951 | | - | |
952 | | - | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
953 | 954 | | |
954 | 955 | | |
955 | 956 | | |
956 | 957 | | |
957 | | - | |
| 958 | + | |
958 | 959 | | |
959 | 960 | | |
960 | 961 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
| 37 | + | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
| |||
176 | 184 | | |
177 | 185 | | |
178 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
179 | 235 | | |
0 commit comments