summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/ganesha/scripts/ganesha-ha.sh13
-rw-r--r--geo-replication/syncdaemon/master.py4
-rw-r--r--libglusterfs/src/syscall.c47
-rw-r--r--libglusterfs/src/syscall.h6
-rw-r--r--tests/bugs/glusterd/bug-1420637-volume-sync-fix.t40
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c12
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c2
-rw-r--r--xlators/protocol/client/src/client-handshake.c37
-rw-r--r--xlators/protocol/client/src/client-rpc-fops.c25
-rw-r--r--xlators/protocol/client/src/client.h5
-rw-r--r--xlators/storage/posix/src/posix.c6
11 files changed, 129 insertions, 68 deletions
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
index ac8c91f194e..0692df8f5dd 100644
--- a/extras/ganesha/scripts/ganesha-ha.sh
+++ b/extras/ganesha/scripts/ganesha-ha.sh
@@ -179,13 +179,16 @@ setup_cluster()
logger "pcs cluster setup ${RHEL6_PCS_CNAME_OPTION} ${name} ${servers} failed"
exit 1;
fi
+
+ # BZ 1284404, 1425110, allow time for SSL certs to propagate, until then
+ # pcsd will not accept connections.
+ sleep 12
pcs cluster start --all
- if [ $? -ne 0 ]; then
- logger "pcs cluster start failed"
- exit 1;
- fi
+ while [ $? -ne 0 ]; do
+ sleep 2
+ pcs cluster start --all
+ done
- sleep 1
# wait for the cluster to elect a DC before querying or writing
# to the CIB. BZ 1334092
crmadmin --dc_lookup --timeout=5000 > /dev/null 2>&1
diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py
index b65abf98589..6437dcc4295 100644
--- a/geo-replication/syncdaemon/master.py
+++ b/geo-replication/syncdaemon/master.py
@@ -149,7 +149,9 @@ class NormalMixin(object):
xt = _xtime_now()
rsc.server.aggregated.set_xtime(path, self.uuid, xt)
else:
- xt = opts['default_xtime']
+ zero_zero = (0, 0)
+ if xt != zero_zero:
+ xt = opts['default_xtime']
return xt
def keepalive_payload_hook(self, timo, gap):
diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c
index 7cf1c7757fe..d8b5024f67b 100644
--- a/libglusterfs/src/syscall.c
+++ b/libglusterfs/src/syscall.c
@@ -57,25 +57,44 @@ sys_fstatat(int dirfd, const char *pathname, struct stat *buf, int flags)
int
-sys_openat(int dirfd, const char *pathname, int flags, ...)
-{
- mode_t mode = 0;
- if (flags & O_CREAT) {
- va_list ap;
- va_start(ap, flags);
- mode = va_arg(ap, int);
- va_end(ap);
- }
+sys_openat(int dirfd, const char *pathname, int flags, int mode)
+{
+ int fd;
#ifdef GF_DARWIN_HOST_OS
if (fchdir(dirfd) < 0)
return -1;
- return open (pathname, flags, mode);
-#else
- return openat (dirfd, pathname, flags, mode);
-#endif
+ fd = open (pathname, flags, mode);
+ /* TODO: Shouldn't we restore the old current directory */
+#else /* GF_DARWIN_HOST_OS */
+ fd = openat (dirfd, pathname, flags, mode);
+#ifdef __FreeBSD__
+ /* On FreeBSD S_ISVTX flag is ignored for an open() with O_CREAT set.
+ * We need to force the flag using fchmod(). */
+ if ((fd >= 0) &&
+ ((flags & O_CREAT) != 0) && ((mode & S_ISVTX) != 0)) {
+ sys_fchmod(fd, mode);
+ /* TODO: It's unlikely that fchmod could fail here. However,
+ if it fails we cannot always restore the old state
+ (if the file existed, we cannot recover it). We would
+ need many more system calls to correctly handle all
+ possible cases and it doesn't worth it. For now we
+ simply ignore the error. */
+ }
+#endif /* __FreeBSD__ */
+#endif /* !GF_DARWIN_HOST_OS */
+
+ return fd;
}
+
+int
+sys_open(const char *pathname, int flags, int mode)
+{
+ return sys_openat(AT_FDCWD, pathname, flags, mode);
+}
+
+
DIR *
sys_opendir (const char *name)
{
@@ -239,7 +258,7 @@ sys_utimes (const char *filename, const struct timeval times[2])
int
sys_creat (const char *pathname, mode_t mode)
{
- return creat (pathname, mode);
+ return sys_open(pathname, O_CREAT | O_TRUNC | O_WRONLY, mode);
}
diff --git a/libglusterfs/src/syscall.h b/libglusterfs/src/syscall.h
index 81884f88164..68d72112b89 100644
--- a/libglusterfs/src/syscall.h
+++ b/libglusterfs/src/syscall.h
@@ -63,8 +63,12 @@ sys_fstat (int fd, struct stat *buf);
int
sys_fstatat (int dirfd, const char *pathname, struct stat *buf,
int flags);
+
+int
+sys_open (const char *pathname, int flags, int mode);
+
int
-sys_openat (int dirfd, const char *pathname, int flags, ...);
+sys_openat (int dirfd, const char *pathname, int flags, int mode);
DIR *sys_opendir (const char *name);
diff --git a/tests/bugs/glusterd/bug-1420637-volume-sync-fix.t b/tests/bugs/glusterd/bug-1420637-volume-sync-fix.t
new file mode 100644
index 00000000000..0bd9988f6be
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1420637-volume-sync-fix.t
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Test case for checking when server-quorum-ratio value is changed on one
+# glusterd where the other is down, the other changes done get synced back
+properly when the glusterd is brought up.
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+. $(dirname $0)/../../cluster.rc
+
+cleanup;
+
+TEST launch_cluster 2
+
+TEST $CLI_1 peer probe $H2;
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
+
+# Lets create & start the volume
+TEST $CLI_1 volume create $V0 $H1:$B1/${V0}0 $H2:$B2/${V0}1
+
+# Start the volume
+TEST $CLI_1 volume start $V0
+TEST $CLI_1 volume set $V0 performance.readdir-ahead on
+
+# Bring down 2nd glusterd
+TEST kill_glusterd 2
+
+TEST $CLI_1 volume set all cluster.server-quorum-ratio 60
+TEST $CLI_1 volume set $V0 performance.readdir-ahead off
+
+# Bring back 2nd glusterd
+TEST $glusterd_2
+
+# After 2nd glusterd come back, there will be 2 nodes in a clusater
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count;
+
+EXPECT_WITHIN $PROBE_TIMEOUT "60" volinfo_field_2 all cluster.server-quorum-ratio
+EXPECT_WITHIN $PROBE_TIMEOUT "off" volinfo_field_2 $V0 performance.readdir-ahead
+
+cleanup;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index bd394fc31ba..cc4f69f3526 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -4339,15 +4339,8 @@ glusterd_import_global_opts (dict_t *friend_data)
* recompute if quorum is met. If quorum is not met bricks are
* not started and those already running are stopped
*/
- if (old_quorum != new_quorum) {
- ret = glusterd_restart_bricks (conf);
- if (ret) {
- gf_msg ("glusterd", GF_LOG_INFO, 0,
- GD_MSG_SERVER_QUORUM_NOT_MET,
- "Restarting bricks failed");
- goto out;
- }
- }
+ if (old_quorum != new_quorum)
+ glusterd_restart_bricks (conf);
}
ret = 0;
@@ -4992,6 +4985,7 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
}
}
}
+ ret = 0;
out:
conf->restart_done = _gf_true;
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 7d396373f46..26cd0fc4f25 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -876,7 +876,7 @@ check_prepare_mountbroker_root (char *mountbroker_root)
dfd0 = dup (dfd);
for (;;) {
- ret = sys_openat (dfd, "..", O_RDONLY);
+ ret = sys_openat (dfd, "..", O_RDONLY, 0);
if (ret != -1) {
dfd2 = ret;
ret = sys_fstat (dfd2, &st2);
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index 7732a9711ae..d0c63c18b46 100644
--- a/xlators/protocol/client/src/client-handshake.c
+++ b/xlators/protocol/client/src/client-handshake.c
@@ -350,7 +350,7 @@ clnt_release_reopen_fd_cbk (struct rpc_req *req, struct iovec *iov,
clnt_fd_lk_reacquire_failed (this, fdctx, conf);
- fdctx->reopen_done (fdctx, this);
+ fdctx->reopen_done (fdctx, fdctx->remote_fd, this);
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -383,7 +383,7 @@ clnt_release_reopen_fd (xlator_t *this, clnt_fd_ctx_t *fdctx)
out:
if (ret) {
clnt_fd_lk_reacquire_failed (this, fdctx, conf);
- fdctx->reopen_done (fdctx, this);
+ fdctx->reopen_done (fdctx, fdctx->remote_fd, this);
}
return 0;
}
@@ -502,7 +502,7 @@ client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov,
}
pthread_mutex_unlock (&conf->lock);
- fdctx->reopen_done (fdctx, this);
+ fdctx->reopen_done (fdctx, fdctx->remote_fd, this);
}
ret = 0;
@@ -612,7 +612,7 @@ client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx)
if (client_fd_lk_list_empty (fdctx->lk_ctx, _gf_false)) {
gf_msg_debug (this->name, 0,
"fd lock list is empty");
- fdctx->reopen_done (fdctx, this);
+ fdctx->reopen_done (fdctx, fdctx->remote_fd, this);
} else {
lk_ctx = fdctx->lk_ctx;
@@ -628,14 +628,14 @@ out:
}
void
-client_default_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this)
+client_default_reopen_done (clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
{
gf_log_callingfn (this->name, GF_LOG_WARNING,
"This function should never be called");
}
void
-client_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this)
+client_reopen_done (clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
{
clnt_conf_t *conf = NULL;
gf_boolean_t destroy = _gf_false;
@@ -644,21 +644,23 @@ client_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this)
pthread_mutex_lock (&conf->lock);
{
+ fdctx->remote_fd = rfd;
fdctx->reopen_attempts = 0;
+ fdctx->reopen_done = client_default_reopen_done;
if (!fdctx->released)
list_add_tail (&fdctx->sfd_pos, &conf->saved_fds);
else
destroy = _gf_true;
- fdctx->reopen_done = client_default_reopen_done;
}
pthread_mutex_unlock (&conf->lock);
if (destroy)
client_fdctx_destroy (this, fdctx);
+
}
void
-client_child_up_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this)
+client_child_up_reopen_done (clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
{
clnt_conf_t *conf = NULL;
uint64_t fd_count = 0;
@@ -671,7 +673,7 @@ client_child_up_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this)
}
UNLOCK (&conf->rec_lock);
- client_reopen_done (fdctx, this);
+ client_reopen_done (fdctx, rfd, this);
if (fd_count == 0) {
gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_UP_NOTIFY,
"last fd open'd/lock-self-heal'd - notifying CHILD-UP");
@@ -734,7 +736,6 @@ client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count,
pthread_mutex_lock (&conf->lock);
{
- fdctx->remote_fd = rsp.fd;
if (!fdctx->released) {
if (conf->lk_heal &&
!client_fd_lk_list_empty (fdctx->lk_ctx,
@@ -764,7 +765,7 @@ client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
if (!attempt_lock_recovery)
- fdctx->reopen_done (fdctx, this);
+ fdctx->reopen_done (fdctx, (rsp.op_ret) ? -1 : rsp.fd, this);
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -781,14 +782,12 @@ client3_3_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count,
int32_t ret = -1;
gfs3_open_rsp rsp = {0,};
clnt_local_t *local = NULL;
- clnt_conf_t *conf = NULL;
clnt_fd_ctx_t *fdctx = NULL;
call_frame_t *frame = NULL;
frame = myframe;
local = frame->local;
fdctx = local->fdctx;
- conf = frame->this->private;
if (-1 == req->rpc_status) {
@@ -824,14 +823,8 @@ client3_3_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- pthread_mutex_lock (&conf->lock);
- {
- fdctx->remote_fd = rsp.fd;
- }
- pthread_mutex_unlock (&conf->lock);
-
out:
- fdctx->reopen_done (fdctx, frame->this);
+ fdctx->reopen_done (fdctx, (rsp.op_ret) ? -1 : rsp.fd, frame->this);
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -892,7 +885,7 @@ out:
if (local)
client_local_wipe (local);
- fdctx->reopen_done (fdctx, this);
+ fdctx->reopen_done (fdctx, fdctx->remote_fd, this);
return 0;
@@ -956,7 +949,7 @@ out:
if (local)
client_local_wipe (local);
- fdctx->reopen_done (fdctx, this);
+ fdctx->reopen_done (fdctx, fdctx->remote_fd, this);
return 0;
diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c
index 2e965653e67..dd21869dfd0 100644
--- a/xlators/protocol/client/src/client-rpc-fops.c
+++ b/xlators/protocol/client/src/client-rpc-fops.c
@@ -3314,6 +3314,7 @@ client3_3_releasedir (call_frame_t *frame, xlator_t *this,
clnt_fd_ctx_t *fdctx = NULL;
clnt_args_t *args = NULL;
int64_t remote_fd = -1;
+ gf_boolean_t destroy = _gf_false;
if (!this || !data)
goto out;
@@ -3332,16 +3333,19 @@ client3_3_releasedir (call_frame_t *frame, xlator_t *this,
reopen_cbk handle releasing
*/
- if (remote_fd != -1)
+ if (remote_fd == -1) {
+ fdctx->released = 1;
+ } else {
list_del_init (&fdctx->sfd_pos);
-
- fdctx->released = 1;
+ destroy = _gf_true;
+ }
}
}
pthread_mutex_unlock (&conf->lock);
- if (remote_fd != -1)
+ if (destroy)
client_fdctx_destroy (this, fdctx);
+
out:
return 0;
@@ -3356,6 +3360,7 @@ client3_3_release (call_frame_t *frame, xlator_t *this,
clnt_fd_ctx_t *fdctx = NULL;
clnt_args_t *args = NULL;
lk_heal_state_t lk_heal_state = GF_LK_HEAL_DONE;
+ gf_boolean_t destroy = _gf_false;
if (!this || !data)
goto out;
@@ -3374,17 +3379,17 @@ client3_3_release (call_frame_t *frame, xlator_t *this,
in progress. Just mark ->released = 1 and let
reopen_cbk handle releasing
*/
-
- if (remote_fd != -1 &&
- lk_heal_state == GF_LK_HEAL_DONE)
+ if (remote_fd == -1) {
+ fdctx->released = 1;
+ } else if (lk_heal_state == GF_LK_HEAL_DONE) {
list_del_init (&fdctx->sfd_pos);
-
- fdctx->released = 1;
+ destroy = _gf_true;
+ }
}
}
pthread_mutex_unlock (&conf->lock);
- if (remote_fd != -1 && lk_heal_state == GF_LK_HEAL_DONE)
+ if (destroy)
client_fdctx_destroy (this, fdctx);
out:
return 0;
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
index 46a7875682e..4e278ae95be 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -195,7 +195,7 @@ typedef struct _client_fd_ctx {
pthread_mutex_t mutex;
lk_heal_state_t lk_heal_state;
uuid_t gfid;
- void (*reopen_done) (struct _client_fd_ctx*, xlator_t *);
+ void (*reopen_done)(struct _client_fd_ctx*, int64_t rfd, xlator_t *);
struct list_head lock_list; /* List of all granted locks on this fd */
int32_t reopen_attempts;
} clnt_fd_ctx_t;
@@ -325,7 +325,8 @@ int client_mark_fd_bad (xlator_t *this);
int client_set_lk_version (xlator_t *this);
int client_fd_lk_list_empty (fd_lk_ctx_t *lk_ctx, gf_boolean_t use_try_lock);
-void client_default_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this);
+void client_default_reopen_done (clnt_fd_ctx_t *fdctx, int64_t rfd,
+ xlator_t *this);
void client_attempt_reopen (fd_t *fd, xlator_t *this);
int client_get_remote_fd (xlator_t *this, fd_t *fd, int flags,
int64_t *remote_fd);
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 22601e688aa..49665884a7e 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -2076,7 +2076,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
if (fdstat_requested ||
(priv->background_unlink && IA_ISREG (loc->inode->ia_type))) {
- fd = open (real_path, O_RDONLY);
+ fd = sys_open (real_path, O_RDONLY, 0);
if (fd == -1) {
op_ret = -1;
op_errno = errno;
@@ -2938,7 +2938,7 @@ posix_create (call_frame_t *frame, xlator_t *this,
if (priv->o_direct)
_flags |= O_DIRECT;
- _fd = open (real_path, _flags, mode);
+ _fd = sys_open (real_path, _flags, mode);
if (_fd == -1) {
op_errno = errno;
@@ -3099,7 +3099,7 @@ posix_open (call_frame_t *frame, xlator_t *this,
if (priv->o_direct)
flags |= O_DIRECT;
- _fd = open (real_path, flags, 0);
+ _fd = sys_open (real_path, flags, 0);
if (_fd == -1) {
op_ret = -1;
op_errno = errno;