From b64a7f8497d9752f4da5a42aeeeebbd7727c442b Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 28 Jun 2013 16:03:52 +0530 Subject: cluster/afr: Provide an option to disable afr durability Change-Id: I40eec20ca6b3f857245a2438883822e251077ee9 BUG: 979365 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/5269 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- doc/admin-guide/en-US/admin_managing_volumes.xml | 6 ++++ .../en-US/markdown/admin_managing_volumes.md | 2 ++ tests/bugs/bug-979365.t | 42 ++++++++++++++++++++++ xlators/cluster/afr/src/afr-transaction.c | 14 ++++++-- xlators/cluster/afr/src/afr.c | 11 ++++++ xlators/cluster/afr/src/afr.h | 1 + xlators/mgmt/glusterd/src/glusterd-volume-set.c | 5 +++ 7 files changed, 78 insertions(+), 3 deletions(-) create mode 100755 tests/bugs/bug-979365.t diff --git a/doc/admin-guide/en-US/admin_managing_volumes.xml b/doc/admin-guide/en-US/admin_managing_volumes.xml index 0c4d2e922..70c1fe0b9 100644 --- a/doc/admin-guide/en-US/admin_managing_volumes.xml +++ b/doc/admin-guide/en-US/admin_managing_volumes.xml @@ -113,6 +113,12 @@ Set volume successful on On | Off + + cluster.ensure-durability + This option makes sure the data/metadata is durable across abrupt shutdown of the brick. + on + On | Off + diagnostics.brick-log-level Changes the log-level of the bricks. diff --git a/doc/admin-guide/en-US/markdown/admin_managing_volumes.md b/doc/admin-guide/en-US/markdown/admin_managing_volumes.md index 5c1b53479..6375bf525 100644 --- a/doc/admin-guide/en-US/markdown/admin_managing_volumes.md +++ b/doc/admin-guide/en-US/markdown/admin_managing_volumes.md @@ -73,6 +73,8 @@ To tune volume options cluster.self-heal-daemon Allows you to turn-off proactive self-heal on replicated volumes. on On | Off + cluster.ensure-durability This option makes sure the data/metadata is durable across abrupt shutdown of the brick. on On | Off + diagnostics.brick-log-level Changes the log-level of the bricks. INFO DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE diagnostics.client-log-level Changes the log-level of the clients. INFO DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE diff --git a/tests/bugs/bug-979365.t b/tests/bugs/bug-979365.t new file mode 100755 index 000000000..f5d9efd54 --- /dev/null +++ b/tests/bugs/bug-979365.t @@ -0,0 +1,42 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#This script checks that ensure-durability option enables/disables afr +#sending fsyncs +cleanup; + +function num_fsyncs { + $CLI volume profile $V0 info | grep -w FSYNC | wc -l +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 ensure-durability on +TEST $CLI volume set $V0 eager-lock off +TEST $CLI volume start $V0 +TEST $CLI volume profile $V0 start +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 +TEST kill_brick $V0 $H0 $B0/${V0}0 +TEST dd of=$M0/a if=/dev/zero bs=1M count=10 +#fsyncs take a while to complete. +sleep 5 +TEST [[ $(num_fsyncs) -ne 0 ]] +#Stop the volume to erase the profile info of old operations +TEST $CLI volume profile $V0 stop +TEST $CLI volume stop $V0 +umount $M0 +#Disable ensure-durability now to disable fsyncs in afr. +TEST $CLI volume set $V0 ensure-durability off +TEST $CLI volume start $V0 +TEST kill_brick $V0 $H0 $B0/${V0}0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 +TEST $CLI volume profile $V0 start +TEST dd of=$M0/a if=/dev/zero bs=1M count=10 +#fsyncs take a while to complete. +sleep 5 +TEST [[ $(num_fsyncs) -eq 0 ]] + +cleanup diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index dbc74ceba..d307d5b3e 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -1495,8 +1495,10 @@ int afr_changelog_post_op_safe (call_frame_t *frame, xlator_t *this) { afr_local_t *local = NULL; + afr_private_t *priv = NULL; local = frame->local; + priv = this->private; if (!local->fd || local->transaction.type != AFR_DATA_TRANSACTION) { afr_changelog_post_op_now (frame, this); @@ -1548,9 +1550,15 @@ afr_changelog_post_op_safe (call_frame_t *frame, xlator_t *this) return 0; } - /* Time to fsync() */ - - afr_changelog_fsync (frame, this); + /* Check whether users want durability and perform fsync/post-op + * accordingly. + */ + if (priv->ensure_durability) { + /* Time to fsync() */ + afr_changelog_fsync (frame, this); + } else { + afr_changelog_post_op_now (frame, this); + } return 0; } diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c index 6fabc0017..9a13fbdac 100644 --- a/xlators/cluster/afr/src/afr.c +++ b/xlators/cluster/afr/src/afr.c @@ -191,6 +191,8 @@ reconfigure (xlator_t *this, dict_t *options) /* Reset this so we re-discover in case the topology changed. */ GF_OPTION_RECONF ("readdir-failover", priv->readdir_failover, options, bool, out); + GF_OPTION_RECONF ("ensure-durability", priv->ensure_durability, options, + bool, out); priv->did_discovery = _gf_false; ret = 0; @@ -335,6 +337,8 @@ init (xlator_t *this) GF_OPTION_INIT ("post-op-delay-secs", priv->post_op_delay_secs, uint32, out); GF_OPTION_INIT ("readdir-failover", priv->readdir_failover, bool, out); + GF_OPTION_INIT ("ensure-durability", priv->ensure_durability, bool, + out); priv->wait_count = 1; @@ -767,5 +771,12 @@ struct volume_options options[] = { .description = "readdir(p) will not failover if this option is off", .default_value = "on", }, + { .key = {"ensure-durability"}, + .type = GF_OPTION_TYPE_BOOL, + .description = "Afr performs fsyncs for transactions if this " + "option is on to make sure the changelogs/data is " + "written to the disk", + .default_value = "on", + }, { .key = {NULL} }, }; diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index 836a64d0a..e72398a62 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -170,6 +170,7 @@ typedef struct _afr_private { gf_boolean_t did_discovery; gf_boolean_t readdir_failover; uint64_t sh_readdir_size; + gf_boolean_t ensure_durability; } afr_private_t; typedef enum { diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 6c4af6e3e..f57f49f42 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -524,6 +524,11 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = 2, .flags = OPT_FLAG_CLIENT_OPT }, + { .key = "cluster.ensure-durability", + .voltype = "cluster/replicate", + .op_version = 2, + .flags = OPT_FLAG_CLIENT_OPT + }, /* Stripe xlator options */ { .key = "cluster.stripe-block-size", -- cgit