summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-08-27 05:02:20 -0700
committerAnand Avati <avati@redhat.com>2013-09-03 16:09:09 -0700
commit6f85f6ce64c99e70d3b674e2e01657803ee3c082 (patch)
tree686a5bdbdfdfb49076609912e051f611071800c8 /xlators
parent53e98f11d1f3df30cc013af021464a257949a62d (diff)
afr: make NOP truncate/ftruncate efficient
If truncate/ftruncate is called with the offset as the current size of file, then skip the durability fsync and unwind quickly. Change-Id: I0baec68d96c6d4d8217d33bd9738f7ed0d1b40c5 BUG: 958118 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/5737 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr-inode-write.c14
-rw-r--r--xlators/cluster/afr/src/afr-transaction.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c
index 18ea323f176..a3090e4dbbe 100644
--- a/xlators/cluster/afr/src/afr-inode-write.c
+++ b/xlators/cluster/afr/src/afr-inode-write.c
@@ -607,6 +607,9 @@ afr_truncate_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if (op_ret != -1) {
+ if (prebuf->ia_size != postbuf->ia_size)
+ local->stable_write = _gf_false;
+
if (local->success_count == 0) {
local->op_ret = op_ret;
local->cont.truncate.prebuf = *prebuf;
@@ -627,6 +630,9 @@ afr_truncate_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
call_count = afr_frame_return (frame);
if (call_count == 0) {
+ if (local->stable_write && afr_txn_nothing_failed (frame, this))
+ local->transaction.unwind (frame, this);
+
local->transaction.resume (frame, this);
}
@@ -654,6 +660,7 @@ afr_truncate_wind (call_frame_t *frame, xlator_t *this)
}
local->call_count = call_count;
+ local->stable_write = _gf_true;
for (i = 0; i < priv->child_count; i++) {
if (local->transaction.pre_op[i]) {
@@ -808,6 +815,9 @@ afr_ftruncate_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if (op_ret != -1) {
+ if (prebuf->ia_size != postbuf->ia_size)
+ local->stable_write = _gf_false;
+
if (local->success_count == 0) {
local->op_ret = op_ret;
local->cont.ftruncate.prebuf = *prebuf;
@@ -828,6 +838,9 @@ afr_ftruncate_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
call_count = afr_frame_return (frame);
if (call_count == 0) {
+ if (local->stable_write && afr_txn_nothing_failed (frame, this))
+ local->transaction.unwind (frame, this);
+
local->transaction.resume (frame, this);
}
@@ -855,6 +868,7 @@ afr_ftruncate_wind (call_frame_t *frame, xlator_t *this)
}
local->call_count = call_count;
+ local->stable_write = _gf_true;
for (i = 0; i < priv->child_count; i++) {
if (local->transaction.pre_op[i]) {
diff --git a/xlators/cluster/afr/src/afr-transaction.h b/xlators/cluster/afr/src/afr-transaction.h
index 05d1c1a8d45..fa626fd0d6e 100644
--- a/xlators/cluster/afr/src/afr-transaction.h
+++ b/xlators/cluster/afr/src/afr-transaction.h
@@ -45,4 +45,7 @@ __mark_all_success (int32_t *pending[], int child_count,
afr_transaction_type type);
gf_boolean_t
afr_any_fops_failed (afr_local_t *local, afr_private_t *priv);
+
+gf_boolean_t
+afr_txn_nothing_failed (call_frame_t *frame, xlator_t *this);
#endif /* __TRANSACTION_H__ */