summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/iobuf.c4
-rw-r--r--tests/basic/write-behind.t53
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c12
-rw-r--r--xlators/performance/write-behind/src/write-behind.c14
4 files changed, 77 insertions, 6 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index 17cd68fc206..fa3ac840c43 100644
--- a/libglusterfs/src/iobuf.c
+++ b/libglusterfs/src/iobuf.c
@@ -30,8 +30,8 @@ struct iobuf_init_config gf_iobuf_init_config[] = {
{8 * 1024, 128},
{32 * 1024, 64},
{128 * 1024, 32},
- {256 * 1024, 8},
- {1 * 1024 * 1024, 2},
+ {256 * 1024, 64},
+ {1 * 1024 * 1024, 64},
};
int
diff --git a/tests/basic/write-behind.t b/tests/basic/write-behind.t
new file mode 100644
index 00000000000..edad59786af
--- /dev/null
+++ b/tests/basic/write-behind.t
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+
+function clear_stats {
+ > /var/lib/glusterfs/stats/glusterfs_d_backends_${V0}0.dump
+}
+
+function got_expected_write_count {
+ expected_size=$1
+ expected_value=$2
+ grep aggr.write_${expected_size} "/var/lib/glusterd/stats/glusterfsd__d_backends_${V0}0.dump" | grep $expected_value
+ if [ $? == 0 ]; then
+ echo "Y";
+ else
+ echo "N";
+ fi
+}
+
+cleanup;
+
+TEST glusterd
+TEST pidof glusterd
+
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
+
+# These are needed for our tracking of write sizes
+TEST $CLI volume set $V0 diagnostics.latency-measurement on
+TEST $CLI volume set $V0 diagnostics.count-fop-hits on
+TEST $CLI volume set $V0 diagnostics.stats-dump-interval 2
+
+# Disable this in testing to get deterministic results
+TEST $CLI volume set $V0 performance.write-behind-trickling-writes off
+
+TEST $CLI volume start $V0
+
+sleep 2;
+
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
+
+# Write a 100MB file with a window-size 1MB, we should get 100 writes of 1MB each
+TEST dd if=/dev/zero of=$M0/100mb_file bs=1M count=100
+EXPECT_WITHIN 5 "Y" got_expected_write_count "1mb" 100
+
+TEST $CLI volume set $V0 performance.write-behind-window-size 512KB
+
+# Write a 100MB file with a window-size 512KB, we should get 200 writes of 512KB each
+TEST dd if=/dev/zero of=$M0/100mb_file_2 bs=1M count=100
+EXPECT_WITHIN 5 "Y" got_expected_write_count "512kb" 200
+
+cleanup;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index ac484e246b1..e82339a537f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -1560,6 +1560,18 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.op_version = 2,
.flags = OPT_FLAG_CLIENT_OPT
},
+ { .key = "performance.write-behind-trickling-writes",
+ .voltype = "performance/write-behind",
+ .option = "trickling-writes",
+ .op_version = 2,
+ .flags = OPT_FLAG_CLIENT_OPT
+ },
+ { .key = "performance.nfs.write-behind-trickling-writes",
+ .voltype = "performance/write-behind",
+ .option = "trickling-writes",
+ .op_version = 2,
+ .flags = OPT_FLAG_CLIENT_OPT
+ },
{ .key = "performance.lazy-open",
.voltype = "performance/open-behind",
.option = "lazy-open",
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 7f5719b1e48..bc59036ff88 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -169,6 +169,7 @@ typedef struct wb_request {
typedef struct wb_conf {
uint64_t aggregate_size;
+ uint64_t page_size;
uint64_t window_size;
gf_boolean_t flush_behind;
gf_boolean_t trickling_writes;
@@ -1207,18 +1208,21 @@ __wb_collapse_small_writes (wb_request_t *holder, wb_request_t *req)
char *ptr = NULL;
struct iobuf *iobuf = NULL;
struct iobref *iobref = NULL;
+ struct wb_conf *conf = NULL;
int ret = -1;
ssize_t required_size = 0;
size_t holder_len = 0;
size_t req_len = 0;
+ conf = req->wb_inode->this->private;
+
if (!holder->iobref) {
holder_len = iov_length (holder->stub->args.vector,
holder->stub->args.count);
req_len = iov_length (req->stub->args.vector,
req->stub->args.count);
- required_size = max ((THIS->ctx->page_size),
+ required_size = max ((conf->page_size),
(holder_len + req_len));
iobuf = iobuf_get2 (req->wb_inode->this->ctx->iobuf_pool,
required_size);
@@ -1281,7 +1285,6 @@ __wb_preprocess_winds (wb_inode_t *wb_inode)
wb_request_t *holder = NULL;
wb_conf_t *conf = NULL;
int ret = 0;
- ssize_t page_size = 0;
/* With asynchronous IO from a VM guest (as a file), there
can be two sequential writes happening in two regions
@@ -1292,7 +1295,6 @@ __wb_preprocess_winds (wb_inode_t *wb_inode)
through the interleaved ops
*/
- page_size = wb_inode->this->ctx->page_size;
conf = wb_inode->this->private;
list_for_each_entry_safe (req, tmp, &wb_inode->todo, todo) {
@@ -1343,7 +1345,7 @@ __wb_preprocess_winds (wb_inode_t *wb_inode)
continue;
}
- space_left = page_size - holder->write_size;
+ space_left = wb_inode->window_conf - holder->write_size;
if (space_left < req->write_size) {
holder->ordering.go = 1;
@@ -2471,6 +2473,9 @@ reconfigure (xlator_t *this, dict_t *options)
GF_OPTION_RECONF ("cache-size", conf->window_size, options, size_uint64,
out);
+ GF_OPTION_RECONF ("cache-size", conf->page_size, options, size_uint64,
+ out);
+
GF_OPTION_RECONF ("flush-behind", conf->flush_behind, options, bool,
out);
@@ -2522,6 +2527,7 @@ init (xlator_t *this)
/* configure 'option window-size <size>' */
GF_OPTION_INIT ("cache-size", conf->window_size, size_uint64, out);
+ GF_OPTION_INIT ("cache-size", conf->page_size, size_uint64, out);
if (!conf->window_size && conf->aggregate_size) {
gf_msg (this->name, GF_LOG_WARNING, 0,