summaryrefslogtreecommitdiffstats
path: root/src/kiro-client.c
diff options
context:
space:
mode:
authorTimo Dritschler <timo.dritschler@kit.edu>2015-02-04 18:40:08 +0100
committerTimo Dritschler <timo.dritschler@kit.edu>2015-02-06 17:25:38 +0100
commit1cfe34fc3b0cd194d6a87cbfa8f7328066acda83 (patch)
tree6767f947235208896b705eef5541fde4ce8ed968 /src/kiro-client.c
parent6a4bf7ed05428a9479a19b69c80814139b4fd121 (diff)
downloadkiro-1cfe34fc3b0cd194d6a87cbfa8f7328066acda83.tar.gz
kiro-1cfe34fc3b0cd194d6a87cbfa8f7328066acda83.tar.bz2
kiro-1cfe34fc3b0cd194d6a87cbfa8f7328066acda83.tar.xz
kiro-1cfe34fc3b0cd194d6a87cbfa8f7328066acda83.zip
Added new kiro_client_sync_partial interface
Diffstat (limited to 'src/kiro-client.c')
-rw-r--r--src/kiro-client.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/kiro-client.c b/src/kiro-client.c
index 92fd6b1..b9c33c5 100644
--- a/src/kiro-client.c
+++ b/src/kiro-client.c
@@ -424,7 +424,7 @@ fail:
int
-kiro_client_sync (KiroClient *self)
+kiro_client_sync_partial (KiroClient *self, gulong remote_offset, gulong size, gulong local_offset)
{
g_return_val_if_fail (self != NULL, -1);
KiroClientPrivate *priv = KIRO_CLIENT_GET_PRIVATE (self);
@@ -436,8 +436,29 @@ kiro_client_sync (KiroClient *self)
struct kiro_connection_context *ctx = (struct kiro_connection_context *)priv->conn->context;
+ if (remote_offset > ctx->peer_mr.length) {
+ g_warning ("kiro_client_sync_partial: remote_offset too large! Won't sync.");
+ return -1;
+ }
+
+ gulong read_size = ctx->peer_mr.length;
+ if (size > 0)
+ read_size = size;
+ else if (remote_offset > 0)
+ read_size -= remote_offset; //read to the end of the memory, starting at offset
+
+ if ((remote_offset + read_size) > ctx->peer_mr.length) {
+ g_warning ("kiro_client_sync_partial: remote_offset + read_size would exceed remote memory boundary! Won't sync.");
+ return -1;
+ }
+
+ if ((local_offset + read_size) > ctx->rdma_mr->size) {
+ g_warning ("kiro_client_sync_partial: local_offset + read_size would exceed local memory boundary! Won't sync.");
+ return -1;
+ }
+
G_LOCK (sync_lock);
- if (rdma_post_read (priv->conn, priv->conn, ctx->rdma_mr->mem, ctx->peer_mr.length, ctx->rdma_mr->mr, 0, (uint64_t)ctx->peer_mr.addr, ctx->peer_mr.rkey)) {
+ if (rdma_post_read (priv->conn, priv->conn, ctx->rdma_mr->mem + local_offset, read_size, ctx->rdma_mr->mr, 0, (uint64_t)ctx->peer_mr.addr + remote_offset, ctx->peer_mr.rkey)) {
g_critical ("Failed to RDMA_READ from server: %s", strerror (errno));
goto fail;
}
@@ -470,6 +491,13 @@ fail:
}
+int
+kiro_client_sync (KiroClient *self)
+{
+ return kiro_client_sync_partial (self, 0, 0, 0);
+}
+
+
gboolean
ping_timeout (gpointer data) {