diff options
author | Raghavendra G <rgowdapp@redhat.com> | 2019-05-13 12:54:52 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2019-09-12 20:25:30 +0530 |
commit | 59f3c790048c9036adb81d56329a66fc3ffb255a (patch) | |
tree | f25e39fa8243b979b64118d7f712007dbcc96a7e /xlators/protocol/client/src/client-helpers.c | |
parent | 61d438e73857776a1f96a7334f56b132275a587b (diff) |
protocol/client: don't reopen fds on which POSIX locks are held after a reconnect
Bricks cleanup any granted locks after a client disconnects and
currently these locks are not healed after a reconnect. This means
post reconnect a competing process could be granted a lock even though
the first process which was granted locks has not unlocked. By not
re-opening fds, subsequent operations on such fds will fail forcing
the application to close the current fd and reopen a new one. This way
we prevent any silent corruption.
A new option "client.strict-locks" is introduced to control this
behaviour. This option is set to "off" by default.
Change-Id: Ieed545efea466cb5e8f5a36199aa26380c301b9e
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
updates: bz#1694920
Diffstat (limited to 'xlators/protocol/client/src/client-helpers.c')
-rw-r--r-- | xlators/protocol/client/src/client-helpers.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c index 52e1089900b..156f1cd3d9b 100644 --- a/xlators/protocol/client/src/client-helpers.c +++ b/xlators/protocol/client/src/client-helpers.c @@ -412,6 +412,7 @@ client_get_remote_fd(xlator_t *this, fd_t *fd, int flags, int64_t *remote_fd) { clnt_fd_ctx_t *fdctx = NULL; clnt_conf_t *conf = NULL; + gf_boolean_t locks_held = _gf_false; GF_VALIDATE_OR_GOTO(this->name, fd, out); GF_VALIDATE_OR_GOTO(this->name, remote_fd, out); @@ -433,11 +434,13 @@ client_get_remote_fd(xlator_t *this, fd_t *fd, int flags, int64_t *remote_fd) *remote_fd = -1; else *remote_fd = fdctx->remote_fd; + + locks_held = !list_empty(&fdctx->lock_list); } } pthread_spin_unlock(&conf->fd_lock); - if ((flags & FALLBACK_TO_ANON_FD) && (*remote_fd == -1)) + if ((flags & FALLBACK_TO_ANON_FD) && (*remote_fd == -1) && (!locks_held)) *remote_fd = GF_ANON_FD_NO; return 0; |