diff options
author | Anoop C S <anoopcs@redhat.com> | 2015-02-04 10:34:33 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-05-02 04:18:44 -0700 |
commit | 4517bf8dd6de310950cc5a612955aa3a2fddb57e (patch) | |
tree | 2cdf4e8ec5c9362a325d5a48e07778ea44e1fdfe /xlators/features/locks/src/common.c | |
parent | 78c1c6002f0b11afa997a14f8378c04f257ea1c5 (diff) |
features/locks: Implement mandatory locks
Initial change to fix/enable the mandatory locking support in GlusterFS
as per the following design:
https://review.gluster.org/#/c/12014/
Accordingly 'locks.mandatory-locking' option is available as part of this
change which will accept one among the following values:
* off
* file
* forced
* optimal
See design doc for more details
Change-Id: I14c489b3f8af5ebcbfa155a03f0c175e9558ac46
BUG: 762184
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-on: http://review.gluster.org/9768
Smoke: Gluster Build System <jenkins@build.gluster.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Poornima G <pgurusid@redhat.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/features/locks/src/common.c')
-rw-r--r-- | xlators/features/locks/src/common.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c index c6db18f6ba8..facb078612f 100644 --- a/xlators/features/locks/src/common.c +++ b/xlators/features/locks/src/common.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.com> + Copyright (c) 2006-2012, 2015-2016 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser @@ -446,7 +446,7 @@ unlock: /* Create a new posix_lock_t */ posix_lock_t * new_posix_lock (struct gf_flock *flock, client_t *client, pid_t client_pid, - gf_lkowner_t *owner, fd_t *fd) + gf_lkowner_t *owner, fd_t *fd, uint32_t lk_flags) { posix_lock_t *lock = NULL; @@ -480,6 +480,7 @@ new_posix_lock (struct gf_flock *flock, client_t *client, pid_t client_pid, lock->fd = fd; lock->client_pid = client_pid; lock->owner = *owner; + lock->lk_flags = lk_flags; INIT_LIST_HEAD (&lock->list); @@ -799,7 +800,8 @@ __insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock) continue; if (same_owner (conf, lock)) { - if (conf->fl_type == lock->fl_type) { + if (conf->fl_type == lock->fl_type && + conf->lk_flags == lock->lk_flags) { sum = add_locks (lock, conf); sum->fl_type = lock->fl_type; @@ -810,6 +812,7 @@ __insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock) sum->fd_num = lock->fd_num; sum->client_pid = lock->client_pid; sum->owner = lock->owner; + sum->lk_flags = lock->lk_flags; __delete_lock (conf); __destroy_lock (conf); @@ -832,6 +835,7 @@ __insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock) sum->fd_num = conf->fd_num; sum->client_pid = conf->client_pid; sum->owner = conf->owner; + sum->lk_flags = conf->lk_flags; v = subtract_locks (sum, lock); @@ -988,7 +992,7 @@ pl_send_prelock_unlock (xlator_t *this, pl_inode_t *pl_inode, unlock_lock = new_posix_lock (&flock, old_lock->client, old_lock->client_pid, &old_lock->owner, - old_lock->fd); + old_lock->fd, old_lock->lk_flags); GF_VALIDATE_OR_GOTO (this->name, unlock_lock, out); ret = 0; |