From cf5b13896d65b6916634976a3a5f61ddeefbc19c Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Mon, 22 Oct 2018 21:16:53 +0530 Subject: 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 --- xlators/features/leases/src/leases-internal.c | 13 ++++++++----- 1 file 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: -- cgit 5space:mode:
authorRaghavendra G <raghavendra@gluster.com>2009-11-18 01:13:38 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-11-18 21:13:38 -0800
commit8cf1cd070e794f18ed5ec28d5a3cb758fa8bf0f2 (patch)
tree2364bfddae863d3e807e5c732b4b144bab46399d
parent8f0ec7204d4b79dfb9fcf5f61df6275f6d4896fb (diff)
Revert "booster, libglusterfsclient: Support samba specific relative paths"
This reverts commit e6fc0cbe716a18f02891d3911481fdcb121d8840. Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 369 (Samba does not work with booster.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=369
-rw-r--r--booster/src/booster_fstab.c8
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c337
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.h2
3 files changed, 166 insertions, 181 deletions
diff --git a/booster/src/booster_fstab.c b/booster/src/booster_fstab.c
index 9524bc668..202249cad 100644
--- a/booster/src/booster_fstab.c
+++ b/booster/src/booster_fstab.c
@@ -375,7 +375,6 @@ booster_mount (struct glusterfs_mntent *ent)
time_t timeout = BOOSTER_DEFAULT_ATTR_TIMEO;
char *timeostr = NULL;
char *endptr = NULL;
- char *optval = NULL;
if (!ent)
return;
@@ -421,13 +420,6 @@ booster_mount (struct glusterfs_mntent *ent)
ipars.lookup_timeout = timeout;
ipars.stat_timeout = timeout;
- opt = glusterfs_fstab_hasoption (ent, "relativepaths");
- if (opt) {
- optval = get_option_value (opt);
- if (strcmp (optval, "on") == 0)
- ipars.relativepaths = 1;
- }
-
if ((glusterfs_mount (ent->mnt_dir, &ipars)) == -1)
gf_log ("booster-fstab", GF_LOG_ERROR, "VMP mounting failed");
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index ed60f73ee..270ecb749 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -58,8 +58,6 @@
#define LIBGF_SENDFILE_BLOCK_SIZE 4096
#define LIBGF_READDIR_BLOCK 4096
-#define libgf_path_absolute(path) ((path[0] == '/'))
-
static inline xlator_t *
libglusterfs_graph (xlator_t *graph);
int32_t libgf_client_readlink (libglusterfs_client_ctx_t *ctx, loc_t *loc,
@@ -86,25 +84,20 @@ pthread_mutex_t vmplock = PTHREAD_MUTEX_INITIALIZER;
* needs to be syncronised.
*/
pthread_mutex_t mountlock = PTHREAD_MUTEX_INITIALIZER;
-int relativepaths = 0;
char *
-libgf_vmp_virtual_path (int entrylen, const char *path, char *vpath)
+libgf_vmp_virtual_path(struct vmp_entry *entry, const char *path)
{
+ char *vpath = NULL;
char *tmp = NULL;
- tmp = ((char *)(path + (entrylen-1)));
- if (strlen (tmp) > 0) {
- if (tmp[0] != '/') {
- vpath[0] = '/';
- vpath[1] = '\0';
- strcat (&vpath[1], tmp);
- } else
- strcpy (vpath, tmp);
- } else {
+ vpath = calloc (strlen (path) + 1, sizeof (char));
+ tmp = ((char *)(path + (entry->vmplen-1)));
+ if (tmp[0] != '/') {
vpath[0] = '/';
- vpath[1] = '\0';
- }
+ strcat (&vpath[1], tmp);
+ } else
+ strcpy (vpath, tmp);
return vpath;
}
@@ -810,21 +803,17 @@ libgf_resolve_path_light (char *path)
char *mypath = NULL;
int len = 0;
int addslash = 0;
- char *savemypath = NULL;
if (!path)
goto out;
- if ((path[0] != '/') && (strncmp (path, "./", 2) != 0))
+ /* We dont as yet support relative paths anywhere in
+ * the lib.