|
|
2072c5 |
From 399fad1ac0f9273483270e8af06a5b2d28927533 Mon Sep 17 00:00:00 2001
|
|
|
2072c5 |
From: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
2072c5 |
Date: Fri, 29 May 2020 14:24:53 +0530
|
|
|
2072c5 |
Subject: [PATCH 387/392] cluster/afr: Delay post-op for fsync
|
|
|
2072c5 |
|
|
|
2072c5 |
Problem:
|
|
|
2072c5 |
AFR doesn't delay post-op for fsync fop. For fsync heavy workloads
|
|
|
2072c5 |
this leads to un-necessary fxattrop/finodelk for every fsync leading
|
|
|
2072c5 |
to bad performance.
|
|
|
2072c5 |
|
|
|
2072c5 |
Fix:
|
|
|
2072c5 |
Have delayed post-op for fsync. Add special flag in xdata to indicate
|
|
|
2072c5 |
that afr shouldn't delay post-op in cases where either the
|
|
|
2072c5 |
process will terminate or graph-switch would happen. Otherwise it leads
|
|
|
2072c5 |
to un-necessary heals when the graph-switch/process-termination
|
|
|
2072c5 |
happens before delayed-post-op completes.
|
|
|
2072c5 |
|
|
|
2072c5 |
> Upstream-patch: https://review.gluster.org/c/glusterfs/+/24473
|
|
|
2072c5 |
> Fixes: #1253
|
|
|
2072c5 |
|
|
|
2072c5 |
BUG: 1848896
|
|
|
2072c5 |
Change-Id: I531940d13269a111c49e0510d49514dc169f4577
|
|
|
2072c5 |
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
2072c5 |
(cherry picked from commit 3ed98fc9dcb39223032e343fd5b0ad17fa3cae14)
|
|
|
2072c5 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/203694
|
|
|
2072c5 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
2072c5 |
Tested-by: Karthik Subrahmanya <ksubrahm@redhat.com>
|
|
|
2072c5 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
2072c5 |
---
|
|
|
2072c5 |
api/src/glfs-resolve.c | 14 ++-
|
|
|
2072c5 |
tests/basic/afr/durability-off.t | 2 +
|
|
|
2072c5 |
tests/basic/gfapi/gfapi-graph-switch-open-fd.t | 44 +++++++++
|
|
|
2072c5 |
tests/basic/gfapi/gfapi-keep-writing.c | 129 +++++++++++++++++++++++++
|
|
|
2072c5 |
xlators/cluster/afr/src/afr-inode-write.c | 11 ++-
|
|
|
2072c5 |
xlators/cluster/afr/src/afr-transaction.c | 9 +-
|
|
|
2072c5 |
xlators/cluster/afr/src/afr.h | 2 +-
|
|
|
2072c5 |
xlators/cluster/dht/src/dht-rebalance.c | 15 ++-
|
|
|
2072c5 |
xlators/mount/fuse/src/fuse-bridge.c | 23 ++++-
|
|
|
2072c5 |
9 files changed, 239 insertions(+), 10 deletions(-)
|
|
|
2072c5 |
create mode 100644 tests/basic/gfapi/gfapi-graph-switch-open-fd.t
|
|
|
2072c5 |
create mode 100644 tests/basic/gfapi/gfapi-keep-writing.c
|
|
|
2072c5 |
|
|
|
2072c5 |
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
|
|
|
2072c5 |
index a79f490..062b7dc 100644
|
|
|
2072c5 |
--- a/api/src/glfs-resolve.c
|
|
|
2072c5 |
+++ b/api/src/glfs-resolve.c
|
|
|
2072c5 |
@@ -722,6 +722,7 @@ glfs_migrate_fd_safe(struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
|
|
|
2072c5 |
0,
|
|
|
2072c5 |
};
|
|
|
2072c5 |
char uuid1[64];
|
|
|
2072c5 |
+ dict_t *xdata = NULL;
|
|
|
2072c5 |
|
|
|
2072c5 |
oldinode = oldfd->inode;
|
|
|
2072c5 |
oldsubvol = oldinode->table->xl;
|
|
|
2072c5 |
@@ -730,7 +731,15 @@ glfs_migrate_fd_safe(struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
|
|
|
2072c5 |
return fd_ref(oldfd);
|
|
|
2072c5 |
|
|
|
2072c5 |
if (!oldsubvol->switched) {
|
|
|
2072c5 |
- ret = syncop_fsync(oldsubvol, oldfd, 0, NULL, NULL, NULL, NULL);
|
|
|
2072c5 |
+ xdata = dict_new();
|
|
|
2072c5 |
+ if (!xdata || dict_set_int8(xdata, "last-fsync", 1)) {
|
|
|
2072c5 |
+ gf_msg(fs->volname, GF_LOG_WARNING, ENOMEM, API_MSG_FSYNC_FAILED,
|
|
|
2072c5 |
+ "last-fsync set failed on %s graph %s (%d)",
|
|
|
2072c5 |
+ uuid_utoa_r(oldfd->inode->gfid, uuid1),
|
|
|
2072c5 |
+ graphid_str(oldsubvol), oldsubvol->graph->id);
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = syncop_fsync(oldsubvol, oldfd, 0, NULL, NULL, xdata, NULL);
|
|
|
2072c5 |
DECODE_SYNCOP_ERR(ret);
|
|
|
2072c5 |
if (ret) {
|
|
|
2072c5 |
gf_msg(fs->volname, GF_LOG_WARNING, errno, API_MSG_FSYNC_FAILED,
|
|
|
2072c5 |
@@ -809,6 +818,9 @@ out:
|
|
|
2072c5 |
newfd = NULL;
|
|
|
2072c5 |
}
|
|
|
2072c5 |
|
|
|
2072c5 |
+ if (xdata)
|
|
|
2072c5 |
+ dict_unref(xdata);
|
|
|
2072c5 |
+
|
|
|
2072c5 |
return newfd;
|
|
|
2072c5 |
}
|
|
|
2072c5 |
|
|
|
2072c5 |
diff --git a/tests/basic/afr/durability-off.t b/tests/basic/afr/durability-off.t
|
|
|
2072c5 |
index 155ffa0..6e0f18b 100644
|
|
|
2072c5 |
--- a/tests/basic/afr/durability-off.t
|
|
|
2072c5 |
+++ b/tests/basic/afr/durability-off.t
|
|
|
2072c5 |
@@ -26,6 +26,8 @@ TEST $CLI volume heal $V0
|
|
|
2072c5 |
EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0
|
|
|
2072c5 |
EXPECT "^0$" echo $($CLI volume profile $V0 info | grep -w FSYNC | wc -l)
|
|
|
2072c5 |
|
|
|
2072c5 |
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0
|
|
|
2072c5 |
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
|
|
|
2072c5 |
#Test that fsyncs happen when durability is on
|
|
|
2072c5 |
TEST $CLI volume set $V0 cluster.ensure-durability on
|
|
|
2072c5 |
TEST $CLI volume set $V0 performance.strict-write-ordering on
|
|
|
2072c5 |
diff --git a/tests/basic/gfapi/gfapi-graph-switch-open-fd.t b/tests/basic/gfapi/gfapi-graph-switch-open-fd.t
|
|
|
2072c5 |
new file mode 100644
|
|
|
2072c5 |
index 0000000..2e666be
|
|
|
2072c5 |
--- /dev/null
|
|
|
2072c5 |
+++ b/tests/basic/gfapi/gfapi-graph-switch-open-fd.t
|
|
|
2072c5 |
@@ -0,0 +1,44 @@
|
|
|
2072c5 |
+#!/bin/bash
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+. $(dirname $0)/../../include.rc
|
|
|
2072c5 |
+. $(dirname $0)/../../volume.rc
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+cleanup;
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+TEST glusterd
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+TEST $CLI volume create $V0 replica 3 ${H0}:$B0/brick{0..2};
|
|
|
2072c5 |
+EXPECT 'Created' volinfo_field $V0 'Status';
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+TEST $CLI volume start $V0;
|
|
|
2072c5 |
+EXPECT 'Started' volinfo_field $V0 'Status';
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0;
|
|
|
2072c5 |
+TEST touch $M0/sync
|
|
|
2072c5 |
+logdir=`gluster --print-logdir`
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+TEST build_tester $(dirname $0)/gfapi-keep-writing.c -lgfapi
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+#Launch a program to keep doing writes on an fd
|
|
|
2072c5 |
+./$(dirname $0)/gfapi-keep-writing ${H0} $V0 $logdir/gfapi-async-calls-test.log sync &
|
|
|
2072c5 |
+p=$!
|
|
|
2072c5 |
+sleep 1 #Let some writes go through
|
|
|
2072c5 |
+#Check if graph switch will lead to any pending markers for ever
|
|
|
2072c5 |
+TEST $CLI volume set $V0 performance.quick-read off
|
|
|
2072c5 |
+TEST $CLI volume set $V0 performance.io-cache off
|
|
|
2072c5 |
+TEST $CLI volume set $V0 performance.stat-prefetch off
|
|
|
2072c5 |
+TEST $CLI volume set $V0 performance.read-ahead off
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+TEST rm -f $M0/sync #Make sure the glfd is closed
|
|
|
2072c5 |
+TEST wait #Wait for background process to die
|
|
|
2072c5 |
+#Goal is to check if there is permanent FOOL changelog
|
|
|
2072c5 |
+sleep 5
|
|
|
2072c5 |
+EXPECT "0x000000000000000000000000" afr_get_changelog_xattr $B0/brick0/glfs_test.txt trusted.afr.dirty
|
|
|
2072c5 |
+EXPECT "0x000000000000000000000000" afr_get_changelog_xattr $B0/brick1/glfs_test.txt trusted.afr.dirty
|
|
|
2072c5 |
+EXPECT "0x000000000000000000000000" afr_get_changelog_xattr $B0/brick2/glfs_test.txt trusted.afr.dirty
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+cleanup_tester $(dirname $0)/gfapi-async-calls-test
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+cleanup;
|
|
|
2072c5 |
diff --git a/tests/basic/gfapi/gfapi-keep-writing.c b/tests/basic/gfapi/gfapi-keep-writing.c
|
|
|
2072c5 |
new file mode 100644
|
|
|
2072c5 |
index 0000000..91b59ce
|
|
|
2072c5 |
--- /dev/null
|
|
|
2072c5 |
+++ b/tests/basic/gfapi/gfapi-keep-writing.c
|
|
|
2072c5 |
@@ -0,0 +1,129 @@
|
|
|
2072c5 |
+#include <fcntl.h>
|
|
|
2072c5 |
+#include <unistd.h>
|
|
|
2072c5 |
+#include <time.h>
|
|
|
2072c5 |
+#include <limits.h>
|
|
|
2072c5 |
+#include <string.h>
|
|
|
2072c5 |
+#include <stdio.h>
|
|
|
2072c5 |
+#include <stdlib.h>
|
|
|
2072c5 |
+#include <errno.h>
|
|
|
2072c5 |
+#include <glusterfs/api/glfs.h>
|
|
|
2072c5 |
+#include <glusterfs/api/glfs-handles.h>
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+#define LOG_ERR(msg) \
|
|
|
2072c5 |
+ do { \
|
|
|
2072c5 |
+ fprintf(stderr, "%s : Error (%s)\n", msg, strerror(errno)); \
|
|
|
2072c5 |
+ } while (0)
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+glfs_t *
|
|
|
2072c5 |
+init_glfs(const char *hostname, const char *volname, const char *logfile)
|
|
|
2072c5 |
+{
|
|
|
2072c5 |
+ int ret = -1;
|
|
|
2072c5 |
+ glfs_t *fs = NULL;
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ fs = glfs_new(volname);
|
|
|
2072c5 |
+ if (!fs) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_new failed");
|
|
|
2072c5 |
+ return NULL;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = glfs_set_volfile_server(fs, "tcp", hostname, 24007);
|
|
|
2072c5 |
+ if (ret < 0) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_set_volfile_server failed");
|
|
|
2072c5 |
+ goto out;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = glfs_set_logging(fs, logfile, 7);
|
|
|
2072c5 |
+ if (ret < 0) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_set_logging failed");
|
|
|
2072c5 |
+ goto out;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = glfs_init(fs);
|
|
|
2072c5 |
+ if (ret < 0) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_init failed");
|
|
|
2072c5 |
+ goto out;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = 0;
|
|
|
2072c5 |
+out:
|
|
|
2072c5 |
+ if (ret) {
|
|
|
2072c5 |
+ glfs_fini(fs);
|
|
|
2072c5 |
+ fs = NULL;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ return fs;
|
|
|
2072c5 |
+}
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+int
|
|
|
2072c5 |
+glfs_test_function(const char *hostname, const char *volname,
|
|
|
2072c5 |
+ const char *logfile, const char *syncfile)
|
|
|
2072c5 |
+{
|
|
|
2072c5 |
+ int ret = -1;
|
|
|
2072c5 |
+ int flags = O_CREAT | O_RDWR;
|
|
|
2072c5 |
+ glfs_t *fs = NULL;
|
|
|
2072c5 |
+ glfs_fd_t *glfd = NULL;
|
|
|
2072c5 |
+ const char *buff = "This is from my prog\n";
|
|
|
2072c5 |
+ const char *filename = "glfs_test.txt";
|
|
|
2072c5 |
+ struct stat buf = {0};
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ fs = init_glfs(hostname, volname, logfile);
|
|
|
2072c5 |
+ if (fs == NULL) {
|
|
|
2072c5 |
+ LOG_ERR("init_glfs failed");
|
|
|
2072c5 |
+ return -1;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ glfd = glfs_creat(fs, filename, flags, 0644);
|
|
|
2072c5 |
+ if (glfd == NULL) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_creat failed");
|
|
|
2072c5 |
+ goto out;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ while (glfs_stat(fs, syncfile, &buf) == 0) {
|
|
|
2072c5 |
+ ret = glfs_write(glfd, buff, strlen(buff), flags);
|
|
|
2072c5 |
+ if (ret < 0) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_write failed");
|
|
|
2072c5 |
+ goto out;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = glfs_close(glfd);
|
|
|
2072c5 |
+ if (ret < 0) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_write failed");
|
|
|
2072c5 |
+ goto out;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+out:
|
|
|
2072c5 |
+ ret = glfs_fini(fs);
|
|
|
2072c5 |
+ if (ret) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_fini failed");
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ return ret;
|
|
|
2072c5 |
+}
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+int
|
|
|
2072c5 |
+main(int argc, char *argv[])
|
|
|
2072c5 |
+{
|
|
|
2072c5 |
+ int ret = 0;
|
|
|
2072c5 |
+ char *hostname = NULL;
|
|
|
2072c5 |
+ char *volname = NULL;
|
|
|
2072c5 |
+ char *logfile = NULL;
|
|
|
2072c5 |
+ char *syncfile = NULL;
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ if (argc != 5) {
|
|
|
2072c5 |
+ fprintf(stderr, "Invalid argument\n");
|
|
|
2072c5 |
+ exit(1);
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ hostname = argv[1];
|
|
|
2072c5 |
+ volname = argv[2];
|
|
|
2072c5 |
+ logfile = argv[3];
|
|
|
2072c5 |
+ syncfile = argv[4];
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = glfs_test_function(hostname, volname, logfile, syncfile);
|
|
|
2072c5 |
+ if (ret) {
|
|
|
2072c5 |
+ LOG_ERR("glfs_test_function failed");
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ return ret;
|
|
|
2072c5 |
+}
|
|
|
2072c5 |
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c
|
|
|
2072c5 |
index 7fcc9d4..df82b6e 100644
|
|
|
2072c5 |
--- a/xlators/cluster/afr/src/afr-inode-write.c
|
|
|
2072c5 |
+++ b/xlators/cluster/afr/src/afr-inode-write.c
|
|
|
2072c5 |
@@ -2492,6 +2492,7 @@ afr_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
|
|
|
2072c5 |
call_frame_t *transaction_frame = NULL;
|
|
|
2072c5 |
int ret = -1;
|
|
|
2072c5 |
int32_t op_errno = ENOMEM;
|
|
|
2072c5 |
+ int8_t last_fsync = 0;
|
|
|
2072c5 |
|
|
|
2072c5 |
transaction_frame = copy_frame(frame);
|
|
|
2072c5 |
if (!transaction_frame)
|
|
|
2072c5 |
@@ -2501,10 +2502,16 @@ afr_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
|
|
|
2072c5 |
if (!local)
|
|
|
2072c5 |
goto out;
|
|
|
2072c5 |
|
|
|
2072c5 |
- if (xdata)
|
|
|
2072c5 |
+ if (xdata) {
|
|
|
2072c5 |
local->xdata_req = dict_copy_with_ref(xdata, NULL);
|
|
|
2072c5 |
- else
|
|
|
2072c5 |
+ if (dict_get_int8(xdata, "last-fsync", &last_fsync) == 0) {
|
|
|
2072c5 |
+ if (last_fsync) {
|
|
|
2072c5 |
+ local->transaction.disable_delayed_post_op = _gf_true;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+ } else {
|
|
|
2072c5 |
local->xdata_req = dict_new();
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
|
|
|
2072c5 |
if (!local->xdata_req)
|
|
|
2072c5 |
goto out;
|
|
|
2072c5 |
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
|
|
|
2072c5 |
index 8e65ae2..ffd0ab8 100644
|
|
|
2072c5 |
--- a/xlators/cluster/afr/src/afr-transaction.c
|
|
|
2072c5 |
+++ b/xlators/cluster/afr/src/afr-transaction.c
|
|
|
2072c5 |
@@ -2385,8 +2385,13 @@ afr_is_delayed_changelog_post_op_needed(call_frame_t *frame, xlator_t *this,
|
|
|
2072c5 |
goto out;
|
|
|
2072c5 |
}
|
|
|
2072c5 |
|
|
|
2072c5 |
- if ((local->op != GF_FOP_WRITE) && (local->op != GF_FOP_FXATTROP)) {
|
|
|
2072c5 |
- /*Only allow writes but shard does [f]xattrops on writes, so
|
|
|
2072c5 |
+ if (local->transaction.disable_delayed_post_op) {
|
|
|
2072c5 |
+ goto out;
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ if ((local->op != GF_FOP_WRITE) && (local->op != GF_FOP_FXATTROP) &&
|
|
|
2072c5 |
+ (local->op != GF_FOP_FSYNC)) {
|
|
|
2072c5 |
+ /*Only allow writes/fsyncs but shard does [f]xattrops on writes, so
|
|
|
2072c5 |
* they are fine too*/
|
|
|
2072c5 |
goto out;
|
|
|
2072c5 |
}
|
|
|
2072c5 |
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
|
|
|
2072c5 |
index e731cfa..6bc4721 100644
|
|
|
2072c5 |
--- a/xlators/cluster/afr/src/afr.h
|
|
|
2072c5 |
+++ b/xlators/cluster/afr/src/afr.h
|
|
|
2072c5 |
@@ -854,7 +854,7 @@ typedef struct _afr_local {
|
|
|
2072c5 |
|
|
|
2072c5 |
int (*unwind)(call_frame_t *frame, xlator_t *this);
|
|
|
2072c5 |
|
|
|
2072c5 |
- /* post-op hook */
|
|
|
2072c5 |
+ gf_boolean_t disable_delayed_post_op;
|
|
|
2072c5 |
} transaction;
|
|
|
2072c5 |
|
|
|
2072c5 |
syncbarrier_t barrier;
|
|
|
2072c5 |
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
2072c5 |
index 8f31dca..145e616 100644
|
|
|
2072c5 |
--- a/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
2072c5 |
+++ b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
2072c5 |
@@ -1564,6 +1564,7 @@ dht_migrate_file(xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
|
|
|
2072c5 |
xlator_t *old_target = NULL;
|
|
|
2072c5 |
xlator_t *hashed_subvol = NULL;
|
|
|
2072c5 |
fd_t *linkto_fd = NULL;
|
|
|
2072c5 |
+ dict_t *xdata = NULL;
|
|
|
2072c5 |
|
|
|
2072c5 |
if (from == to) {
|
|
|
2072c5 |
gf_msg_debug(this->name, 0,
|
|
|
2072c5 |
@@ -1882,7 +1883,15 @@ dht_migrate_file(xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
|
|
|
2072c5 |
|
|
|
2072c5 |
/* TODO: Sync the locks */
|
|
|
2072c5 |
|
|
|
2072c5 |
- ret = syncop_fsync(to, dst_fd, 0, NULL, NULL, NULL, NULL);
|
|
|
2072c5 |
+ xdata = dict_new();
|
|
|
2072c5 |
+ if (!xdata || dict_set_int8(xdata, "last-fsync", 1)) {
|
|
|
2072c5 |
+ gf_log(this->name, GF_LOG_ERROR,
|
|
|
2072c5 |
+ "%s: failed to set last-fsync flag on "
|
|
|
2072c5 |
+ "%s (%s)",
|
|
|
2072c5 |
+ loc->path, to->name, strerror(ENOMEM));
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = syncop_fsync(to, dst_fd, 0, NULL, NULL, xdata, NULL);
|
|
|
2072c5 |
if (ret) {
|
|
|
2072c5 |
gf_log(this->name, GF_LOG_WARNING, "%s: failed to fsync on %s (%s)",
|
|
|
2072c5 |
loc->path, to->name, strerror(-ret));
|
|
|
2072c5 |
@@ -2356,11 +2365,15 @@ out:
|
|
|
2072c5 |
|
|
|
2072c5 |
if (dst_fd)
|
|
|
2072c5 |
syncop_close(dst_fd);
|
|
|
2072c5 |
+
|
|
|
2072c5 |
if (src_fd)
|
|
|
2072c5 |
syncop_close(src_fd);
|
|
|
2072c5 |
if (linkto_fd)
|
|
|
2072c5 |
syncop_close(linkto_fd);
|
|
|
2072c5 |
|
|
|
2072c5 |
+ if (xdata)
|
|
|
2072c5 |
+ dict_unref(xdata);
|
|
|
2072c5 |
+
|
|
|
2072c5 |
loc_wipe(&tmp_loc);
|
|
|
2072c5 |
loc_wipe(&parent_loc);
|
|
|
2072c5 |
|
|
|
2072c5 |
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
|
|
|
2072c5 |
index 6e99053..1592067 100644
|
|
|
2072c5 |
--- a/xlators/mount/fuse/src/fuse-bridge.c
|
|
|
2072c5 |
+++ b/xlators/mount/fuse/src/fuse-bridge.c
|
|
|
2072c5 |
@@ -5551,6 +5551,7 @@ fuse_migrate_fd(xlator_t *this, fd_t *basefd, xlator_t *old_subvol,
|
|
|
2072c5 |
char create_in_progress = 0;
|
|
|
2072c5 |
fuse_fd_ctx_t *basefd_ctx = NULL;
|
|
|
2072c5 |
fd_t *oldfd = NULL;
|
|
|
2072c5 |
+ dict_t *xdata = NULL;
|
|
|
2072c5 |
|
|
|
2072c5 |
basefd_ctx = fuse_fd_ctx_get(this, basefd);
|
|
|
2072c5 |
GF_VALIDATE_OR_GOTO("glusterfs-fuse", basefd_ctx, out);
|
|
|
2072c5 |
@@ -5587,10 +5588,23 @@ fuse_migrate_fd(xlator_t *this, fd_t *basefd, xlator_t *old_subvol,
|
|
|
2072c5 |
}
|
|
|
2072c5 |
|
|
|
2072c5 |
if (oldfd->inode->table->xl == old_subvol) {
|
|
|
2072c5 |
- if (IA_ISDIR(oldfd->inode->ia_type))
|
|
|
2072c5 |
+ if (IA_ISDIR(oldfd->inode->ia_type)) {
|
|
|
2072c5 |
ret = syncop_fsyncdir(old_subvol, oldfd, 0, NULL, NULL);
|
|
|
2072c5 |
- else
|
|
|
2072c5 |
- ret = syncop_fsync(old_subvol, oldfd, 0, NULL, NULL, NULL, NULL);
|
|
|
2072c5 |
+ } else {
|
|
|
2072c5 |
+ xdata = dict_new();
|
|
|
2072c5 |
+ if (!xdata || dict_set_int8(xdata, "last-fsync", 1)) {
|
|
|
2072c5 |
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
|
|
|
2072c5 |
+ "last-fsync set failed (%s) on fd (%p)"
|
|
|
2072c5 |
+ "(basefd:%p basefd-inode.gfid:%s) "
|
|
|
2072c5 |
+ "(old-subvolume:%s-%d new-subvolume:%s-%d)",
|
|
|
2072c5 |
+ strerror(ENOMEM), oldfd, basefd,
|
|
|
2072c5 |
+ uuid_utoa(basefd->inode->gfid), old_subvol->name,
|
|
|
2072c5 |
+ old_subvol->graph->id, new_subvol->name,
|
|
|
2072c5 |
+ new_subvol->graph->id);
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
+
|
|
|
2072c5 |
+ ret = syncop_fsync(old_subvol, oldfd, 0, NULL, NULL, xdata, NULL);
|
|
|
2072c5 |
+ }
|
|
|
2072c5 |
|
|
|
2072c5 |
if (ret < 0) {
|
|
|
2072c5 |
gf_log("glusterfs-fuse", GF_LOG_WARNING,
|
|
|
2072c5 |
@@ -5645,6 +5659,9 @@ out:
|
|
|
2072c5 |
|
|
|
2072c5 |
fd_unref(oldfd);
|
|
|
2072c5 |
|
|
|
2072c5 |
+ if (xdata)
|
|
|
2072c5 |
+ dict_unref(xdata);
|
|
|
2072c5 |
+
|
|
|
2072c5 |
return ret;
|
|
|
2072c5 |
}
|
|
|
2072c5 |
|
|
|
2072c5 |
--
|
|
|
2072c5 |
1.8.3.1
|
|
|
2072c5 |
|