You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@crail.apache.org by pe...@apache.org on 2018/04/10 11:19:49 UTC

[10/16] incubator-crail git commit: NvmfUnalignedWriteFuture: refactoring

NvmfUnalignedWriteFuture: refactoring

Use offsetInSector in floorToSector and provide a new
floorToSector overload method for ints.

Signed-off-by: Jonas Pfefferle <pe...@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/89820d9a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-crail/tree/89820d9a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-crail/diff/89820d9a

Branch: refs/heads/master
Commit: 89820d9a379f40890f27f0f0054990cb955f1e13
Parents: 4a303c8
Author: Jonas Pfefferle <pe...@apache.org>
Authored: Tue Apr 10 11:08:50 2018 +0200
Committer: Jonas Pfefferle <pe...@apache.org>
Committed: Tue Apr 10 13:19:03 2018 +0200

----------------------------------------------------------------------
 .../crail/storage/nvmf/client/NvmfUnalignedWriteFuture.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-crail/blob/89820d9a/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfUnalignedWriteFuture.java
----------------------------------------------------------------------
diff --git a/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfUnalignedWriteFuture.java b/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfUnalignedWriteFuture.java
index 08eab5b..d4b16b2 100644
--- a/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfUnalignedWriteFuture.java
+++ b/storage-nvmf/src/main/java/org/apache/crail/storage/nvmf/client/NvmfUnalignedWriteFuture.java
@@ -43,7 +43,11 @@ public class NvmfUnalignedWriteFuture implements StorageFuture {
 	}
 
 	private final long floorToSectorSize(long address) {
-		return address - (address % endpoint.getLBADataSize());
+		return address - offsetInSector(address);
+	}
+
+	private final int floorToSectorSize(int length) {
+		return length - offsetInSector(length);
 	}
 
 	private final int leftInSector(long address) {
@@ -91,7 +95,7 @@ public class NvmfUnalignedWriteFuture implements StorageFuture {
 		/* middle */
 		if (isSectorAligned(nextRemoteOffset) && buffer.remaining() >= endpoint.getLBADataSize()) {
 			int oldLimit = buffer.limit();
-			buffer.limit(buffer.position() + (int)floorToSectorSize(buffer.remaining()));
+			buffer.limit(buffer.position() + floorToSectorSize(buffer.remaining()));
 			int toWrite = buffer.remaining();
 			middleFuture = endpoint.write(buffer, blockInfo, nextRemoteOffset);
 			nextRemoteOffset += toWrite;