summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorPranith K <pranithk@gluster.com>2011-03-16 09:42:12 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-17 11:58:47 -0700
commit56b86533b1e2eca1535a7b20955b72baf25cd2ae (patch)
treeb0b5f40d3dfd2e56fe14b996b9205d3b05bfaa39 /xlators
parent825a104afe892f91c77dfc3622b50116341c5bb2 (diff)
features/locks: White space related changes to adhere to coding guidelines.
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2346 (Log message enhancements in GlusterFS - phase 1) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/locks/src/common.c244
-rw-r--r--xlators/features/locks/src/entrylk.c532
-rw-r--r--xlators/features/locks/src/inodelk.c444
-rw-r--r--xlators/features/locks/src/posix.c292
-rw-r--r--xlators/features/locks/src/reservelk.c192
5 files changed, 852 insertions, 852 deletions
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index ade440a7d..ef3140089 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -57,11 +57,11 @@ allocate_domain (const char *volume)
dom->domain = gf_strdup(volume);
- if (!dom->domain) {
- gf_log ("posix-locks", GF_LOG_TRACE,
- "Out of Memory");
- return NULL;
- }
+ if (!dom->domain) {
+ gf_log ("posix-locks", GF_LOG_TRACE,
+ "Out of Memory");
+ return NULL;
+ }
gf_log ("posix-locks", GF_LOG_TRACE,
"New domain allocated: %s", dom->domain);
@@ -418,45 +418,45 @@ pl_inode_t *
pl_inode_get (xlator_t *this, inode_t *inode)
{
uint64_t tmp_pl_inode = 0;
- pl_inode_t *pl_inode = NULL;
-// mode_t st_mode = 0;
- int ret = 0;
+ pl_inode_t *pl_inode = NULL;
+// mode_t st_mode = 0;
+ int ret = 0;
- ret = inode_ctx_get (inode, this,&tmp_pl_inode);
- if (ret == 0) {
+ ret = inode_ctx_get (inode, this,&tmp_pl_inode);
+ if (ret == 0) {
pl_inode = (pl_inode_t *)(long)tmp_pl_inode;
- goto out;
+ goto out;
}
- pl_inode = GF_CALLOC (1, sizeof (*pl_inode),
+ pl_inode = GF_CALLOC (1, sizeof (*pl_inode),
gf_locks_mt_pl_inode_t);
- if (!pl_inode) {
- gf_log (this->name, GF_LOG_ERROR,
- "Out of memory.");
- goto out;
- }
+ if (!pl_inode) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Out of memory.");
+ goto out;
+ }
gf_log (this->name, GF_LOG_TRACE,
"Allocating new pl inode");
/*
- st_mode = inode->st_mode;
- if ((st_mode & S_ISGID) && !(st_mode & S_IXGRP))
- pl_inode->mandatory = 1;
+ st_mode = inode->st_mode;
+ if ((st_mode & S_ISGID) && !(st_mode & S_IXGRP))
+ pl_inode->mandatory = 1;
*/
- pthread_mutex_init (&pl_inode->mutex, NULL);
+ pthread_mutex_init (&pl_inode->mutex, NULL);
- INIT_LIST_HEAD (&pl_inode->dom_list);
- INIT_LIST_HEAD (&pl_inode->ext_list);
- INIT_LIST_HEAD (&pl_inode->rw_list);
- INIT_LIST_HEAD (&pl_inode->reservelk_list);
- INIT_LIST_HEAD (&pl_inode->blocked_reservelks);
+ INIT_LIST_HEAD (&pl_inode->dom_list);
+ INIT_LIST_HEAD (&pl_inode->ext_list);
+ INIT_LIST_HEAD (&pl_inode->rw_list);
+ INIT_LIST_HEAD (&pl_inode->reservelk_list);
+ INIT_LIST_HEAD (&pl_inode->blocked_reservelks);
INIT_LIST_HEAD (&pl_inode->blocked_calls);
- inode_ctx_put (inode, this, (uint64_t)(long)(pl_inode));
+ inode_ctx_put (inode, this, (uint64_t)(long)(pl_inode));
out:
- return pl_inode;
+ return pl_inode;
}
@@ -465,31 +465,31 @@ posix_lock_t *
new_posix_lock (struct gf_flock *flock, void *transport, pid_t client_pid,
uint64_t owner, fd_t *fd)
{
- posix_lock_t *lock = NULL;
+ posix_lock_t *lock = NULL;
- lock = GF_CALLOC (1, sizeof (posix_lock_t),
+ lock = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
- if (!lock) {
- return NULL;
- }
+ if (!lock) {
+ return NULL;
+ }
- lock->fl_start = flock->l_start;
- lock->fl_type = flock->l_type;
+ lock->fl_start = flock->l_start;
+ lock->fl_type = flock->l_type;
- if (flock->l_len == 0)
- lock->fl_end = LLONG_MAX;
- else
- lock->fl_end = flock->l_start + flock->l_len - 1;
+ if (flock->l_len == 0)
+ lock->fl_end = LLONG_MAX;
+ else
+ lock->fl_end = flock->l_start + flock->l_len - 1;
- lock->transport = transport;
+ lock->transport = transport;
lock->fd_num = fd_to_fdnum (fd);
lock->fd = fd;
- lock->client_pid = client_pid;
+ lock->client_pid = client_pid;
lock->owner = owner;
- INIT_LIST_HEAD (&lock->list);
+ INIT_LIST_HEAD (&lock->list);
- return lock;
+ return lock;
}
@@ -497,7 +497,7 @@ new_posix_lock (struct gf_flock *flock, void *transport, pid_t client_pid,
void
__delete_lock (pl_inode_t *pl_inode, posix_lock_t *lock)
{
- list_del_init (&lock->list);
+ list_del_init (&lock->list);
}
@@ -505,7 +505,7 @@ __delete_lock (pl_inode_t *pl_inode, posix_lock_t *lock)
void
__destroy_lock (posix_lock_t *lock)
{
- GF_FREE (lock);
+ GF_FREE (lock);
}
@@ -513,15 +513,15 @@ __destroy_lock (posix_lock_t *lock)
void
posix_lock_to_flock (posix_lock_t *lock, struct gf_flock *flock)
{
- flock->l_pid = lock->client_pid;
- flock->l_type = lock->fl_type;
- flock->l_start = lock->fl_start;
+ flock->l_pid = lock->client_pid;
+ flock->l_type = lock->fl_type;
+ flock->l_start = lock->fl_start;
flock->l_owner = lock->owner;
- if (lock->fl_end == LLONG_MAX)
- flock->l_len = 0;
- else
- flock->l_len = lock->fl_end - lock->fl_start + 1;
+ if (lock->fl_end == LLONG_MAX)
+ flock->l_len = 0;
+ else
+ flock->l_len = lock->fl_end - lock->fl_start + 1;
}
/* Insert the lock into the inode's lock list */
@@ -530,7 +530,7 @@ __insert_lock (pl_inode_t *pl_inode, posix_lock_t *lock)
{
list_add_tail (&lock->list, &pl_inode->ext_list);
- return;
+ return;
}
@@ -538,14 +538,14 @@ __insert_lock (pl_inode_t *pl_inode, posix_lock_t *lock)
int
locks_overlap (posix_lock_t *l1, posix_lock_t *l2)
{
- /*
- Note:
- FUSE always gives us absolute offsets, so no need to worry
- about SEEK_CUR or SEEK_END
- */
-
- return ((l1->fl_end >= l2->fl_start) &&
- (l2->fl_end >= l1->fl_start));
+ /*
+ Note:
+ FUSE always gives us absolute offsets, so no need to worry
+ about SEEK_CUR or SEEK_END
+ */
+
+ return ((l1->fl_end >= l2->fl_start) &&
+ (l2->fl_end >= l1->fl_start));
}
@@ -564,15 +564,15 @@ same_owner (posix_lock_t *l1, posix_lock_t *l2)
void
__delete_unlck_locks (pl_inode_t *pl_inode)
{
- posix_lock_t *l = NULL;
- posix_lock_t *tmp = NULL;
-
- list_for_each_entry_safe (l, tmp, &pl_inode->ext_list, list) {
- if (l->fl_type == F_UNLCK) {
- __delete_lock (pl_inode, l);
- __destroy_lock (l);
- }
- }
+ posix_lock_t *l = NULL;
+ posix_lock_t *tmp = NULL;
+
+ list_for_each_entry_safe (l, tmp, &pl_inode->ext_list, list) {
+ if (l->fl_type == F_UNLCK) {
+ __delete_lock (pl_inode, l);
+ __destroy_lock (l);
+ }
+ }
}
@@ -580,22 +580,22 @@ __delete_unlck_locks (pl_inode_t *pl_inode)
static posix_lock_t *
add_locks (posix_lock_t *l1, posix_lock_t *l2)
{
- posix_lock_t *sum = NULL;
+ posix_lock_t *sum = NULL;
- sum = GF_CALLOC (1, sizeof (posix_lock_t),
+ sum = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
- if (!sum)
- return NULL;
+ if (!sum)
+ return NULL;
- sum->fl_start = min (l1->fl_start, l2->fl_start);
- sum->fl_end = max (l1->fl_end, l2->fl_end);
+ sum->fl_start = min (l1->fl_start, l2->fl_start);
+ sum->fl_end = max (l1->fl_end, l2->fl_end);
- return sum;
+ return sum;
}
/* Subtract two locks */
struct _values {
- posix_lock_t *locks[3];
+ posix_lock_t *locks[3];
};
/* {big} must always be contained inside {small} */
@@ -603,85 +603,85 @@ static struct _values
subtract_locks (posix_lock_t *big, posix_lock_t *small)
{
- struct _values v = { .locks = {0, 0, 0} };
+ struct _values v = { .locks = {0, 0, 0} };
- if ((big->fl_start == small->fl_start) &&
- (big->fl_end == small->fl_end)) {
- /* both edges coincide with big */
- v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
+ if ((big->fl_start == small->fl_start) &&
+ (big->fl_end == small->fl_end)) {
+ /* both edges coincide with big */
+ v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
if (!v.locks[0])
goto out;
- memcpy (v.locks[0], big, sizeof (posix_lock_t));
- v.locks[0]->fl_type = small->fl_type;
+ memcpy (v.locks[0], big, sizeof (posix_lock_t));
+ v.locks[0]->fl_type = small->fl_type;
goto done;
- }
+ }
- if ((small->fl_start > big->fl_start) &&
+ if ((small->fl_start > big->fl_start) &&
(small->fl_end < big->fl_end)) {
- /* both edges lie inside big */
- v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
+ /* both edges lie inside big */
+ v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
if (!v.locks[0])
goto out;
- v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
+ v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
if (!v.locks[1])
goto out;
- v.locks[2] = GF_CALLOC (1, sizeof (posix_lock_t),
+ v.locks[2] = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
if (!v.locks[1])
goto out;
- memcpy (v.locks[0], big, sizeof (posix_lock_t));
- v.locks[0]->fl_end = small->fl_start - 1;
+ memcpy (v.locks[0], big, sizeof (posix_lock_t));
+ v.locks[0]->fl_end = small->fl_start - 1;
- memcpy (v.locks[1], small, sizeof (posix_lock_t));
+ memcpy (v.locks[1], small, sizeof (posix_lock_t));
- memcpy (v.locks[2], big, sizeof (posix_lock_t));
- v.locks[2]->fl_start = small->fl_end + 1;
+ memcpy (v.locks[2], big, sizeof (posix_lock_t));
+ v.locks[2]->fl_start = small->fl_end + 1;
goto done;
- }
+ }
- /* one edge coincides with big */
+ /* one edge coincides with big */
if (small->fl_start == big->fl_start) {
- v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
+ v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
if (!v.locks[0])
goto out;
- v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
+ v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
if (!v.locks[1])
goto out;
- memcpy (v.locks[0], big, sizeof (posix_lock_t));
- v.locks[0]->fl_start = small->fl_end + 1;
+ memcpy (v.locks[0], big, sizeof (posix_lock_t));
+ v.locks[0]->fl_start = small->fl_end + 1;
- memcpy (v.locks[1], small, sizeof (posix_lock_t));
+ memcpy (v.locks[1], small, sizeof (posix_lock_t));
goto done;
- }
+ }
- if (small->fl_end == big->fl_end) {
- v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
+ if (small->fl_end == big->fl_end) {
+ v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
if (!v.locks[0])
goto out;
- v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
+ v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
gf_locks_mt_posix_lock_t);
if (!v.locks[1])
goto out;
- memcpy (v.locks[0], big, sizeof (posix_lock_t));
- v.locks[0]->fl_end = small->fl_start - 1;
+ memcpy (v.locks[0], big, sizeof (posix_lock_t));
+ v.locks[0]->fl_end = small->fl_start - 1;
- memcpy (v.locks[1], small, sizeof (posix_lock_t));
+ memcpy (v.locks[1], small, sizeof (posix_lock_t));
goto done;
- }
+ }
gf_log ("posix-locks", GF_LOG_ERROR,
"Unexpected case in subtract_locks. Please send "
@@ -860,7 +860,7 @@ __grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode, struct list_head *g
list_del_init (&l->list);
if (__is_lock_grantable (pl_inode, l)) {
- conf = GF_CALLOC (1, sizeof (*conf),
+ conf = GF_CALLOC (1, sizeof (*conf),
gf_locks_mt_posix_lock_t);
if (!conf) {
@@ -986,19 +986,19 @@ pl_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
/* Send unlock before the actual lock to
prevent lock upgrade / downgrade
problems only if:
- - it is a blocking call
- - it has other conflicting locks
+ - it is a blocking call
+ - it has other conflicting locks
*/
- if (can_block &&
- !(__is_lock_grantable (pl_inode, lock))) {
- ret = pl_send_prelock_unlock (this, pl_inode,
- lock);
- if (ret)
- gf_log (this->name, GF_LOG_DEBUG,
+ if (can_block &&
+ !(__is_lock_grantable (pl_inode, lock))) {
+ ret = pl_send_prelock_unlock (this, pl_inode,
+ lock);
+ if (ret)
+ gf_log (this->name, GF_LOG_DEBUG,
"Could not send pre-lock "
- "unlock");
- }
+ "unlock");
+ }
if (__is_lock_grantable (pl_inode, lock)) {
gf_log (this->name, GF_LOG_TRACE,
diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c
index 827b87d20..c2862cab3 100644
--- a/xlators/features/locks/src/entrylk.c
+++ b/xlators/features/locks/src/entrylk.c
@@ -35,29 +35,29 @@
static pl_entry_lock_t *
new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type,
- void *trans, pid_t client_pid, uint64_t owner, const char *volume)
+ void *trans, pid_t client_pid, uint64_t owner, const char *volume)
{
- pl_entry_lock_t *newlock = NULL;
+ pl_entry_lock_t *newlock = NULL;
- newlock = GF_CALLOC (1, sizeof (pl_entry_lock_t),
+ newlock = GF_CALLOC (1, sizeof (pl_entry_lock_t),
gf_locks_mt_pl_entry_lock_t);
- if (!newlock) {
- goto out;
- }
-
- newlock->basename = basename ? gf_strdup (basename) : NULL;
- newlock->type = type;
- newlock->trans = trans;
- newlock->volume = volume;
+ if (!newlock) {
+ goto out;
+ }
+
+ newlock->basename = basename ? gf_strdup (basename) : NULL;
+ newlock->type = type;
+ newlock->trans = trans;
+ newlock->volume = volume;
newlock->client_pid = client_pid;
newlock->owner = owner;
- INIT_LIST_HEAD (&newlock->domain_list);
- INIT_LIST_HEAD (&newlock->blocked_locks);
+ INIT_LIST_HEAD (&newlock->domain_list);
+ INIT_LIST_HEAD (&newlock->blocked_locks);
out:
- return newlock;
+ return newlock;
}
@@ -77,7 +77,7 @@ out:
static int
names_conflict (const char *n1, const char *n2)
{
- return all_names (n1) || all_names (n2) || !strcmp (n1, n2);
+ return all_names (n1) || all_names (n2) || !strcmp (n1, n2);
}
@@ -86,7 +86,7 @@ __same_entrylk_owner (pl_entry_lock_t *l1, pl_entry_lock_t *l2)
{
return ((l1->owner == l2->owner) &&
- (l1->trans == l2->trans));
+ (l1->trans == l2->trans));
}
@@ -99,33 +99,33 @@ __same_entrylk_owner (pl_entry_lock_t *l1, pl_entry_lock_t *l2)
static pl_entry_lock_t *
__lock_grantable (pl_dom_list_t *dom, const char *basename, entrylk_type type)
{
- pl_entry_lock_t *lock = NULL;
+ pl_entry_lock_t *lock = NULL;
- if (list_empty (&dom->entrylk_list))
- return NULL;
+ if (list_empty (&dom->entrylk_list))
+ return NULL;
- list_for_each_entry (lock, &dom->entrylk_list, domain_list) {
- if (names_conflict (lock->basename, basename))
- return lock;
- }
+ list_for_each_entry (lock, &dom->entrylk_list, domain_list) {
+ if (names_conflict (lock->basename, basename))
+ return lock;
+ }
- return NULL;
+ return NULL;
}
static pl_entry_lock_t *
__blocked_lock_conflict (pl_dom_list_t *dom, const char *basename, entrylk_type type)
{
- pl_entry_lock_t *lock = NULL;
+ pl_entry_lock_t *lock = NULL;
- if (list_empty (&dom->blocked_entrylks))
- return NULL;
+ if (list_empty (&dom->blocked_entrylks))
+ return NULL;
- list_for_each_entry (lock, &dom->blocked_entrylks, blocked_locks) {
- if (names_conflict (lock->basename, basename))
- return lock;
- }
+ list_for_each_entry (lock, &dom->blocked_entrylks, blocked_locks) {
+ if (names_conflict (lock->basename, basename))
+ return lock;
+ }
- return NULL;
+ return NULL;
}
static int
@@ -133,23 +133,23 @@ __owner_has_lock (pl_dom_list_t *dom, pl_entry_lock_t *newlock)
{
pl_entry_lock_t *lock = NULL;
- list_for_each_entry (lock, &dom->entrylk_list, domain_list) {
- if (__same_entrylk_owner (lock, newlock))
- return 1;
- }
+ list_for_each_entry (lock, &dom->entrylk_list, domain_list) {
+ if (__same_entrylk_owner (lock, newlock))
+ return 1;
+ }
- list_for_each_entry (lock, &dom->blocked_entrylks, blocked_locks) {
- if (__same_entrylk_owner (lock, newlock))
- return 1;
- }
+ list_for_each_entry (lock, &dom->blocked_entrylks, blocked_locks) {
+ if (__same_entrylk_owner (lock, newlock))
+ return 1;
+ }
- return 0;
+ return 0;
}
static int
names_equal (const char *n1, const char *n2)
{
- return (n1 == NULL && n2 == NULL) || (n1 && n2 && !strcmp (n1, n2));
+ return (n1 == NULL && n2 == NULL) || (n1 && n2 && !strcmp (n1, n2));
}
void
@@ -284,21 +284,21 @@ entrylk_trace_block (xlator_t *this, call_frame_t *frame, const char *volume,
static pl_entry_lock_t *
__find_most_matching_lock (pl_dom_list_t *dom, const char *basename)
{
- pl_entry_lock_t *lock;
- pl_entry_lock_t *all = NULL;
- pl_entry_lock_t *exact = NULL;
-
- if (list_empty (&dom->entrylk_list))
- return NULL;
-
- list_for_each_entry (lock, &dom->entrylk_list, domain_list) {
- if (all_names (lock->basename))
- all = lock;
- else if (names_equal (lock->basename, basename))
- exact = lock;
- }
+ pl_entry_lock_t *lock;
+ pl_entry_lock_t *all = NULL;
+ pl_entry_lock_t *exact = NULL;
+
+ if (list_empty (&dom->entrylk_list))
+ return NULL;
+
+ list_for_each_entry (lock, &dom->entrylk_list, domain_list) {
+ if (all_names (lock->basename))
+ all = lock;
+ else if (names_equal (lock->basename, basename))
+ exact = lock;
+ }
- return (exact ? exact : all);
+ return (exact ? exact : all);
}
/**
@@ -314,55 +314,55 @@ __find_most_matching_lock (pl_dom_list_t *dom, const char *basename)
int
__lock_name (pl_inode_t *pinode, const char *basename, entrylk_type type,
- call_frame_t *frame, pl_dom_list_t *dom, xlator_t *this, int nonblock)
+ call_frame_t *frame, pl_dom_list_t *dom, xlator_t *this, int nonblock)
{
- pl_entry_lock_t *lock = NULL;
- pl_entry_lock_t *conf = NULL;
- void *trans = NULL;
+ pl_entry_lock_t *lock = NULL;
+ pl_entry_lock_t *conf = NULL;
+ void *trans = NULL;
pid_t client_pid = 0;
uint64_t owner = 0;
- int ret = -EINVAL;
+ int ret = -EINVAL;
- trans = frame->root->trans;
+ trans = frame->root->trans;
client_pid = frame->root->pid;
owner = frame->root->lk_owner;
- lock = new_entrylk_lock (pinode, basename, type, trans, client_pid, owner, dom->domain);
- if (!lock) {
- ret = -ENOMEM;
- goto out;
- }
+ lock = new_entrylk_lock (pinode, basename, type, trans, client_pid, owner, dom->domain);
+ if (!lock) {
+ ret = -ENOMEM;
+ goto out;
+ }
lock->frame = frame;
lock->this = this;
lock->trans = trans;
- conf = __lock_grantable (dom, basename, type);
- if (conf) {
- ret = -EAGAIN;
- if (nonblock){
- if (lock->basename)
- GF_FREE ((char *)lock->basename);
+ conf = __lock_grantable (dom, basename, type);
+ if (conf) {
+ ret = -EAGAIN;
+ if (nonblock){
+ if (lock->basename)
+ GF_FREE ((char *)lock->basename);
GF_FREE (lock);
goto out;
}
- list_add_tail (&lock->blocked_locks, &dom->blocked_entrylks);
+ list_add_tail (&lock->blocked_locks, &dom->blocked_entrylks);
- gf_log (this->name, GF_LOG_TRACE,
- "Blocking lock: {pinode=%p, basename=%s}",
- pinode, basename);
+ gf_log (this->name, GF_LOG_TRACE,
+ "Blocking lock: {pinode=%p, basename=%s}",
+ pinode, basename);
- goto out;
- }
+ goto out;
+ }
if ( __blocked_lock_conflict (dom, basename, type) && !(__owner_has_lock (dom, lock))) {
ret = -EAGAIN;
if (nonblock) {
- if (lock->basename)
- GF_FREE ((char *) lock->basename);
+ if (lock->basename)
+ GF_FREE ((char *) lock->basename);
GF_FREE (lock);
goto out;
@@ -374,18 +374,18 @@ __lock_name (pl_inode_t *pinode, const char *basename, entrylk_type type,
gf_log (this->name, GF_LOG_TRACE,
"Lock is grantable, but blocking to prevent starvation");
- gf_log (this->name, GF_LOG_TRACE,
- "Blocking lock: {pinode=%p, basename=%s}",
- pinode, basename);
+ gf_log (this->name, GF_LOG_TRACE,
+ "Blocking lock: {pinode=%p, basename=%s}",
+ pinode, basename);
ret = -EAGAIN;
- goto out;
+ goto out;
}
switch (type) {
- case ENTRYLK_WRLCK:
- list_add_tail (&lock->domain_list, &dom->entrylk_list);
- break;
+ case ENTRYLK_WRLCK:
+ list_add_tail (&lock->domain_list, &dom->entrylk_list);
+ break;
default:
@@ -393,11 +393,11 @@ __lock_name (pl_inode_t *pinode, const char *basename, entrylk_type type,
"Invalid type for entrylk specified: %d", type);
ret = -EINVAL;
goto out;
- }
+ }
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
/**
@@ -410,107 +410,107 @@ out:
pl_entry_lock_t *
__unlock_name (pl_dom_list_t *dom, const char *basename, entrylk_type type)
{
- pl_entry_lock_t *lock = NULL;
- pl_entry_lock_t *ret_lock = NULL;
-
- lock = __find_most_matching_lock (dom, basename);
-
- if (!lock) {
- gf_log ("locks", GF_LOG_DEBUG,
- "unlock on %s (type=ENTRYLK_WRLCK) attempted but no matching lock found",
- basename);
- goto out;
- }
-
- if (names_equal (lock->basename, basename)
- && lock->type == type) {
-
- if (type == ENTRYLK_WRLCK) {
- list_del_init (&lock->domain_list);
- ret_lock = lock;
- }
- } else {
- gf_log ("locks", GF_LOG_DEBUG,
- "Unlock for a non-existing lock!");
- goto out;
- }
+ pl_entry_lock_t *lock = NULL;
+ pl_entry_lock_t *ret_lock = NULL;
+
+ lock = __find_most_matching_lock (dom, basename);
+
+ if (!lock) {
+ gf_log ("locks", GF_LOG_DEBUG,
+ "unlock on %s (type=ENTRYLK_WRLCK) attempted but no matching lock found",
+ basename);
+ goto out;
+ }
+
+ if (names_equal (lock->basename, basename)
+ && lock->type == type) {
+
+ if (type == ENTRYLK_WRLCK) {
+ list_del_init (&lock->domain_list);
+ ret_lock = lock;
+ }
+ } else {
+ gf_log ("locks", GF_LOG_DEBUG,
+ "Unlock for a non-existing lock!");
+ goto out;
+ }
out:
- return ret_lock;
+ return ret_lock;
}
void
__grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode,
- pl_dom_list_t *dom, struct list_head *granted)
+ pl_dom_list_t *dom, struct list_head *granted)
{
- int bl_ret = 0;
- pl_entry_lock_t *bl = NULL;
- pl_entry_lock_t *tmp = NULL;
+ int bl_ret = 0;
+ pl_entry_lock_t *bl = NULL;
+ pl_entry_lock_t *tmp = NULL;
struct list_head blocked_list;
INIT_LIST_HEAD (&blocked_list);
list_splice_init (&dom->blocked_entrylks, &blocked_list);
-
- list_for_each_entry_safe (bl, tmp, &blocked_list,
- blocked_locks) {
- list_del_init (&bl->blocked_locks);
+ list_for_each_entry_safe (bl, tmp, &blocked_list,
+ blocked_locks) {
+ list_del_init (&bl->blocked_locks);
- gf_log ("locks", GF_LOG_TRACE,
- "Trying to unblock: {pinode=%p, basename=%s}",
- pl_inode, bl->basename);
- bl_ret = __lock_name (pl_inode, bl->basename, bl->type,
- bl->frame, dom, bl->this, 0);
+ gf_log ("locks", GF_LOG_TRACE,
+ "Trying to unblock: {pinode=%p, basename=%s}",
+ pl_inode, bl->basename);
- if (bl_ret == 0) {
- list_add (&bl->blocked_locks, granted);
- } else {
+ bl_ret = __lock_name (pl_inode, bl->basename, bl->type,
+ bl->frame, dom, bl->this, 0);
+
+ if (bl_ret == 0) {
+ list_add (&bl->blocked_locks, granted);
+ } else {
gf_log (this->name, GF_LOG_DEBUG,
"should never happen");
- if (bl->basename)
- GF_FREE ((char *)bl->basename);
- GF_FREE (bl);
- }
- }
- return;
+ if (bl->basename)
+ GF_FREE ((char *)bl->basename);
+ GF_FREE (bl);
+ }
+ }
+ return;
}
/* Grants locks if possible which are blocked on a lock */
void
grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode,
- pl_entry_lock_t *unlocked, pl_dom_list_t *dom)
+ pl_entry_lock_t *unlocked, pl_dom_list_t *dom)
{
- struct list_head granted_list;
- pl_entry_lock_t *tmp = NULL;
- pl_entry_lock_t *lock = NULL;
+ struct list_head granted_list;
+ pl_entry_lock_t *tmp = NULL;
+ pl_entry_lock_t *lock = NULL;
- INIT_LIST_HEAD (&granted_list);
+ INIT_LIST_HEAD (&granted_list);
- pthread_mutex_lock (&pl_inode->mutex);
- {
- __grant_blocked_entry_locks (this, pl_inode, dom, &granted_list);
- }
- pthread_mutex_unlock (&pl_inode->mutex);
+ pthread_mutex_lock (&pl_inode->mutex);
+ {
+ __grant_blocked_entry_locks (this, pl_inode, dom, &granted_list);
+ }
+ pthread_mutex_unlock (&pl_inode->mutex);
- list_for_each_entry_safe (lock, tmp, &granted_list, blocked_locks) {
- list_del_init (&lock->blocked_locks);
+ list_for_each_entry_safe (lock, tmp, &granted_list, blocked_locks) {
+ list_del_init (&lock->blocked_locks);
entrylk_trace_out (this, lock->frame, NULL, NULL, NULL,
lock->basename, ENTRYLK_LOCK, lock->type,
0, 0);
- STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0);
+ STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0);
- }
+ }
- GF_FREE ((char *)unlocked->basename);
- GF_FREE (unlocked);
+ GF_FREE ((char *)unlocked->basename);
+ GF_FREE (unlocked);
- return;
+ return;
}
/**
@@ -520,18 +520,18 @@ grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode,
static int
release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
- pl_dom_list_t *dom, void *trans)
+ pl_dom_list_t *dom, void *trans)
{
- pl_entry_lock_t *lock = NULL;
- pl_entry_lock_t *tmp = NULL;
- struct list_head granted;
+ pl_entry_lock_t *lock = NULL;
+ pl_entry_lock_t *tmp = NULL;
+ struct list_head granted;
struct list_head released;
- INIT_LIST_HEAD (&granted);
+ INIT_LIST_HEAD (&granted);
INIT_LIST_HEAD (&released);
- pthread_mutex_lock (&pinode->mutex);
- {
+ pthread_mutex_lock (&pinode->mutex);
+ {
list_for_each_entry_safe (lock, tmp, &dom->blocked_entrylks,
blocked_locks) {
if (lock->trans != trans)
@@ -539,7 +539,7 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
list_del_init (&lock->blocked_locks);
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_TRACE,
"releasing lock on held by "
"{transport=%p}",trans);
@@ -547,26 +547,26 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
}
- list_for_each_entry_safe (lock, tmp, &dom->entrylk_list,
- domain_list) {
- if (lock->trans != trans)
- continue;
+ list_for_each_entry_safe (lock, tmp, &dom->entrylk_list,
+ domain_list) {
+ if (lock->trans != trans)
+ continue;
- list_del_init (&lock->domain_list);
+ list_del_init (&lock->domain_list);
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_TRACE,
"releasing lock on held by "
"{transport=%p}",trans);
- GF_FREE ((char *)lock->basename);
- GF_FREE (lock);
- }
+ GF_FREE ((char *)lock->basename);
+ GF_FREE (lock);
+ }
- __grant_blocked_entry_locks (this, pinode, dom, &granted);
+ __grant_blocked_entry_locks (this, pinode, dom, &granted);
- }
+ }
- pthread_mutex_unlock (&pinode->mutex);
+ pthread_mutex_unlock (&pinode->mutex);
list_for_each_entry_safe (lock, tmp, &released, blocked_locks) {
list_del_init (&lock->blocked_locks);
@@ -579,17 +579,17 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
}
- list_for_each_entry_safe (lock, tmp, &granted, blocked_locks) {
- list_del_init (&lock->blocked_locks);
+ list_for_each_entry_safe (lock, tmp, &granted, blocked_locks) {
+ list_del_init (&lock->blocked_locks);
- STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0);
+ STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0);
- if (lock->basename)
- GF_FREE ((char *)lock->basename);
- GF_FREE (lock);
- }
+ if (lock->basename)
+ GF_FREE ((char *)lock->basename);
+ GF_FREE (lock);
+ }
- return 0;
+ return 0;
}
/* Common entrylk code called by pl_entrylk and pl_fentrylk */
@@ -599,130 +599,130 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this,
entrylk_cmd cmd, entrylk_type type, loc_t *loc, fd_t *fd)
{
uint64_t owner = 0;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
-
- void * transport = NULL;
- pid_t pid = -1;
-
- pl_inode_t * pinode = NULL;
- int ret = -1;
- pl_entry_lock_t *unlocked = NULL;
- char unwind = 1;
-
- pl_dom_list_t *dom = NULL;
-
- pinode = pl_inode_get (this, inode);
- if (!pinode) {
- gf_log (this->name, GF_LOG_ERROR,
- "Out of memory.");
- op_errno = ENOMEM;
- goto out;
- }
-
- dom = get_domain (pinode, volume);
- if (!dom){
- gf_log (this->name, GF_LOG_ERROR,
- "Out of memory");
- op_errno = ENOMEM;
- goto out;
- }
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+
+ void * transport = NULL;
+ pid_t pid = -1;
+
+ pl_inode_t * pinode = NULL;
+ int ret = -1;
+ pl_entry_lock_t *unlocked = NULL;
+ char unwind = 1;
+
+ pl_dom_list_t *dom = NULL;
+
+ pinode = pl_inode_get (this, inode);
+ if (!pinode) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Out of memory.");
+ op_errno = ENOMEM;
+ goto out;
+ }
+
+ dom = get_domain (pinode, volume);
+ if (!dom){
+ gf_log (this->name, GF_LOG_ERROR,
+ "Out of memory");
+ op_errno = ENOMEM;
+ goto out;
+ }
entrylk_trace_in (this, frame, volume, fd, loc, basename, cmd, type);
- pid = frame->root->pid;
+ pid = frame->root->pid;
owner = frame->root->lk_owner;
- transport = frame->root->trans;
+ transport = frame->root->trans;
- if (owner == 0) {
- /*
+ if (owner == 0) {
+ /*
this is a special case that means release
all locks from this transport
- */
+ */
- gf_log (this->name, GF_LOG_TRACE,
- "Releasing locks for transport %p", transport);
+ gf_log (this->name, GF_LOG_TRACE,
+ "Releasing locks for transport %p", transport);
- release_entry_locks_for_transport (this, pinode, dom, transport);
- op_ret = 0;
+ release_entry_locks_for_transport (this, pinode, dom, transport);
+ op_ret = 0;
- goto out;
- }
+ goto out;
+ }
- switch (cmd) {
- case ENTRYLK_LOCK:
- pthread_mutex_lock (&pinode->mutex);
- {
- ret = __lock_name (pinode, basename, type,
- frame, dom, this, 0);
- }
- pthread_mutex_unlock (&pinode->mutex);
+ switch (cmd) {
+ case ENTRYLK_LOCK:
+ pthread_mutex_lock (&pinode->mutex);
+ {
+ ret = __lock_name (pinode, basename, type,
+ frame, dom, this, 0);
+ }
+ pthread_mutex_unlock (&pinode->mutex);
op_errno = -ret;
- if (ret < 0) {
+ if (ret < 0) {
if (ret == -EAGAIN)
unwind = 0;
else
unwind = 1;
- goto out;
- } else {
+ goto out;
+ } else {
op_ret = 0;
op_errno = 0;
unwind = 1;
goto out;
}
- break;
+ break;
- case ENTRYLK_LOCK_NB:
- pthread_mutex_lock (&pinode->mutex);
- {
- ret = __lock_name (pinode, basename, type,
- frame, dom, this, 1);
- }
- pthread_mutex_unlock (&pinode->mutex);
+ case ENTRYLK_LOCK_NB:
+ pthread_mutex_lock (&pinode->mutex);
+ {
+ ret = __lock_name (pinode, basename, type,
+ frame, dom, this, 1);
+ }
+ pthread_mutex_unlock (&pinode->mutex);
- if (ret < 0)
- op_errno = -ret;
+ if (ret < 0)
+ op_errno = -ret;
unwind = 1;
goto out;
- break;
+ break;
- case ENTRYLK_UNLOCK:
- pthread_mutex_lock (&pinode->mutex);
- {
+ case ENTRYLK_UNLOCK:
+ pthread_mutex_lock (&pinode->mutex);
+ {
unlocked = __unlock_name (dom, basename, type);
- }
- pthread_mutex_unlock (&pinode->mutex);
+ }
+ pthread_mutex_unlock (&pinode->mutex);
- if (unlocked)
- grant_blocked_entry_locks (this, pinode, unlocked, dom);
+ if (unlocked)
+ grant_blocked_entry_locks (this, pinode, unlocked, dom);
- break;
+ break;
- default:
- gf_log (this->name, GF_LOG_ERROR,
- "Unexpected case in entrylk (cmd=%d). Please file"
+ default:
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unexpected case in entrylk (cmd=%d). Please file"
"a bug report at http://bugs.gluster.com", cmd);
- goto out;
- }
+ goto out;
+ }
- op_ret = 0;
+ op_ret = 0;
out:
pl_update_refkeeper (this, inode);
- if (unwind) {
+ if (unwind) {
entrylk_trace_out (this, frame, volume, fd, loc, basename,
cmd, type, op_ret, op_errno);
- STACK_UNWIND_STRICT (entrylk, frame, op_ret, op_errno);
- } else {
+ STACK_UNWIND_STRICT (entrylk, frame, op_ret, op_errno);
+ } else {
entrylk_trace_block (this, frame, volume, fd, loc, basename,
cmd, type);
}
- return 0;
+ return 0;
}
/**
@@ -733,8 +733,8 @@ out:
int
pl_entrylk (call_frame_t *frame, xlator_t *this,
- const char *volume, loc_t *loc, const char *basename,
- entrylk_cmd cmd, entrylk_type type)
+ const char *volume, loc_t *loc, const char *basename,
+ entrylk_cmd cmd, entrylk_type type)
{
pl_common_entrylk (frame, this, volume, loc->inode, basename, cmd, type, loc, NULL);
@@ -775,7 +775,7 @@ __get_entrylk_count (xlator_t *this, pl_inode_t *pl_inode)
" XATTR DEBUG"
" domain: %s %s on %s state = Active",
dom->domain,
- lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
+ lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
"ENTRYLK_WRLCK", lock->basename);
count++;
}
@@ -786,7 +786,7 @@ __get_entrylk_count (xlator_t *this, pl_inode_t *pl_inode)
" XATTR DEBUG"
" domain: %s %s on %s state = Blocked",
dom->domain,
- lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
+ lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
"ENTRYLK_WRLCK", lock->basename);
count++;
}
diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c
index bbbd03398..851eeb088 100644
--- a/xlators/features/locks/src/inodelk.c
+++ b/xlators/features/locks/src/inodelk.c
@@ -36,23 +36,23 @@
void
__delete_inode_lock (pl_inode_lock_t *lock)
{
- list_del (&lock->list);
+ list_del (&lock->list);
}
void
__destroy_inode_lock (pl_inode_lock_t *lock)
{
- GF_FREE (lock);
+ GF_FREE (lock);
}
/* Check if 2 inodelks are conflicting on type. Only 2 shared locks don't conflict */
static int
inodelk_type_conflict (pl_inode_lock_t *l1, pl_inode_lock_t *l2)
{
- if (l2->fl_type == F_WRLCK || l1->fl_type == F_WRLCK)
- return 1;
+ if (l2->fl_type == F_WRLCK || l1->fl_type == F_WRLCK)
+ return 1;
- return 0;
+ return 0;
}
void
@@ -115,14 +115,14 @@ pl_print_inodelk (char *str, int size, int cmd, struct gf_flock *flock, const ch
static int
inodelk_overlap (pl_inode_lock_t *l1, pl_inode_lock_t *l2)
{
- return ((l1->fl_end >= l2->fl_start) &&
- (l2->fl_end >= l1->fl_start));
+ return ((l1->fl_end >= l2->fl_start) &&
+ (l2->fl_end >= l1->fl_start));
}
/* Returns true if the 2 inodelks have the same owner */
static int same_inodelk_owner (pl_inode_lock_t *l1, pl_inode_lock_t *l2)
{
- return ((l1->owner == l2->owner) &&
+ return ((l1->owner == l2->owner) &&
(l1->transport == l2->transport));
}
@@ -138,18 +138,18 @@ inodelk_conflict (pl_inode_lock_t *l1, pl_inode_lock_t *l2)
static pl_inode_lock_t *
__inodelk_grantable (pl_dom_list_t *dom, pl_inode_lock_t *lock)
{
- pl_inode_lock_t *l = NULL;
- pl_inode_lock_t *ret = NULL;
- if (list_empty (&dom->inodelk_list))
- goto out;
- list_for_each_entry (l, &dom->inodelk_list, list){
- if (inodelk_conflict (lock, l)) {
- ret = l;
- goto out;
- }
- }
+ pl_inode_lock_t *l = NULL;
+ pl_inode_lock_t *ret = NULL;
+ if (list_empty (&dom->inodelk_list))
+ goto out;
+ list_for_each_entry (l, &dom->inodelk_list, list){
+ if (inodelk_conflict (lock, l)) {
+ ret = l;
+ goto out;
+ }
+ }
out:
- return ret;
+ return ret;
}
static pl_inode_lock_t *
@@ -158,18 +158,18 @@ __blocked_lock_conflict (pl_dom_list_t *dom, pl_inode_lock_t *lock)
pl_inode_lock_t *l = NULL;
pl_inode_lock_t *ret = NULL;
- if (list_empty (&dom->blocked_entrylks))
- return NULL;
+ if (list_empty (&dom->blocked_entrylks))
+ return NULL;
- list_for_each_entry (l, &dom->blocked_inodelks, blocked_locks) {
- if (inodelk_conflict (lock, l)) {
- ret = l;
- goto out;
+ list_for_each_entry (l, &dom->blocked_inodelks, blocked_locks) {
+ if (inodelk_conflict (lock, l)) {
+ ret = l;
+ goto out;
}
- }
+ }
out:
- return ret;
+ return ret;
}
static int
@@ -177,17 +177,17 @@ __owner_has_lock (pl_dom_list_t *dom, pl_inode_lock_t *newlock)
{
pl_inode_lock_t *lock = NULL;
- list_for_each_entry (lock, &dom->entrylk_list, list) {
- if (same_inodelk_owner (lock, newlock))
- return 1;
- }
+ list_for_each_entry (lock, &dom->entrylk_list, list) {
+ if (same_inodelk_owner (lock, newlock))
+ return 1;
+ }
- list_for_each_entry (lock, &dom->blocked_entrylks, blocked_locks) {
- if (same_inodelk_owner (lock, newlock))
- return 1;
- }
+ list_for_each_entry (lock, &dom->blocked_entrylks, blocked_locks) {
+ if (same_inodelk_owner (lock, newlock))
+ return 1;
+ }
- return 0;
+ return 0;
}
@@ -196,18 +196,18 @@ __owner_has_lock (pl_dom_list_t *dom, pl_inode_lock_t *newlock)
*/
static int
__lock_inodelk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
- int can_block, pl_dom_list_t *dom)
+ int can_block, pl_dom_list_t *dom)
{
- pl_inode_lock_t *conf = NULL;
- int ret = -EINVAL;
+ pl_inode_lock_t *conf = NULL;
+ int ret = -EINVAL;
- conf = __inodelk_grantable (dom, lock);
- if (conf){
- ret = -EAGAIN;
- if (can_block == 0)
- goto out;
+ conf = __inodelk_grantable (dom, lock);
+ if (conf){
+ ret = -EAGAIN;
+ if (can_block == 0)
+ goto out;
- list_add_tail (&lock->blocked_locks, &dom->blocked_inodelks);
+ list_add_tail (&lock->blocked_locks, &dom->blocked_inodelks);
gf_log (this->name, GF_LOG_TRACE,
"%s (pid=%d) lk-owner:%"PRIu64" %"PRId64" - %"PRId64" => Blocked",
@@ -218,8 +218,8 @@ __lock_inodelk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
lock->user_flock.l_len);
- goto out;
- }
+ goto out;
+ }
if (__blocked_lock_conflict (dom, lock) && !(__owner_has_lock (dom, lock))) {
ret = -EAGAIN;
@@ -230,7 +230,7 @@ __lock_inodelk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
gf_log (this->name, GF_LOG_TRACE,
"Lock is grantable, but blocking to prevent starvation");
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_TRACE,
"%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => Blocked",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
@@ -239,38 +239,38 @@ __lock_inodelk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
lock->user_flock.l_len);
- goto out;
+ goto out;
}
- list_add (&lock->list, &dom->inodelk_list);
+ list_add (&lock->list, &dom->inodelk_list);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
/* Return true if the two inodelks have exactly same lock boundaries */
static int
inodelks_equal (pl_inode_lock_t *l1, pl_inode_lock_t *l2)
{
- if ((l1->fl_start == l2->fl_start) &&
- (l1->fl_end == l2->fl_end))
- return 1;
+ if ((l1->fl_start == l2->fl_start) &&
+ (l1->fl_end == l2->fl_end))
+ return 1;
- return 0;
+ return 0;
}
static pl_inode_lock_t *
find_matching_inodelk (pl_inode_lock_t *lock, pl_dom_list_t *dom)
{
- pl_inode_lock_t *l = NULL;
- list_for_each_entry (l, &dom->inodelk_list, list) {
- if (inodelks_equal (l, lock) &&
+ pl_inode_lock_t *l = NULL;
+ list_for_each_entry (l, &dom->inodelk_list, list) {
+ if (inodelks_equal (l, lock) &&
same_inodelk_owner (l, lock))
- return l;
- }
- return NULL;
+ return l;
+ }
+ return NULL;
}
/* Set F_UNLCK removes a lock which has the exact same lock boundaries
@@ -280,60 +280,60 @@ static pl_inode_lock_t *
__inode_unlock_lock (xlator_t *this, pl_inode_lock_t *lock, pl_dom_list_t *dom)
{
- pl_inode_lock_t *conf = NULL;
+ pl_inode_lock_t *conf = NULL;
- conf = find_matching_inodelk (lock, dom);
- if (!conf) {
+ conf = find_matching_inodelk (lock, dom);
+ if (!conf) {
gf_log (this->name, GF_LOG_DEBUG,
" Matching lock not found for unlock");
- goto out;
+ goto out;
}
- __delete_inode_lock (conf);
+ __delete_inode_lock (conf);
gf_log (this->name, GF_LOG_DEBUG,
" Matching lock found for unlock");
__destroy_inode_lock (lock);
out:
- return conf;
+ return conf;
}
static void
-__grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode,
- struct list_head *granted, pl_dom_list_t *dom)
+__grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode,
+ struct list_head *granted, pl_dom_list_t *dom)
{
- int bl_ret = 0;
- pl_inode_lock_t *bl = NULL;
- pl_inode_lock_t *tmp = NULL;
+ int bl_ret = 0;
+ pl_inode_lock_t *bl = NULL;
+ pl_inode_lock_t *tmp = NULL;
struct list_head blocked_list;
INIT_LIST_HEAD (&blocked_list);
list_splice_init (&dom->blocked_inodelks, &blocked_list);
- list_for_each_entry_safe (bl, tmp, &blocked_list, blocked_locks) {
+ list_for_each_entry_safe (bl, tmp, &blocked_list, blocked_locks) {
- list_del_init (&bl->blocked_locks);
+ list_del_init (&bl->blocked_locks);
- bl_ret = __lock_inodelk (this, pl_inode, bl, 1, dom);
+ bl_ret = __lock_inodelk (this, pl_inode, bl, 1, dom);
- if (bl_ret == 0) {
- list_add (&bl->blocked_locks, granted);
+ if (bl_ret == 0) {
+ list_add (&bl->blocked_locks, granted);
}
}
- return;
+ return;
}
/* Grant all inodelks blocked on a lock */
void
grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *dom)
{
- struct list_head granted;
- pl_inode_lock_t *lock;
- pl_inode_lock_t *tmp;
+ struct list_head granted;
+ pl_inode_lock_t *lock;
+ pl_inode_lock_t *tmp;
- INIT_LIST_HEAD (&granted);
+ INIT_LIST_HEAD (&granted);
if (list_empty (&dom->blocked_inodelks)) {
gf_log (this->name, GF_LOG_TRACE,
@@ -341,25 +341,25 @@ grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *
}
pthread_mutex_lock (&pl_inode->mutex);
- {
- __grant_blocked_inode_locks (this, pl_inode, &granted, dom);
- }
+ {
+ __grant_blocked_inode_locks (this, pl_inode, &granted, dom);
+ }
pthread_mutex_unlock (&pl_inode->mutex);
- list_for_each_entry_safe (lock, tmp, &granted, blocked_locks) {
+ list_for_each_entry_safe (lock, tmp, &granted, blocked_locks) {
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => Granted",
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
- lock->owner,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => Granted",
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
+ lock->owner,
+ lock->user_flock.l_start,
+ lock->user_flock.l_len);
- pl_trace_out (this, lock->frame, NULL, NULL, F_SETLKW,
- &lock->user_flock, 0, 0, lock->volume);
+ pl_trace_out (this, lock->frame, NULL, NULL, F_SETLKW,
+ &lock->user_flock, 0, 0, lock->volume);
- STACK_UNWIND_STRICT (inodelk, lock->frame, 0, 0);
- }
+ STACK_UNWIND_STRICT (inodelk, lock->frame, 0, 0);
+ }
}
@@ -368,8 +368,8 @@ static int
release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom,
inode_t *inode, void *trans)
{
- pl_inode_lock_t *tmp = NULL;
- pl_inode_lock_t *l = NULL;
+ pl_inode_lock_t *tmp = NULL;
+ pl_inode_lock_t *l = NULL;
pl_inode_t * pinode = NULL;
@@ -414,7 +414,7 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom,
continue;
__delete_inode_lock (l);
- __destroy_inode_lock (l);
+ __destroy_inode_lock (l);
if (inode_path (inode, NULL, &path) < 0) {
@@ -446,24 +446,24 @@ unlock:
GF_FREE (l);
}
- grant_blocked_inode_locks (this, pinode, dom);
- return 0;
+ grant_blocked_inode_locks (this, pinode, dom);
+ return 0;
}
static int
pl_inode_setlk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
- int can_block, pl_dom_list_t *dom)
+ int can_block, pl_dom_list_t *dom)
{
- int ret = -EINVAL;
+ int ret = -EINVAL;
pl_inode_lock_t *retlock = NULL;
- pthread_mutex_lock (&pl_inode->mutex);
- {
- if (lock->fl_type != F_UNLCK) {
- ret = __lock_inodelk (this, pl_inode, lock, can_block, dom);
- if (ret == 0)
- gf_log (this->name, GF_LOG_TRACE,
+ pthread_mutex_lock (&pl_inode->mutex);
+ {
+ if (lock->fl_type != F_UNLCK) {
+ ret = __lock_inodelk (this, pl_inode, lock, can_block, dom);
+ if (ret == 0)
+ gf_log (this->name, GF_LOG_TRACE,
"%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => OK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
@@ -471,35 +471,35 @@ pl_inode_setlk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
lock->fl_start,
lock->fl_end);
- if (ret == -EAGAIN)
- gf_log (this->name, GF_LOG_TRACE,
+ if (ret == -EAGAIN)
+ gf_log (this->name, GF_LOG_TRACE,
"%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => NOK",
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
lock->owner,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ lock->user_flock.l_start,
+ lock->user_flock.l_len);
- goto out;
- }
+ goto out;
+ }
- retlock = __inode_unlock_lock (this, lock, dom);
- if (!retlock) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Bad Unlock issued on Inode lock");
+ retlock = __inode_unlock_lock (this, lock, dom);
+ if (!retlock) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Bad Unlock issued on Inode lock");
ret = -EINVAL;
goto out;
}
- __destroy_inode_lock (retlock);
+ __destroy_inode_lock (retlock);
ret = 0;
- }
+ }
out:
- pthread_mutex_unlock (&pl_inode->mutex);
- grant_blocked_inode_locks (this, pl_inode, dom);
+ pthread_mutex_unlock (&pl_inode->mutex);
+ grant_blocked_inode_locks (this, pl_inode, dom);
return ret;
}
@@ -509,31 +509,31 @@ new_inode_lock (struct gf_flock *flock, void *transport, pid_t client_pid,
uint64_t owner, const char *volume)
{
- pl_inode_lock_t *lock = NULL;
+ pl_inode_lock_t *lock = NULL;
- lock = GF_CALLOC (1, sizeof (*lock),
+ lock = GF_CALLOC (1, sizeof (*lock),
gf_locks_mt_pl_inode_lock_t);
- if (!lock) {
- return NULL;
- }
+ if (!lock) {
+ return NULL;
+ }
- lock->fl_start = flock->l_start;
- lock->fl_type = flock->l_type;
+ lock->fl_start = flock->l_start;
+ lock->fl_type = flock->l_type;
- if (flock->l_len == 0)
- lock->fl_end = LLONG_MAX;
- else
- lock->fl_end = flock->l_start + flock->l_len - 1;
+ if (flock->l_len == 0)
+ lock->fl_end = LLONG_MAX;
+ else
+ lock->fl_end = flock->l_start + flock->l_len - 1;
- lock->transport = transport;
- lock->client_pid = client_pid;
+ lock->transport = transport;
+ lock->client_pid = client_pid;
lock->owner = owner;
- lock->volume = volume;
+ lock->volume = volume;
- INIT_LIST_HEAD (&lock->list);
- INIT_LIST_HEAD (&lock->blocked_locks);
+ INIT_LIST_HEAD (&lock->list);
+ INIT_LIST_HEAD (&lock->blocked_locks);
- return lock;
+ return lock;
}
/* Common inodelk code called from pl_inodelk and pl_finodelk */
@@ -542,96 +542,96 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this,
const char *volume, inode_t *inode, int32_t cmd,
struct gf_flock *flock, loc_t *loc, fd_t *fd)
{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- int ret = -1;
- int can_block = 0;
- void * transport = NULL;
- pid_t client_pid = -1;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ int ret = -1;
+ int can_block = 0;
+ void * transport = NULL;
+ pid_t client_pid = -1;
uint64_t owner = -1;
- pl_inode_t * pinode = NULL;
- pl_inode_lock_t * reqlock = NULL;
- pl_dom_list_t * dom = NULL;
+ pl_inode_t * pinode = NULL;
+ pl_inode_lock_t * reqlock = NULL;
+ pl_dom_list_t * dom = NULL;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (inode, unwind);
- VALIDATE_OR_GOTO (flock, unwind);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (inode, unwind);
+ VALIDATE_OR_GOTO (flock, unwind);
- if ((flock->l_start < 0) || (flock->l_len < 0)) {
- op_errno = EINVAL;
- goto unwind;
- }
+ if ((flock->l_start < 0) || (flock->l_len < 0)) {
+ op_errno = EINVAL;
+ goto unwind;
+ }
pl_trace_in (this, frame, fd, loc, cmd, flock, volume);
- transport = frame->root->trans;
- client_pid = frame->root->pid;
+ transport = frame->root->trans;
+ client_pid = frame->root->pid;
owner = frame->root->lk_owner;
- pinode = pl_inode_get (this, inode);
- if (!pinode) {
- gf_log (this->name, GF_LOG_ERROR,
- "Out of memory.");
- op_errno = ENOMEM;
- goto unwind;
- }
+ pinode = pl_inode_get (this, inode);
+ if (!pinode) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Out of memory.");
+ op_errno = ENOMEM;
+ goto unwind;
+ }
- dom = get_domain (pinode, volume);
+ dom = get_domain (pinode, volume);
- if (owner == 0) {
- /*
+ if (owner == 0) {
+ /*
special case: this means release all locks
from this transport
- */
- gf_log (this->name, GF_LOG_TRACE,
- "Releasing all locks from transport %p", transport);
+ */
+ gf_log (this->name, GF_LOG_TRACE,
+ "Releasing all locks from transport %p", transport);
- release_inode_locks_of_transport (this, dom, inode, transport);
- goto unwind;
- }
+ release_inode_locks_of_transport (this, dom, inode, transport);
+ goto unwind;
+ }
- reqlock = new_inode_lock (flock, transport, client_pid, owner, volume);
+ reqlock = new_inode_lock (flock, transport, client_pid, owner, volume);
- if (!reqlock) {
- gf_log (this->name, GF_LOG_ERROR,
- "Out of memory.");
- op_ret = -1;
- op_errno = ENOMEM;
- goto unwind;
- }
+ if (!reqlock) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Out of memory.");
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto unwind;
+ }
reqlock->frame = frame;
reqlock->this = this;
- switch (cmd) {
- case F_SETLKW:
- can_block = 1;
- reqlock->frame = frame;
- reqlock->this = this;
+ switch (cmd) {
+ case F_SETLKW:
+ can_block = 1;
+ reqlock->frame = frame;
+ reqlock->this = this;
- /* fall through */
+ /* fall through */
- case F_SETLK:
- memcpy (&reqlock->user_flock, flock, sizeof (struct gf_flock));
- ret = pl_inode_setlk (this, pinode, reqlock,
+ case F_SETLK:
+ memcpy (&reqlock->user_flock, flock, sizeof (struct gf_flock));
+ ret = pl_inode_setlk (this, pinode, reqlock,
can_block, dom);
- if (ret < 0) {
+ if (ret < 0) {
if (can_block) {
pl_trace_block (this, frame, fd, loc,
cmd, flock, volume);
- goto out;
+ goto out;
}
- gf_log (this->name, GF_LOG_TRACE, "returning EAGAIN");
- op_errno = -ret;
- __destroy_inode_lock (reqlock);
- goto unwind;
- }
- break;
-
- default:
- op_errno = ENOTSUP;
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_TRACE, "returning EAGAIN");
+ op_errno = -ret;
+ __destroy_inode_lock (reqlock);
+ goto unwind;
+ }
+ break;
+
+ default:
+ op_errno = ENOTSUP;
+ gf_log (this->name, GF_LOG_DEBUG,
"Lock command F_GETLK not supported for [f]inodelk "
"(cmd=%d)",
cmd);
@@ -641,10 +641,10 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this,
op_ret = 0;
unwind:
- if ((inode != NULL) && (flock !=NULL)) {
- pl_update_refkeeper (this, inode);
- pl_trace_out (this, frame, fd, loc, cmd, flock, op_ret, op_errno, volume);
- }
+ if ((inode != NULL) && (flock !=NULL)) {
+ pl_update_refkeeper (this, inode);
+ pl_trace_out (this, frame, fd, loc, cmd, flock, op_ret, op_errno, volume);
+ }
STACK_UNWIND_STRICT (inodelk, frame, op_ret, op_errno);
out:
@@ -683,32 +683,32 @@ __get_inodelk_count (xlator_t *this, pl_inode_t *pl_inode)
list_for_each_entry (dom, &pl_inode->dom_list, inode_list) {
list_for_each_entry (lock, &dom->inodelk_list, list) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_DEBUG,
" XATTR DEBUG"
- " domain: %s %s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" "
+ " domain: %s %s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" "
"state = Active",
dom->domain,
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
lock->owner,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ lock->user_flock.l_start,
+ lock->user_flock.l_len);
count++;
}
list_for_each_entry (lock, &dom->blocked_inodelks, blocked_locks) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_DEBUG,
" XATTR DEBUG"
- " domain: %s %s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" "
+ " domain: %s %s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" "
"state = Blocked",
dom->domain,
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
lock->owner,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ lock->user_flock.l_start,
+ lock->user_flock.l_len);
count++;
}
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index dacc2b04e..46e73a7fc 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -274,7 +274,7 @@ pl_truncate (call_frame_t *frame, xlator_t *this,
{
struct _truncate_ops *local = NULL;
- local = GF_CALLOC (1, sizeof (struct _truncate_ops),
+ local = GF_CALLOC (1, sizeof (struct _truncate_ops),
gf_locks_mt_truncate_ops);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
@@ -306,7 +306,7 @@ pl_ftruncate (call_frame_t *frame, xlator_t *this,
{
struct _truncate_ops *local = NULL;
- local = GF_CALLOC (1, sizeof (struct _truncate_ops),
+ local = GF_CALLOC (1, sizeof (struct _truncate_ops),
gf_locks_mt_truncate_ops);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
@@ -381,14 +381,14 @@ __delete_locks_of_owner (pl_inode_t *pl_inode,
list_for_each_entry_safe (l, tmp, &pl_inode->ext_list, list) {
if ((l->transport == transport)
&& (l->owner == owner)) {
- gf_log ("posix-locks", GF_LOG_TRACE,
+ gf_log ("posix-locks", GF_LOG_TRACE,
" Flushing lock"
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" state: %s",
- l->fl_type == F_UNLCK ? "Unlock" : "Lock",
- l->client_pid,
+ "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" state: %s",
+ l->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ l->client_pid,
l->owner,
- l->user_flock.l_start,
- l->user_flock.l_len,
+ l->user_flock.l_start,
+ l->user_flock.l_len,
l->blocked == 1 ? "Blocked" : "Active");
__delete_lock (pl_inode, l);
@@ -401,11 +401,11 @@ __delete_locks_of_owner (pl_inode_t *pl_inode,
int32_t
pl_opendir_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- fd_t *fd)
+ void *cookie,
+ xlator_t *this,
+ int32_t op_ret,
+ int32_t op_errno,
+ fd_t *fd)
{
pl_fdctx_t *fdctx = NULL;
@@ -422,24 +422,24 @@ pl_opendir_cbk (call_frame_t *frame,
}
unwind:
- STACK_UNWIND_STRICT (opendir,
+ STACK_UNWIND_STRICT (opendir,
frame,
op_ret,
op_errno,
fd);
- return 0;
+ return 0;
}
-int32_t
+int32_t
pl_opendir (call_frame_t *frame, xlator_t *this,
- loc_t *loc, fd_t *fd)
+ loc_t *loc, fd_t *fd)
{
- STACK_WIND (frame,
- pl_opendir_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->opendir,
- loc, fd);
- return 0;
+ STACK_WIND (frame,
+ pl_opendir_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->opendir,
+ loc, fd);
+ return 0;
}
@@ -478,7 +478,7 @@ pl_flush (call_frame_t *frame, xlator_t *this,
* all locks opened with this fd.
*/
gf_log (this->name, GF_LOG_TRACE,
- "Releasing all locks with fd %p", fd);
+ "Releasing all locks with fd %p", fd);
delete_locks_of_fd (this, pl_inode, fd);
goto wind;
@@ -704,7 +704,7 @@ pl_readv (call_frame_t *frame, xlator_t *this,
goto unlock;
}
- rw = GF_CALLOC (1, sizeof (*rw),
+ rw = GF_CALLOC (1, sizeof (*rw),
gf_locks_mt_pl_rw_req_t);
if (!rw) {
gf_log (this->name, GF_LOG_ERROR,
@@ -802,7 +802,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto unlock;
}
- rw = GF_CALLOC (1, sizeof (*rw),
+ rw = GF_CALLOC (1, sizeof (*rw),
gf_locks_mt_pl_rw_req_t);
if (!rw) {
gf_log (this->name, GF_LOG_ERROR,
@@ -1200,120 +1200,120 @@ pl_forget (xlator_t *this,
posix_lock_t *ext_tmp = NULL;
posix_lock_t *ext_l = NULL;
- struct list_head posixlks_released;
+ struct list_head posixlks_released;
pl_inode_lock_t *ino_tmp = NULL;
pl_inode_lock_t *ino_l = NULL;
- struct list_head inodelks_released;
+ struct list_head inodelks_released;
pl_rw_req_t *rw_tmp = NULL;
pl_rw_req_t *rw_req = NULL;
pl_entry_lock_t *entry_tmp = NULL;
pl_entry_lock_t *entry_l = NULL;
- struct list_head entrylks_released;
+ struct list_head entrylks_released;
pl_dom_list_t *dom = NULL;
pl_dom_list_t *dom_tmp = NULL;
- INIT_LIST_HEAD (&posixlks_released);
- INIT_LIST_HEAD (&inodelks_released);
- INIT_LIST_HEAD (&entrylks_released);
+ INIT_LIST_HEAD (&posixlks_released);
+ INIT_LIST_HEAD (&inodelks_released);
+ INIT_LIST_HEAD (&entrylks_released);
pl_inode = pl_inode_get (this, inode);
- pthread_mutex_lock (&pl_inode->mutex);
- {
+ pthread_mutex_lock (&pl_inode->mutex);
+ {
- if (!list_empty (&pl_inode->rw_list)) {
- gf_log (this->name, GF_LOG_WARNING,
- "Pending R/W requests found, releasing.");
+ if (!list_empty (&pl_inode->rw_list)) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Pending R/W requests found, releasing.");
- list_for_each_entry_safe (rw_req, rw_tmp, &pl_inode->rw_list,
- list) {
+ list_for_each_entry_safe (rw_req, rw_tmp, &pl_inode->rw_list,
+ list) {
- list_del (&rw_req->list);
- GF_FREE (rw_req);
- }
- }
+ list_del (&rw_req->list);
+ GF_FREE (rw_req);
+ }
+ }
- if (!list_empty (&pl_inode->ext_list)) {
- gf_log (this->name, GF_LOG_WARNING,
- "Pending fcntl locks found, releasing.");
+ if (!list_empty (&pl_inode->ext_list)) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Pending fcntl locks found, releasing.");
- list_for_each_entry_safe (ext_l, ext_tmp, &pl_inode->ext_list,
- list) {
+ list_for_each_entry_safe (ext_l, ext_tmp, &pl_inode->ext_list,
+ list) {
+
+ __delete_lock (pl_inode, ext_l);
+ if (ext_l->blocked) {
+ list_add_tail (&ext_l->list, &posixlks_released);
+ continue;
+ }
+ __destroy_lock (ext_l);
+ }
+ }
- __delete_lock (pl_inode, ext_l);
- if (ext_l->blocked) {
- list_add_tail (&ext_l->list, &posixlks_released);
- continue;
- }
- __destroy_lock (ext_l);
- }
- }
+ list_for_each_entry_safe (dom, dom_tmp, &pl_inode->dom_list, inode_list) {
- list_for_each_entry_safe (dom, dom_tmp, &pl_inode->dom_list, inode_list) {
+ if (!list_empty (&dom->inodelk_list)) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Pending inode locks found, releasing.");
- if (!list_empty (&dom->inodelk_list)) {
- gf_log (this->name, GF_LOG_WARNING,
- "Pending inode locks found, releasing.");
+ list_for_each_entry_safe (ino_l, ino_tmp, &dom->inodelk_list, list) {
+ __delete_inode_lock (ino_l);
+ __destroy_inode_lock (ino_l);
+ }
- list_for_each_entry_safe (ino_l, ino_tmp, &dom->inodelk_list, list) {
- __delete_inode_lock (ino_l);
- __destroy_inode_lock (ino_l);
- }
+ list_splice_init (&dom->blocked_inodelks, &inodelks_released);
- list_splice_init (&dom->blocked_inodelks, &inodelks_released);
-
- }
- if (!list_empty (&dom->entrylk_list)) {
- gf_log (this->name, GF_LOG_WARNING,
- "Pending entry locks found, releasing.");
+ }
+ if (!list_empty (&dom->entrylk_list)) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Pending entry locks found, releasing.");
- list_for_each_entry_safe (entry_l, entry_tmp, &dom->entrylk_list, domain_list) {
- list_del_init (&entry_l->domain_list);
+ list_for_each_entry_safe (entry_l, entry_tmp, &dom->entrylk_list, domain_list) {
+ list_del_init (&entry_l->domain_list);
- if (entry_l->basename)
- GF_FREE ((char *)entry_l->basename);
- GF_FREE (entry_l);
- }
+ if (entry_l->basename)
+ GF_FREE ((char *)entry_l->basename);
+ GF_FREE (entry_l);
+ }
- list_splice_init (&dom->blocked_entrylks, &entrylks_released);
- }
+ list_splice_init (&dom->blocked_entrylks, &entrylks_released);
+ }
- list_del (&dom->inode_list);
- gf_log ("posix-locks", GF_LOG_TRACE,
- " Cleaning up domain: %s", dom->domain);
- GF_FREE ((char *)(dom->domain));
- GF_FREE (dom);
- }
+ list_del (&dom->inode_list);
+ gf_log ("posix-locks", GF_LOG_TRACE,
+ " Cleaning up domain: %s", dom->domain);
+ GF_FREE ((char *)(dom->domain));
+ GF_FREE (dom);
+ }
- }
- pthread_mutex_unlock (&pl_inode->mutex);
+ }
+ pthread_mutex_unlock (&pl_inode->mutex);
- list_for_each_entry_safe (ext_l, ext_tmp, &posixlks_released, list) {
+ list_for_each_entry_safe (ext_l, ext_tmp, &posixlks_released, list) {
- STACK_UNWIND_STRICT (lk, ext_l->frame, -1, 0, &ext_l->user_flock);
- __destroy_lock (ext_l);
- }
+ STACK_UNWIND_STRICT (lk, ext_l->frame, -1, 0, &ext_l->user_flock);
+ __destroy_lock (ext_l);
+ }
- list_for_each_entry_safe (ino_l, ino_tmp, &inodelks_released, blocked_locks) {
+ list_for_each_entry_safe (ino_l, ino_tmp, &inodelks_released, blocked_locks) {
- STACK_UNWIND_STRICT (inodelk, ino_l->frame, -1, 0);
- __destroy_inode_lock (ino_l);
- }
+ STACK_UNWIND_STRICT (inodelk, ino_l->frame, -1, 0);
+ __destroy_inode_lock (ino_l);
+ }
- list_for_each_entry_safe (entry_l, entry_tmp, &entrylks_released, blocked_locks) {
+ list_for_each_entry_safe (entry_l, entry_tmp, &entrylks_released, blocked_locks) {
- STACK_UNWIND_STRICT (entrylk, entry_l->frame, -1, 0);
- if (entry_l->basename)
- GF_FREE ((char *)entry_l->basename);
- GF_FREE (entry_l);
+ STACK_UNWIND_STRICT (entrylk, entry_l->frame, -1, 0);
+ if (entry_l->basename)
+ GF_FREE ((char *)entry_l->basename);
+ GF_FREE (entry_l);
- }
+ }
GF_FREE (pl_inode);
@@ -1333,7 +1333,7 @@ pl_release (xlator_t *this, fd_t *fd)
goto out;
}
- ret = inode_ctx_get (fd->inode, this, &tmp_pl_inode);
+ ret = inode_ctx_get (fd->inode, this, &tmp_pl_inode);
if (ret != 0)
goto out;
@@ -1393,14 +1393,14 @@ __get_posixlk_count (xlator_t *this, pl_inode_t *pl_inode)
list_for_each_entry (lock, &pl_inode->ext_list, list) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_DEBUG,
" XATTR DEBUG"
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" state: %s",
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
+ "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" state: %s",
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
lock->owner,
- lock->user_flock.l_start,
- lock->user_flock.l_len,
+ lock->user_flock.l_start,
+ lock->user_flock.l_len,
lock->blocked == 1 ? "Blocked" : "Active");
count++;
@@ -1484,12 +1484,12 @@ pl_posixlk_xattr_fill (xlator_t *this, inode_t *inode,
int32_t
pl_lookup_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- inode_t *inode,
- struct iatt *buf,
+ void *cookie,
+ xlator_t *this,
+ int32_t op_ret,
+ int32_t op_errno,
+ inode_t *inode,
+ struct iatt *buf,
dict_t *dict,
struct iatt *postparent)
{
@@ -1519,23 +1519,23 @@ pl_lookup_cbk (call_frame_t *frame,
GF_FREE (local);
out:
- STACK_UNWIND_STRICT (
+ STACK_UNWIND_STRICT (
lookup,
frame,
- op_ret,
- op_errno,
- inode,
- buf,
+ op_ret,
+ op_errno,
+ inode,
+ buf,
dict,
postparent);
- return 0;
+ return 0;
}
int32_t
pl_lookup (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- dict_t *xattr_req)
+ xlator_t *this,
+ loc_t *loc,
+ dict_t *xattr_req)
{
pl_local_t *local = NULL;
int ret = -1;
@@ -1561,18 +1561,18 @@ pl_lookup (call_frame_t *frame,
frame->local = local;
- STACK_WIND (frame,
- pl_lookup_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->lookup,
- loc,
- xattr_req);
+ STACK_WIND (frame,
+ pl_lookup_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup,
+ loc,
+ xattr_req);
ret = 0;
out:
if (ret == -1)
STACK_UNWIND_STRICT (lookup, frame, -1, 0, NULL, NULL, NULL, NULL);
- return 0;
+ return 0;
}
void
@@ -1631,7 +1631,7 @@ __dump_entrylks (pl_inode_t *pl_inode)
"xlator.feature.locks.lock-dump.domain.entrylk",
"entrylk[%d](ACTIVE)",count );
snprintf (tmp, 256," %s on %s owner=%llu, transport=%p",
- lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
+ lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
"ENTRYLK_WRLCK", lock->basename,
(unsigned long long) lock->owner,
lock->trans);
@@ -1647,7 +1647,7 @@ __dump_entrylks (pl_inode_t *pl_inode)
"xlator.feature.locks.lock-dump.domain.entrylk",
"entrylk[%d](BLOCKED)",count );
snprintf (tmp, 256," %s on %s state = Blocked",
- lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
+ lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
"ENTRYLK_WRLCK", lock->basename);
gf_proc_dump_write(key, tmp);
@@ -1854,7 +1854,7 @@ mem_acct_init (xlator_t *this)
return ret;
ret = xlator_mem_acct_init (this, gf_locks_mt_end + 1);
-
+
if (ret != 0) {
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
"failed");
@@ -1870,7 +1870,7 @@ init (xlator_t *this)
posix_locks_private_t *priv = NULL;
xlator_list_t *trav = NULL;
data_t *mandatory = NULL;
- data_t *trace = NULL;
+ data_t *trace = NULL;
if (!this->children || this->children->next) {
gf_log (this->name, GF_LOG_CRITICAL,
@@ -1894,7 +1894,7 @@ init (xlator_t *this)
return -1;
}
- priv = GF_CALLOC (1, sizeof (*priv),
+ priv = GF_CALLOC (1, sizeof (*priv),
gf_locks_mt_posix_locks_private_t);
mandatory = dict_get (this->options, "mandatory-locks");
@@ -1902,15 +1902,15 @@ init (xlator_t *this)
gf_log (this->name, GF_LOG_WARNING,
"mandatory locks not supported in this minor release.");
- trace = dict_get (this->options, "trace");
- if (trace) {
- if (gf_string2boolean (trace->data,
- &priv->trace) == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "'trace' takes on only boolean values.");
- return -1;
- }
- }
+ trace = dict_get (this->options, "trace");
+ if (trace) {
+ if (gf_string2boolean (trace->data,
+ &priv->trace) == -1) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "'trace' takes on only boolean values.");
+ return -1;
+ }
+ }
this->private = priv;
return 0;
@@ -1982,8 +1982,8 @@ struct volume_options options[] = {
{ .key = { "mandatory-locks", "mandatory" },
.type = GF_OPTION_TYPE_BOOL
},
- { .key = { "trace" },
- .type = GF_OPTION_TYPE_BOOL
- },
+ { .key = { "trace" },
+ .type = GF_OPTION_TYPE_BOOL
+ },
{ .key = {NULL} },
};
diff --git a/xlators/features/locks/src/reservelk.c b/xlators/features/locks/src/reservelk.c
index e2b88140a..61110df79 100644
--- a/xlators/features/locks/src/reservelk.c
+++ b/xlators/features/locks/src/reservelk.c
@@ -36,24 +36,24 @@
void
__delete_reserve_lock (posix_lock_t *lock)
{
- list_del (&lock->list);
+ list_del (&lock->list);
}
void
__destroy_reserve_lock (posix_lock_t *lock)
{
- GF_FREE (lock);
+ GF_FREE (lock);
}
/* Return true if the two reservelks have exactly same lock boundaries */
int
reservelks_equal (posix_lock_t *l1, posix_lock_t *l2)
{
- if ((l1->fl_start == l2->fl_start) &&
- (l1->fl_end == l2->fl_end))
- return 1;
+ if ((l1->fl_start == l2->fl_start) &&
+ (l1->fl_end == l2->fl_end))
+ return 1;
- return 0;
+ return 0;
}
/* Determine if lock is grantable or not */
@@ -61,24 +61,24 @@ static posix_lock_t *
__reservelk_grantable (pl_inode_t *pl_inode, posix_lock_t *lock)
{
xlator_t *this = NULL;
- posix_lock_t *l = NULL;
+ posix_lock_t *l = NULL;
posix_lock_t *ret_lock = NULL;
this = THIS;
- if (list_empty (&pl_inode->reservelk_list)) {
+ if (list_empty (&pl_inode->reservelk_list)) {
gf_log (this->name, GF_LOG_TRACE,
"No reservelks in list");
- goto out;
+ goto out;
}
- list_for_each_entry (l, &pl_inode->reservelk_list, list){
- if (reservelks_equal (lock, l)) {
+ list_for_each_entry (l, &pl_inode->reservelk_list, list){
+ if (reservelks_equal (lock, l)) {
ret_lock = l;
break;
- }
- }
+ }
+ }
out:
- return ret_lock;
+ return ret_lock;
}
static int
@@ -175,16 +175,16 @@ static int
__lock_reservelk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
int can_block)
{
- posix_lock_t *conf = NULL;
- int ret = -EINVAL;
+ posix_lock_t *conf = NULL;
+ int ret = -EINVAL;
- conf = __reservelk_grantable (pl_inode, lock);
- if (conf){
- ret = -EAGAIN;
- if (can_block == 0)
- goto out;
+ conf = __reservelk_grantable (pl_inode, lock);
+ if (conf){
+ ret = -EAGAIN;
+ if (can_block == 0)
+ goto out;
- list_add_tail (&lock->list, &pl_inode->blocked_reservelks);
+ list_add_tail (&lock->list, &pl_inode->blocked_reservelks);
gf_log (this->name, GF_LOG_TRACE,
"%s (pid=%d) lk-owner:%"PRIu64" %"PRId64" - %"PRId64" => Blocked",
@@ -195,26 +195,26 @@ __lock_reservelk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
lock->user_flock.l_len);
- goto out;
- }
+ goto out;
+ }
- list_add (&lock->list, &pl_inode->reservelk_list);
+ list_add (&lock->list, &pl_inode->reservelk_list);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
static posix_lock_t *
find_matching_reservelk (posix_lock_t *lock, pl_inode_t *pl_inode)
{
- posix_lock_t *l = NULL;
- list_for_each_entry (l, &pl_inode->reservelk_list, list) {
- if (reservelks_equal (l, lock))
- return l;
- }
- return NULL;
+ posix_lock_t *l = NULL;
+ list_for_each_entry (l, &pl_inode->reservelk_list, list) {
+ if (reservelks_equal (l, lock))
+ return l;
+ }
+ return NULL;
}
/* Set F_UNLCK removes a lock which has the exact same lock boundaries
@@ -224,20 +224,20 @@ static posix_lock_t *
__reserve_unlock_lock (xlator_t *this, posix_lock_t *lock, pl_inode_t *pl_inode)
{
- posix_lock_t *conf = NULL;
+ posix_lock_t *conf = NULL;
- conf = find_matching_reservelk (lock, pl_inode);
- if (!conf) {
+ conf = find_matching_reservelk (lock, pl_inode);
+ if (!conf) {
gf_log (this->name, GF_LOG_DEBUG,
" Matching lock not found for unlock");
- goto out;
+ goto out;
}
- __delete_reserve_lock (conf);
+ __delete_reserve_lock (conf);
gf_log (this->name, GF_LOG_DEBUG,
" Matching lock found for unlock");
out:
- return conf;
+ return conf;
}
@@ -246,37 +246,37 @@ static void
__grant_blocked_reserve_locks (xlator_t *this, pl_inode_t *pl_inode,
struct list_head *granted)
{
- int bl_ret = 0;
- posix_lock_t *bl = NULL;
- posix_lock_t *tmp = NULL;
+ int bl_ret = 0;
+ posix_lock_t *bl = NULL;
+ posix_lock_t *tmp = NULL;
struct list_head blocked_list;
INIT_LIST_HEAD (&blocked_list);
list_splice_init (&pl_inode->blocked_reservelks, &blocked_list);
- list_for_each_entry_safe (bl, tmp, &blocked_list, list) {
+ list_for_each_entry_safe (bl, tmp, &blocked_list, list) {
- list_del_init (&bl->list);
+ list_del_init (&bl->list);
- bl_ret = __lock_reservelk (this, pl_inode, bl, 1);
+ bl_ret = __lock_reservelk (this, pl_inode, bl, 1);
- if (bl_ret == 0) {
- list_add (&bl->list, granted);
+ if (bl_ret == 0) {
+ list_add (&bl->list, granted);
}
}
- return;
+ return;
}
/* Grant all reservelks blocked on lock(s) */
void
grant_blocked_reserve_locks (xlator_t *this, pl_inode_t *pl_inode)
{
- struct list_head granted;
- posix_lock_t *lock = NULL;
- posix_lock_t *tmp = NULL;
+ struct list_head granted;
+ posix_lock_t *lock = NULL;
+ posix_lock_t *tmp = NULL;
- INIT_LIST_HEAD (&granted);
+ INIT_LIST_HEAD (&granted);
if (list_empty (&pl_inode->blocked_reservelks)) {
gf_log (this->name, GF_LOG_TRACE,
@@ -285,22 +285,22 @@ grant_blocked_reserve_locks (xlator_t *this, pl_inode_t *pl_inode)
}
pthread_mutex_lock (&pl_inode->mutex);
- {
- __grant_blocked_reserve_locks (this, pl_inode, &granted);
- }
+ {
+ __grant_blocked_reserve_locks (this, pl_inode, &granted);
+ }
pthread_mutex_unlock (&pl_inode->mutex);
- list_for_each_entry_safe (lock, tmp, &granted, list) {
+ list_for_each_entry_safe (lock, tmp, &granted, list) {
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => Granted",
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
- lock->owner,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => Granted",
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
+ lock->owner,
+ lock->user_flock.l_start,
+ lock->user_flock.l_len);
- STACK_UNWIND_STRICT (lk, lock->frame, 0, 0, &lock->user_flock);
- }
+ STACK_UNWIND_STRICT (lk, lock->frame, 0, 0, &lock->user_flock);
+ }
}
@@ -308,34 +308,34 @@ static void
__grant_blocked_lock_calls (xlator_t *this, pl_inode_t *pl_inode,
struct list_head *granted)
{
- int bl_ret = 0;
- posix_lock_t *bl = NULL;
- posix_lock_t *tmp = NULL;
+ int bl_ret = 0;
+ posix_lock_t *bl = NULL;
+ posix_lock_t *tmp = NULL;
struct list_head blocked_list;
INIT_LIST_HEAD (&blocked_list);
list_splice_init (&pl_inode->blocked_reservelks, &blocked_list);
- list_for_each_entry_safe (bl, tmp, &blocked_list, list) {
+ list_for_each_entry_safe (bl, tmp, &blocked_list, list) {
- list_del_init (&bl->list);
+ list_del_init (&bl->list);
- bl_ret = pl_verify_reservelk (this, pl_inode, bl, bl->blocked);
+ bl_ret = pl_verify_reservelk (this, pl_inode, bl, bl->blocked);
- if (bl_ret == 0) {
+ if (bl_ret == 0) {
list_add_tail (&bl->list, granted);
}
}
- return;
+ return;
}
void
grant_blocked_lock_calls (xlator_t *this, pl_inode_t *pl_inode)
{
- struct list_head granted;
- posix_lock_t *lock = NULL;
- posix_lock_t *tmp = NULL;
+ struct list_head granted;
+ posix_lock_t *lock = NULL;
+ posix_lock_t *tmp = NULL;
fd_t *fd = NULL;
int can_block = 0;
@@ -349,9 +349,9 @@ grant_blocked_lock_calls (xlator_t *this, pl_inode_t *pl_inode)
}
pthread_mutex_lock (&pl_inode->mutex);
- {
- __grant_blocked_lock_calls (this, pl_inode, &granted);
- }
+ {
+ __grant_blocked_lock_calls (this, pl_inode, &granted);
+ }
pthread_mutex_unlock (&pl_inode->mutex);
list_for_each_entry_safe (lock, tmp, &granted, list) {
@@ -393,18 +393,18 @@ pl_reserve_unlock (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock)
int ret = -1;
pthread_mutex_lock (&pl_inode->mutex);
- {
- retlock = __reserve_unlock_lock (this, lock, pl_inode);
- if (!retlock) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Bad Unlock issued on Inode lock");
+ {
+ retlock = __reserve_unlock_lock (this, lock, pl_inode);
+ if (!retlock) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Bad Unlock issued on Inode lock");
ret = -EINVAL;
goto out;
}
gf_log (this->name, GF_LOG_TRACE,
"Reservelk Unlock successful");
- __destroy_reserve_lock (retlock);
+ __destroy_reserve_lock (retlock);
ret = 0;
}
out:
@@ -421,22 +421,22 @@ int
pl_reserve_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
int can_block)
{
- int ret = -EINVAL;
+ int ret = -EINVAL;
- pthread_mutex_lock (&pl_inode->mutex);
- {
+ pthread_mutex_lock (&pl_inode->mutex);
+ {
- ret = __lock_reservelk (this, pl_inode, lock, can_block);
+ ret = __lock_reservelk (this, pl_inode, lock, can_block);
if (ret < 0)
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_TRACE,
"%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => NOK",
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
lock->owner,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ lock->user_flock.l_start,
+ lock->user_flock.l_len);
else
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_TRACE,
"%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => OK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
@@ -444,7 +444,7 @@ pl_reserve_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
lock->fl_start,
lock->fl_end);
- }
- pthread_mutex_unlock (&pl_inode->mutex);
+ }
+ pthread_mutex_unlock (&pl_inode->mutex);
return ret;
}