Repository: incubator-crail
Updated Branches:
  refs/heads/master 749f44206 -> bd1e23e0f


NVMf: staging buffer cache existing entry bug

A buffer might already exist at a certain remote address (resp. LBA) if
a file was deleted and a block was reassigned to a different file. Do not
throw an exception but free the buffer. If we can't free it something
went wrong as there should never be two writers writing to the same
remote address.

https://issues.apache.org/jira/projects/CRAIL/issues/CRAIL-30

Signed-off-by: Jonas Pfefferle <peppe...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-crail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-crail/commit/671b6355
Tree: http://git-wip-us.apache.org/repos/asf/incubator-crail/tree/671b6355
Diff: http://git-wip-us.apache.org/repos/asf/incubator-crail/diff/671b6355

Branch: refs/heads/master
Commit: 671b63554658925e78d1a8c8a11c706ffee8924d
Parents: 749f442
Author: Jonas Pfefferle <peppe...@apache.org>
Authored: Wed May 2 12:53:47 2018 +0200
Committer: Jonas Pfefferle <peppe...@apache.org>
Committed: Thu May 3 13:50:16 2018 +0200

----------------------------------------------------------------------
 .../crail/storage/nvmf/client/NvmfStagingBufferCache.java     | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-crail/blob/671b6355/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfStagingBufferCache.java
----------------------------------------------------------------------
diff --git 
a/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfStagingBufferCache.java
 
b/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfStagingBufferCache.java
index e29c284..64a8857 100644
--- 
a/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfStagingBufferCache.java
+++ 
b/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfStagingBufferCache.java
@@ -145,7 +145,12 @@ public class NvmfStagingBufferCache {
                BufferCacheEntry entry = new BufferCacheEntry(buffer);
                BufferCacheEntry prevEntry = 
remoteAddressMap.putIfAbsent(alignedRemoteAddress, entry);
                if (prevEntry != null) {
-                       throw new IllegalStateException();
+                       if (prevEntry.tryFree()) {
+                               freeBuffers.add(prevEntry.getBuffer());
+                       } else {
+                               /* we can't have two writes to the same 
location */
+                               throw new IllegalStateException();
+                       }
                }
                return entry;
        }

Reply via email to