From 19b8c09709c7aeecb84eafb02de797a49a004638 Mon Sep 17 00:00:00 2001 From: Susant Palai Date: Fri, 22 Apr 2016 15:20:39 +0530 Subject: posix/lock: implement meta-lock/unlock functionality problem : The lock state needs to be protected when rebalance is reading the lock state on the source. Otherwise there will be locks left unmigrated. Hence, to synchronize incoming lock requests with lock-migration, meta lock is needed. Any new lock request will be queued if there is an active meta-lock and with sucessful lock migration, will be unwound with EREMOTE, so that dht module can wind the request to the correct destination. On a successful lock migration, "pl_inode->migrated" flag is enabled. Hence, any further request would be unwound with EREMOTE and will be redirected to new destination. More details can be found here: https://github.com/gluster/glusterfs-specs/blob/master/accepted/Lock-Migration.md design discussion: https://www.gluster.org/pipermail/gluster-devel/2016-January/048088.html Change-Id: Ief033d5652b5ca4ba6f499110a521cae283d6aba BUG: 1331720 Signed-off-by: Susant Palai Reviewed-on: http://review.gluster.org/14251 Tested-by: Prasanna Kumar Kalever Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Raghavendra G --- xlators/features/locks/src/locks.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'xlators/features/locks/src/locks.h') diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h index b8763091d00..e363f425b65 100644 --- a/xlators/features/locks/src/locks.h +++ b/xlators/features/locks/src/locks.h @@ -62,6 +62,8 @@ struct __posix_lock { char *client_uid; gf_lkowner_t owner; pid_t client_pid; /* pid of client process */ + + int blocking; }; typedef struct __posix_lock posix_lock_t; @@ -155,6 +157,10 @@ struct __pl_inode { struct list_head reservelk_list; /* list of reservelks */ struct list_head blocked_reservelks; /* list of blocked reservelks */ struct list_head blocked_calls; /* List of blocked lock calls while a reserve is held*/ + struct list_head metalk_list; /* Meta lock list */ + /* This is to store the incoming lock + requests while meta lock is enabled */ + struct list_head queued_locks; int mandatory; /* if mandatory locking is enabled */ inode_t *refkeeper; /* hold refs on an inode while locks are @@ -167,6 +173,18 @@ struct __pl_inode { }; typedef struct __pl_inode pl_inode_t; +struct __pl_metalk { + pthread_mutex_t mutex; + /* For pl_inode meta lock list */ + struct list_head list; + /* For pl_ctx_t list */ + struct list_head client_list; + char *client_uid; + + pl_inode_t *pl_inode; + int ref; +}; +typedef struct __pl_metalk pl_meta_lock_t; typedef struct { mlk_mode_t mandatory_mode; /* holds current mandatory locking mode */ @@ -206,6 +224,7 @@ typedef struct _locks_ctx { pthread_mutex_t lock; struct list_head inodelk_lockers; struct list_head entrylk_lockers; + struct list_head metalk_list; } pl_ctx_t; -- cgit