summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2018-10-22 21:16:53 +0530
committerAmar Tumballi <amarts@redhat.com>2018-10-24 07:11:09 +0000
commitcf5b13896d65b6916634976a3a5f61ddeefbc19c (patch)
treea852203f3de1f68818b01f94aff5411c3e24a227
parent63a8d72736aec13ae90eb1a425ffd2078e5236ad (diff)
leases:Mark the fop conflicting if lease_id not set
Glusterfs leases expects lease_id to be set and sent for each fop to determine conflict resolution with the existing lease. Incase if not set (most likely if there is an older client in a mixed cluster), it makes sense to consider it as conflicitng fop and recall the lease. Also fixed the return status check for __remove_lease(), wherein non-negative value is considered as success case. Change-Id: I5bcfba4f7c71a5af7cdedeb03436d0b818e85783 updates: #350 Signed-off-by: Soumya Koduri <skoduri@redhat.com>
-rw-r--r--xlators/features/leases/src/leases-internal.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/xlators/features/leases/src/leases-internal.c b/xlators/features/leases/src/leases-internal.c
index f87d93d945b..296799b8dff 100644
--- a/xlators/features/leases/src/leases-internal.c
+++ b/xlators/features/leases/src/leases-internal.c
@@ -984,7 +984,7 @@ process_lease_req(call_frame_t *frame, xlator_t *this, inode_t *inode,
break;
case GF_UNLK_LEASE:
ret = __remove_lease(this, inode, lease_ctx, client_uid, lease);
- if ((ret == 0) && (lease_ctx->lease_cnt == 0)) {
+ if ((ret >= 0) && (lease_ctx->lease_cnt == 0)) {
pthread_mutex_unlock(&lease_ctx->lock);
goto unblock;
}
@@ -1019,7 +1019,6 @@ __check_lease_conflict(call_frame_t *frame, lease_inode_ctx_t *lease_ctx,
GF_VALIDATE_OR_GOTO("leases", frame, out);
GF_VALIDATE_OR_GOTO("leases", lease_ctx, out);
- GF_VALIDATE_OR_GOTO("leases", lease_id, out);
lease_type = lease_ctx->lease_type;
@@ -1032,9 +1031,13 @@ __check_lease_conflict(call_frame_t *frame, lease_inode_ctx_t *lease_ctx,
goto recall;
}
- /* TODO: If lease_id is not sent, fall back to client uid conflict check?
- * Or set conflicts = true if lease_id is 0 when there is an existing
- * lease */
+ /* If lease_id is not sent, set conflicts = true if there is
+ * an existing lease */
+ if (!lease_id && (lease_ctx->lease_cnt > 0)) {
+ conflicts = _gf_true;
+ goto recall;
+ }
+
switch (lease_type) {
case (GF_RW_LEASE | GF_RD_LEASE):
case GF_RW_LEASE: