NVMf: fix staging buffer cache get race condition
authorJonas Pfefferle <pepperjo@apache.org>
Mon, 7 May 2018 07:16:22 +0000 (09:16 +0200)
committerJonas Pfefferle <pepperjo@apache.org>
Mon, 7 May 2018 07:18:54 +0000 (09:18 +0200)
Fixes NVMf staging buffer cache get. Do not throw an exception
if we can't free the previous buffer in the hashmap. If we can't
free it it was already freed by allocateFreeBuffers.

Signed-off-by: Jonas Pfefferle <pepperjo@apache.org>
storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfStagingBufferCache.java

index 09d6315..709dcff 100644 (file)
@@ -148,10 +148,9 @@ public class NvmfStagingBufferCache {
                if (prevEntry != null) {
                        if (prevEntry.tryFree()) {
                                freeBuffers.add(prevEntry.getBuffer());
-                       } else {
-                               /* we can't have two writes to the same location */
-                               throw new IllegalStateException();
-                       }
+                       } /*else {
+                               we lost the race with allocateFreeBuffers which freed the buffer
+                       }*/
                }
                return entry;
        }