summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-03-24 07:27:26 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-29 04:14:29 -0700
commitb691214fd9114e2b4c7d419ef06aedd28614127a (patch)
treea0a03c39dee5ac2af4b0f2c7acfe49808903823d
parent408a2b029824a3915ce094aed520061e80c078c8 (diff)
cluster/afr: whitespace cleanup
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
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.c544
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c806
-rw-r--r--xlators/cluster/afr/src/afr-open.c196
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-algorithm.c424
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c1069
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c847
-rw-r--r--xlators/cluster/afr/src/afr.h692
7 files changed, 2288 insertions, 2290 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c
index 19ddcbda762..59bd7872e9f 100644
--- a/xlators/cluster/afr/src/afr-dir-read.c
+++ b/xlators/cluster/afr/src/afr-dir-read.c
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2007-2010 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2007-2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
@@ -98,8 +98,8 @@ afr_examine_dir_readdir_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, int32_t op_errno,
gf_dirent_t *entries)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
afr_self_heal_t * sh = NULL;
gf_dirent_t * entry = NULL;
@@ -166,7 +166,7 @@ out:
sizeof(sh_type_str));
gf_log (this->name, GF_LOG_NORMAL,
"%s self-heal triggered. path: %s, "
- "reason: checksums of directory differ,"
+ "reason: checksums of directory differ,"
" forced merge option set",
sh_type_str, local->loc.path);
@@ -197,8 +197,8 @@ afr_examine_dir (call_frame_t *frame, xlator_t *this)
priv = this->private;
local->cont.opendir.checksum = GF_CALLOC (priv->child_count,
- sizeof (*local->cont.opendir.checksum),
- gf_afr_mt_int32_t);
+ sizeof (*local->cont.opendir.checksum),
+ gf_afr_mt_int32_t);
call_count = afr_up_children_count (priv->child_count, local->child_up);
@@ -223,15 +223,15 @@ afr_examine_dir (call_frame_t *frame, xlator_t *this)
int32_t
afr_opendir_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno,
- fd_t *fd)
+ xlator_t *this, int32_t op_ret, int32_t op_errno,
+ fd_t *fd)
{
afr_private_t *priv = NULL;
- afr_local_t *local = NULL;
+ afr_local_t *local = NULL;
int32_t up_children_count = 0;
int ret = -1;
- int call_count = -1;
+ int call_count = -1;
priv = this->private;
local = frame->local;
@@ -239,18 +239,18 @@ afr_opendir_cbk (call_frame_t *frame, void *cookie,
up_children_count = afr_up_children_count (priv->child_count,
local->child_up);
- LOCK (&frame->lock);
- {
- if (op_ret >= 0)
- local->op_ret = op_ret;
+ LOCK (&frame->lock);
+ {
+ if (op_ret >= 0)
+ local->op_ret = op_ret;
- local->op_errno = op_errno;
- }
- UNLOCK (&frame->lock);
+ local->op_errno = op_errno;
+ }
+ UNLOCK (&frame->lock);
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0) {
+ if (call_count == 0) {
if (local->op_ret == 0) {
ret = afr_fd_ctx_set (this, local->fd);
@@ -286,79 +286,79 @@ afr_opendir_cbk (call_frame_t *frame, void *cookie,
local->op_errno, local->fd);
}
} else {
-out:
+ out:
AFR_STACK_UNWIND (opendir, frame, local->op_ret,
local->op_errno, local->fd);
}
}
- return 0;
+ return 0;
}
-int32_t
+int32_t
afr_opendir (call_frame_t *frame, xlator_t *this,
- loc_t *loc, fd_t *fd)
+ loc_t *loc, fd_t *fd)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
- int child_count = 0;
- int i = 0;
+ int child_count = 0;
+ int i = 0;
- int ret = -1;
- int call_count = -1;
+ int ret = -1;
+ int call_count = -1;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
- priv = this->private;
+ priv = this->private;
- child_count = priv->child_count;
+ child_count = priv->child_count;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
- goto out;
- }
+ ALLOC_OR_GOTO (local, afr_local_t, out);
+ ret = AFR_LOCAL_INIT (local, priv);
+ if (ret < 0) {
+ op_errno = -ret;
+ goto out;
+ }
loc_copy (&local->loc, loc);
- frame->local = local;
- local->fd = fd_ref (fd);
+ frame->local = local;
+ local->fd = fd_ref (fd);
- call_count = local->call_count;
-
- for (i = 0; i < child_count; i++) {
- if (local->child_up[i]) {
- STACK_WIND (frame, afr_opendir_cbk,
- priv->children[i],
- priv->children[i]->fops->opendir,
- loc, fd);
+ call_count = local->call_count;
- if (!--call_count)
- break;
- }
- }
+ for (i = 0; i < child_count; i++) {
+ if (local->child_up[i]) {
+ STACK_WIND (frame, afr_opendir_cbk,
+ priv->children[i],
+ priv->children[i]->fops->opendir,
+ loc, fd);
+
+ if (!--call_count)
+ break;
+ }
+ }
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (opendir, frame, op_ret, op_errno, fd);
- }
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (opendir, frame, op_ret, op_errno, fd);
+ }
- return 0;
+ return 0;
}
/**
* Common algorithm for directory read calls:
- *
+ *
* - Try the fop on the first child that is up
* - if we have failed due to ENOTCONN:
* try the next child
@@ -394,110 +394,110 @@ out:
static void
afr_remember_entries (gf_dirent_t *entries, fd_t *fd)
{
- struct entry_name *n = NULL;
- gf_dirent_t * entry = NULL;
+ struct entry_name *n = NULL;
+ gf_dirent_t * entry = NULL;
- int ret = 0;
+ int ret = 0;
- uint64_t ctx;
- afr_fd_ctx_t *fd_ctx;
+ uint64_t ctx;
+ afr_fd_ctx_t *fd_ctx;
- ret = fd_ctx_get (fd, THIS, &ctx);
- if (ret < 0) {
- gf_log (THIS->name, GF_LOG_DEBUG,
- "could not get fd ctx for fd=%p", fd);
- return;
- }
+ ret = fd_ctx_get (fd, THIS, &ctx);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_DEBUG,
+ "could not get fd ctx for fd=%p", fd);
+ return;
+ }
fd_ctx = (afr_fd_ctx_t *)(long) ctx;
- list_for_each_entry (entry, &entries->list, list) {
- n = GF_CALLOC (1, sizeof (*n), gf_afr_mt_entry_name);
- n->name = gf_strdup (entry->d_name);
- INIT_LIST_HEAD (&n->list);
+ list_for_each_entry (entry, &entries->list, list) {
+ n = GF_CALLOC (1, sizeof (*n), gf_afr_mt_entry_name);
+ n->name = gf_strdup (entry->d_name);
+ INIT_LIST_HEAD (&n->list);
- list_add (&n->list, &fd_ctx->entries);
- }
+ list_add (&n->list, &fd_ctx->entries);
+ }
}
static off_t
afr_filter_entries (gf_dirent_t *entries, fd_t *fd)
{
- gf_dirent_t *entry, *tmp;
- int ret = 0;
+ gf_dirent_t *entry, *tmp;
+ int ret = 0;
- uint64_t ctx;
- afr_fd_ctx_t *fd_ctx;
+ uint64_t ctx;
+ afr_fd_ctx_t *fd_ctx;
- off_t offset = 0;
+ off_t offset = 0;
- ret = fd_ctx_get (fd, THIS, &ctx);
- if (ret < 0) {
- gf_log (THIS->name, GF_LOG_DEBUG,
- "could not get fd ctx for fd=%p", fd);
- return -1;
- }
+ ret = fd_ctx_get (fd, THIS, &ctx);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_DEBUG,
+ "could not get fd ctx for fd=%p", fd);
+ return -1;
+ }
fd_ctx = (afr_fd_ctx_t *)(long) ctx;
- list_for_each_entry_safe (entry, tmp, &entries->list, list) {
- offset = entry->d_off;
+ list_for_each_entry_safe (entry, tmp, &entries->list, list) {
+ offset = entry->d_off;
- if (remembered_name (entry->d_name, &fd_ctx->entries)) {
- list_del (&entry->list);
- GF_FREE (entry);
- }
- }
+ if (remembered_name (entry->d_name, &fd_ctx->entries)) {
+ list_del (&entry->list);
+ GF_FREE (entry);
+ }
+ }
- return offset;
+ return offset;
}
static void
afr_forget_entries (fd_t *fd)
{
- struct entry_name *entry, *tmp;
- int ret = 0;
+ struct entry_name *entry, *tmp;
+ int ret = 0;
- uint64_t ctx;
- afr_fd_ctx_t *fd_ctx;
+ uint64_t ctx;
+ afr_fd_ctx_t *fd_ctx;
- ret = fd_ctx_get (fd, THIS, &ctx);
- if (ret < 0) {
- gf_log (THIS->name, GF_LOG_DEBUG,
- "could not get fd ctx for fd=%p", fd);
- return;
- }
+ ret = fd_ctx_get (fd, THIS, &ctx);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_DEBUG,
+ "could not get fd ctx for fd=%p", fd);
+ return;
+ }
fd_ctx = (afr_fd_ctx_t *)(long) ctx;
- list_for_each_entry_safe (entry, tmp, &fd_ctx->entries, list) {
- GF_FREE (entry->name);
- list_del (&entry->list);
- GF_FREE (entry);
- }
+ list_for_each_entry_safe (entry, tmp, &fd_ctx->entries, list) {
+ GF_FREE (entry->name);
+ list_del (&entry->list);
+ GF_FREE (entry);
+ }
}
int32_t
afr_readdir_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno,
- gf_dirent_t *entries)
+ xlator_t *this, int32_t op_ret, int32_t op_errno,
+ gf_dirent_t *entries)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
gf_dirent_t * entry = NULL;
gf_dirent_t * tmp = NULL;
int child_index = -1;
- priv = this->private;
- local = frame->local;
+ priv = this->private;
+ local = frame->local;
child_index = (long) cookie;
- if (op_ret != -1) {
+ if (op_ret != -1) {
list_for_each_entry_safe (entry, tmp, &entries->list, list) {
entry->d_ino = afr_itransform (entry->d_ino,
priv->child_count,
@@ -509,11 +509,11 @@ afr_readdir_cbk (call_frame_t *frame, void *cookie,
GF_FREE (entry);
}
}
- }
+ }
AFR_STACK_UNWIND (readdir, frame, op_ret, op_errno, entries);
- return 0;
+ return 0;
}
@@ -537,7 +537,7 @@ afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
uint64_t ctx = 0;
afr_fd_ctx_t *fd_ctx = NULL;
- off_t offset = 0;
+ off_t offset = 0;
priv = this->private;
children = priv->children;
@@ -546,88 +546,88 @@ afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
child_index = (long) cookie;
- if (priv->strict_readdir) {
- ret = fd_ctx_get (local->fd, this, &ctx);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "could not get fd ctx for fd=%p", local->fd);
- op_ret = -1;
- op_errno = -ret;
- goto out;
- }
-
- fd_ctx = (afr_fd_ctx_t *)(long) ctx;
-
- if (child_went_down (op_ret, op_errno)) {
- if (all_tried (child_index, priv->child_count)) {
- goto out;
- }
-
- call_child = ++child_index;
-
- gf_log (this->name, GF_LOG_TRACE,
- "starting readdir afresh on child %d, offset %"PRId64,
- call_child, (uint64_t) 0);
-
- fd_ctx->failed_over = _gf_true;
-
- STACK_WIND_COOKIE (frame, afr_readdirp_cbk,
- (void *) (long) call_child,
- children[call_child],
- children[call_child]->fops->readdirp, local->fd,
- local->cont.readdir.size, 0);
- return 0;
- }
- }
-
- if (op_ret != -1) {
- list_for_each_entry_safe (entry, tmp, &entries->list, list) {
- inum = afr_itransform (entry->d_ino, priv->child_count,
- child_index);
- entry->d_ino = inum;
- inum = afr_itransform (entry->d_stat.ia_ino,
- priv->child_count, child_index);
- entry->d_stat.ia_ino = inum;
-
- if ((local->fd->inode == local->fd->inode->table->root)
- && !strcmp (entry->d_name, GF_REPLICATE_TRASH_DIR)) {
- list_del_init (&entry->list);
- GF_FREE (entry);
- }
- }
- }
-
- if (priv->strict_readdir) {
- if (fd_ctx->failed_over) {
- if (list_empty (&entries->list)) {
- goto out;
- }
-
- offset = afr_filter_entries (entries, local->fd);
-
- afr_remember_entries (entries, local->fd);
-
- if (list_empty (&entries->list)) {
- /* All the entries we got were duplicate. We
- shouldn't send an empty list now, because
- that'll make the application stop reading. So
- try to get more entries */
-
- gf_log (this->name, GF_LOG_TRACE,
- "trying to fetch non-duplicate entries from offset %"PRId64", child %s",
- offset, children[child_index]->name);
-
- STACK_WIND_COOKIE (frame, afr_readdirp_cbk,
- (void *) (long) child_index,
- children[child_index],
- children[child_index]->fops->readdirp,
- local->fd, local->cont.readdir.size, offset);
- return 0;
- }
- } else {
- afr_remember_entries (entries, local->fd);
- }
- }
+ if (priv->strict_readdir) {
+ ret = fd_ctx_get (local->fd, this, &ctx);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "could not get fd ctx for fd=%p", local->fd);
+ op_ret = -1;
+ op_errno = -ret;
+ goto out;
+ }
+
+ fd_ctx = (afr_fd_ctx_t *)(long) ctx;
+
+ if (child_went_down (op_ret, op_errno)) {
+ if (all_tried (child_index, priv->child_count)) {
+ goto out;
+ }
+
+ call_child = ++child_index;
+
+ gf_log (this->name, GF_LOG_TRACE,
+ "starting readdir afresh on child %d, offset %"PRId64,
+ call_child, (uint64_t) 0);
+
+ fd_ctx->failed_over = _gf_true;
+
+ STACK_WIND_COOKIE (frame, afr_readdirp_cbk,
+ (void *) (long) call_child,
+ children[call_child],
+ children[call_child]->fops->readdirp, local->fd,
+ local->cont.readdir.size, 0);
+ return 0;
+ }
+ }
+
+ if (op_ret != -1) {
+ list_for_each_entry_safe (entry, tmp, &entries->list, list) {
+ inum = afr_itransform (entry->d_ino, priv->child_count,
+ child_index);
+ entry->d_ino = inum;
+ inum = afr_itransform (entry->d_stat.ia_ino,
+ priv->child_count, child_index);
+ entry->d_stat.ia_ino = inum;
+
+ if ((local->fd->inode == local->fd->inode->table->root)
+ && !strcmp (entry->d_name, GF_REPLICATE_TRASH_DIR)) {
+ list_del_init (&entry->list);
+ GF_FREE (entry);
+ }
+ }
+ }
+
+ if (priv->strict_readdir) {
+ if (fd_ctx->failed_over) {
+ if (list_empty (&entries->list)) {
+ goto out;
+ }
+
+ offset = afr_filter_entries (entries, local->fd);
+
+ afr_remember_entries (entries, local->fd);
+
+ if (list_empty (&entries->list)) {
+ /* All the entries we got were duplicate. We
+ shouldn't send an empty list now, because
+ that'll make the application stop reading. So
+ try to get more entries */
+
+ gf_log (this->name, GF_LOG_TRACE,
+ "trying to fetch non-duplicate entries from offset %"PRId64", child %s",
+ offset, children[child_index]->name);
+
+ STACK_WIND_COOKIE (frame, afr_readdirp_cbk,
+ (void *) (long) child_index,
+ children[child_index],
+ children[child_index]->fops->readdirp,
+ local->fd, local->cont.readdir.size, offset);
+ return 0;
+ }
+ } else {
+ afr_remember_entries (entries, local->fd);
+ }
+ }
out:
AFR_STACK_UNWIND (readdirp, frame, op_ret, op_errno, entries);
@@ -638,70 +638,70 @@ out:
int32_t
afr_do_readdir (call_frame_t *frame, xlator_t *this,
- fd_t *fd, size_t size, off_t offset, int whichop)
+ fd_t *fd, size_t size, off_t offset, int whichop)
{
- afr_private_t * priv = NULL;
- xlator_t ** children = NULL;
- int call_child = 0;
- afr_local_t *local = NULL;
+ afr_private_t * priv = NULL;
+ xlator_t ** children = NULL;
+ int call_child = 0;
+ afr_local_t *local = NULL;
uint64_t ctx;
afr_fd_ctx_t *fd_ctx;
- int ret = -1;
+ int ret = -1;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
- priv = this->private;
- children = priv->children;
+ priv = this->private;
+ children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
- goto out;
- }
+ ALLOC_OR_GOTO (local, afr_local_t, out);
+ ret = AFR_LOCAL_INIT (local, priv);
+ if (ret < 0) {
+ op_errno = -ret;
+ goto out;
+ }
- frame->local = local;
+ frame->local = local;
- call_child = afr_first_up_child (priv);
- if (call_child == -1) {
- op_errno = ENOTCONN;
- gf_log (this->name, GF_LOG_DEBUG,
- "no child is up");
- goto out;
- }
+ call_child = afr_first_up_child (priv);
+ if (call_child == -1) {
+ op_errno = ENOTCONN;
+ gf_log (this->name, GF_LOG_DEBUG,
+ "no child is up");
+ goto out;
+ }
local->fd = fd_ref (fd);
local->cont.readdir.size = size;
- if (priv->strict_readdir) {
- ret = fd_ctx_get (fd, this, &ctx);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "could not get fd ctx for fd=%p", fd);
- op_errno = -ret;
- goto out;
- }
+ if (priv->strict_readdir) {
+ ret = fd_ctx_get (fd, this, &ctx);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "could not get fd ctx for fd=%p", fd);
+ op_errno = -ret;
+ goto out;
+ }
- fd_ctx = (afr_fd_ctx_t *)(long) ctx;
+ fd_ctx = (afr_fd_ctx_t *)(long) ctx;
- if (fd_ctx->last_tried != call_child) {
- gf_log (this->name, GF_LOG_TRACE,
- "first up child has changed from %d to %d, restarting readdir from offset 0",
- fd_ctx->last_tried, call_child);
+ if (fd_ctx->last_tried != call_child) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "first up child has changed from %d to %d, restarting readdir from offset 0",
+ fd_ctx->last_tried, call_child);
- fd_ctx->failed_over = _gf_true;
- offset = 0;
- }
+ fd_ctx->failed_over = _gf_true;
+ offset = 0;
+ }
- fd_ctx->last_tried = call_child;
- }
+ fd_ctx->last_tried = call_child;
+ }
if (whichop == GF_FOP_READDIR)
STACK_WIND_COOKIE (frame, afr_readdir_cbk,
@@ -716,12 +716,12 @@ afr_do_readdir (call_frame_t *frame, xlator_t *this,
children[call_child]->fops->readdirp, fd,
size, offset);
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (readdir, frame, op_ret, op_errno, NULL);
- }
- return 0;
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (readdir, frame, op_ret, op_errno, NULL);
+ }
+ return 0;
}
@@ -746,8 +746,8 @@ afr_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
int32_t
afr_releasedir (xlator_t *this, fd_t *fd)
{
- afr_forget_entries (fd);
+ afr_forget_entries (fd);
afr_cleanup_fd_ctx (this, fd);
- return 0;
+ return 0;
}
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index d2089db8ed4..11db1e1d733 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2007-2010 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2007-2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
@@ -61,80 +61,80 @@
int32_t
afr_access_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno)
+ xlator_t *this, int32_t op_ret, int32_t op_errno)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
- int unwind = 1;
- int last_tried = -1;
- int this_try = -1;
+ int unwind = 1;
+ int last_tried = -1;
+ int this_try = -1;
int read_child = -1;
- priv = this->private;
- children = priv->children;
+ priv = this->private;
+ children = priv->children;
- local = frame->local;
+ local = frame->local;
read_child = (long) cookie;
- if (op_ret == -1) {
+ if (op_ret == -1) {
retry:
- last_tried = local->cont.access.last_tried;
+ last_tried = local->cont.access.last_tried;
- if (all_tried (last_tried, priv->child_count)) {
- goto out;
- }
- this_try = ++local->cont.access.last_tried;
+ if (all_tried (last_tried, priv->child_count)) {
+ goto out;
+ }
+ this_try = ++local->cont.access.last_tried;
if (this_try == read_child) {
goto retry;
}
- unwind = 0;
+ unwind = 0;
- STACK_WIND_COOKIE (frame, afr_access_cbk,
- (void *) (long) read_child,
- children[this_try],
- children[this_try]->fops->access,
- &local->loc, local->cont.access.mask);
- }
+ STACK_WIND_COOKIE (frame, afr_access_cbk,
+ (void *) (long) read_child,
+ children[this_try],
+ children[this_try]->fops->access,
+ &local->loc, local->cont.access.mask);
+ }
out:
- if (unwind) {
- AFR_STACK_UNWIND (access, frame, op_ret, op_errno);
- }
+ if (unwind) {
+ AFR_STACK_UNWIND (access, frame, op_ret, op_errno);
+ }
- return 0;
+ return 0;
}
int32_t
afr_access (call_frame_t *frame, xlator_t *this,
- loc_t *loc, int32_t mask)
+ loc_t *loc, int32_t mask)
{
- afr_private_t * priv = NULL;
- xlator_t ** children = NULL;
- int call_child = 0;
- afr_local_t *local = NULL;
+ afr_private_t * priv = NULL;
+ xlator_t ** children = NULL;
+ int call_child = 0;
+ afr_local_t *local = NULL;
int32_t read_child = -1;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
- priv = this->private;
- VALIDATE_OR_GOTO (priv->children, out);
+ priv = this->private;
+ VALIDATE_OR_GOTO (priv->children, out);
- children = priv->children;
+ children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (local, afr_local_t, out);
read_child = afr_read_child (this, loc->inode);
@@ -155,20 +155,20 @@ afr_access (call_frame_t *frame, xlator_t *this,
local->cont.access.last_tried = call_child;
}
- loc_copy (&local->loc, loc);
- local->cont.access.mask = mask;
+ loc_copy (&local->loc, loc);
+ local->cont.access.mask = mask;
- STACK_WIND_COOKIE (frame, afr_access_cbk,
- (void *) (long) call_child,
- children[call_child], children[call_child]->fops->access,
- loc, mask);
+ STACK_WIND_COOKIE (frame, afr_access_cbk,
+ (void *) (long) call_child,
+ children[call_child], children[call_child]->fops->access,
+ loc, mask);
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (access, frame, op_ret, op_errno);
- }
- return 0;
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (access, frame, op_ret, op_errno);
+ }
+ return 0;
}
@@ -178,85 +178,85 @@ out:
int32_t
afr_stat_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno,
- struct iatt *buf)
+ xlator_t *this, int32_t op_ret, int32_t op_errno,
+ struct iatt *buf)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
- int unwind = 1;
- int last_tried = -1;
- int this_try = -1;
- int read_child = -1;
+ int unwind = 1;
+ int last_tried = -1;
+ int this_try = -1;
+ int read_child = -1;
- priv = this->private;
- children = priv->children;
+ priv = this->private;
+ children = priv->children;
- read_child = (long) cookie;
+ read_child = (long) cookie;
- local = frame->local;
+ local = frame->local;
- if (op_ret == -1) {
- retry:
- last_tried = local->cont.stat.last_tried;
+ if (op_ret == -1) {
+ retry:
+ last_tried = local->cont.stat.last_tried;
- if (all_tried (last_tried, priv->child_count)) {
- goto out;
- }
- this_try = ++local->cont.stat.last_tried;
+ if (all_tried (last_tried, priv->child_count)) {
+ goto out;
+ }
+ this_try = ++local->cont.stat.last_tried;
- if (this_try == read_child) {
- goto retry;
- }
+ if (this_try == read_child) {
+ goto retry;
+ }
- unwind = 0;
+ unwind = 0;
- STACK_WIND_COOKIE (frame, afr_stat_cbk,
- (void *) (long) read_child,
- children[this_try],
- children[this_try]->fops->stat,
- &local->loc);
- }
+ STACK_WIND_COOKIE (frame, afr_stat_cbk,
+ (void *) (long) read_child,
+ children[this_try],
+ children[this_try]->fops->stat,
+ &local->loc);
+ }
out:
- if (unwind) {
- if (buf)
- buf->ia_ino = local->cont.stat.ino;
+ if (unwind) {
+ if (buf)
+ buf->ia_ino = local->cont.stat.ino;
- AFR_STACK_UNWIND (stat, frame, op_ret, op_errno, buf);
- }
+ AFR_STACK_UNWIND (stat, frame, op_ret, op_errno, buf);
+ }
- return 0;
+ return 0;
}
int32_t
afr_stat (call_frame_t *frame, xlator_t *this,
- loc_t *loc)
+ loc_t *loc)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
int32_t read_child = -1;
- int call_child = 0;
+ int call_child = 0;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
- priv = this->private;
- VALIDATE_OR_GOTO (priv->children, out);
+ priv = this->private;
+ VALIDATE_OR_GOTO (priv->children, out);
- children = priv->children;
+ children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ frame->local = local;
read_child = afr_read_child (this, loc->inode);
@@ -266,33 +266,33 @@ afr_stat (call_frame_t *frame, xlator_t *this,
local->cont.stat.last_tried = -1;
} else {
- call_child = afr_first_up_child (priv);
- if (call_child == -1) {
- op_errno = ENOTCONN;
- gf_log (this->name, GF_LOG_DEBUG,
- "no child is up");
- goto out;
- }
+ call_child = afr_first_up_child (priv);
+ if (call_child == -1) {
+ op_errno = ENOTCONN;
+ gf_log (this->name, GF_LOG_DEBUG,
+ "no child is up");
+ goto out;
+ }
- local->cont.stat.last_tried = call_child;
- }
+ local->cont.stat.last_tried = call_child;
+ }
- loc_copy (&local->loc, loc);
+ loc_copy (&local->loc, loc);
- local->cont.stat.ino = loc->inode->ino;
+ local->cont.stat.ino = loc->inode->ino;
- STACK_WIND_COOKIE (frame, afr_stat_cbk, (void *) (long) call_child,
- children[call_child],
- children[call_child]->fops->stat,
- loc);
+ STACK_WIND_COOKIE (frame, afr_stat_cbk, (void *) (long) call_child,
+ children[call_child],
+ children[call_child]->fops->stat,
+ loc);
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (stat, frame, op_ret, op_errno, NULL);
- }
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (stat, frame, op_ret, op_errno, NULL);
+ }
- return 0;
+ return 0;
}
@@ -302,88 +302,88 @@ out:
int32_t
afr_fstat_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno,
- struct iatt *buf)
+ xlator_t *this, int32_t op_ret, int32_t op_errno,
+ struct iatt *buf)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
- int unwind = 1;
- int last_tried = -1;
- int this_try = -1;
+ int unwind = 1;
+ int last_tried = -1;
+ int this_try = -1;
int read_child = -1;
- priv = this->private;
- children = priv->children;
+ priv = this->private;
+ children = priv->children;
- local = frame->local;
+ local = frame->local;
- read_child = (long) cookie;
+ read_child = (long) cookie;
- if (op_ret == -1) {
- retry:
- last_tried = local->cont.fstat.last_tried;
+ if (op_ret == -1) {
+ retry:
+ last_tried = local->cont.fstat.last_tried;
- if (all_tried (last_tried, priv->child_count)) {
- goto out;
- }
- this_try = ++local->cont.fstat.last_tried;
+ if (all_tried (last_tried, priv->child_count)) {
+ goto out;
+ }
+ this_try = ++local->cont.fstat.last_tried;
- if (this_try == read_child) {
- goto retry;
- }
+ if (this_try == read_child) {
+ goto retry;
+ }
- unwind = 0;
+ unwind = 0;
- STACK_WIND_COOKIE (frame, afr_fstat_cbk,
- (void *) (long) read_child,
- children[this_try],
- children[this_try]->fops->fstat,
- local->fd);
- }
+ STACK_WIND_COOKIE (frame, afr_fstat_cbk,
+ (void *) (long) read_child,
+ children[this_try],
+ children[this_try]->fops->fstat,
+ local->fd);
+ }
out:
- if (unwind) {
- if (buf)
- buf->ia_ino = local->cont.fstat.ino;
+ if (unwind) {
+ if (buf)
+ buf->ia_ino = local->cont.fstat.ino;
- AFR_STACK_UNWIND (fstat, frame, op_ret, op_errno, buf);
- }
+ AFR_STACK_UNWIND (fstat, frame, op_ret, op_errno, buf);
+ }
- return 0;
+ return 0;
}
int32_t
afr_fstat (call_frame_t *frame, xlator_t *this,
- fd_t *fd)
+ fd_t *fd)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
- int call_child = 0;
+ int call_child = 0;
int32_t read_child = -1;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (fd, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (fd, out);
+ VALIDATE_OR_GOTO (this->private, out);
- priv = this->private;
- VALIDATE_OR_GOTO (priv->children, out);
+ priv = this->private;
+ VALIDATE_OR_GOTO (priv->children, out);
- children = priv->children;
+ children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ frame->local = local;
- VALIDATE_OR_GOTO (fd->inode, out);
+ VALIDATE_OR_GOTO (fd->inode, out);
read_child = afr_read_child (this, fd->inode);
@@ -397,28 +397,28 @@ afr_fstat (call_frame_t *frame, xlator_t *this,
if (call_child == -1) {
op_errno = ENOTCONN;
gf_log (this->name, GF_LOG_DEBUG,
- "no child is up");
- goto out;
- }
+ "no child is up");
+ goto out;
+ }
local->cont.fstat.last_tried = call_child;
}
- local->cont.fstat.ino = fd->inode->ino;
- local->fd = fd_ref (fd);
+ local->cont.fstat.ino = fd->inode->ino;
+ local->fd = fd_ref (fd);
- STACK_WIND_COOKIE (frame, afr_fstat_cbk, (void *) (long) call_child,
- children[call_child],
- children[call_child]->fops->fstat,
- fd);
+ STACK_WIND_COOKIE (frame, afr_fstat_cbk, (void *) (long) call_child,
+ children[call_child],
+ children[call_child]->fops->fstat,
+ fd);
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (fstat, frame, op_ret, op_errno, NULL);
- }
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (fstat, frame, op_ret, op_errno, NULL);
+ }
- return 0;
+ return 0;
}
/* }}} */
@@ -427,85 +427,85 @@ out:
int32_t
afr_readlink_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno,
- const char *buf, struct iatt *sbuf)
+ xlator_t *this, int32_t op_ret, int32_t op_errno,
+ const char *buf, struct iatt *sbuf)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
- int unwind = 1;
- int last_tried = -1;
- int this_try = -1;
+ int unwind = 1;
+ int last_tried = -1;
+ int this_try = -1;
int read_child = -1;
- priv = this->private;
- children = priv->children;
+ priv = this->private;
+ children = priv->children;
- local = frame->local;
+ local = frame->local;
read_child = (long) cookie;
- if (op_ret == -1) {
+ if (op_ret == -1) {
retry:
- last_tried = local->cont.readlink.last_tried;
+ last_tried = local->cont.readlink.last_tried;
- if (all_tried (last_tried, priv->child_count)) {
- goto out;
- }
- this_try = ++local->cont.readlink.last_tried;
+ if (all_tried (last_tried, priv->child_count)) {
+ goto out;
+ }
+ this_try = ++local->cont.readlink.last_tried;
if (this_try == read_child) {
goto retry;
}
- unwind = 0;
- STACK_WIND_COOKIE (frame, afr_readlink_cbk,
- (void *) (long) read_child,
- children[this_try],
- children[this_try]->fops->readlink,
- &local->loc,
- local->cont.readlink.size);
- }
+ unwind = 0;
+ STACK_WIND_COOKIE (frame, afr_readlink_cbk,
+ (void *) (long) read_child,
+ children[this_try],
+ children[this_try]->fops->readlink,
+ &local->loc,
+ local->cont.readlink.size);
+ }
out:
- if (unwind) {
+ if (unwind) {
if (sbuf)
sbuf->ia_ino = local->cont.readlink.ino;
- AFR_STACK_UNWIND (readlink, frame, op_ret, op_errno, buf, sbuf);
- }
+ AFR_STACK_UNWIND (readlink, frame, op_ret, op_errno, buf, sbuf);
+ }
- return 0;
+ return 0;
}
int32_t
afr_readlink (call_frame_t *frame, xlator_t *this,
- loc_t *loc, size_t size)
+ loc_t *loc, size_t size)
{
- afr_private_t * priv = NULL;
- xlator_t ** children = NULL;
- int call_child = 0;
- afr_local_t *local = NULL;
+ afr_private_t * priv = NULL;
+ xlator_t ** children = NULL;
+ int call_child = 0;
+ afr_local_t *local = NULL;
int32_t read_child = -1;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
- priv = this->private;
- VALIDATE_OR_GOTO (priv->children, out);
+ priv = this->private;
+ VALIDATE_OR_GOTO (priv->children, out);
- children = priv->children;
+ children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ frame->local = local;
read_child = afr_read_child (this, loc->inode);
@@ -527,22 +527,22 @@ afr_readlink (call_frame_t *frame, xlator_t *this,
local->cont.readlink.last_tried = call_child;
}
- loc_copy (&local->loc, loc);
+ loc_copy (&local->loc, loc);
- local->cont.readlink.size = size;
+ local->cont.readlink.size = size;
local->cont.readlink.ino = loc->inode->ino;
- STACK_WIND_COOKIE (frame, afr_readlink_cbk,
- (void *) (long) call_child,
- children[call_child], children[call_child]->fops->readlink,
- loc, size);
+ STACK_WIND_COOKIE (frame, afr_readlink_cbk,
+ (void *) (long) call_child,
+ children[call_child], children[call_child]->fops->readlink,
+ loc, size);
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (readlink, frame, op_ret, op_errno, NULL, NULL);
- }
- return 0;
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (readlink, frame, op_ret, op_errno, NULL, NULL);
+ }
+ return 0;
}
@@ -604,61 +604,61 @@ __filter_xattrs (dict_t *dict)
int32_t
afr_getxattr_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno,
- dict_t *dict)
+ xlator_t *this, int32_t op_ret, int32_t op_errno,
+ dict_t *dict)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
- int unwind = 1;
- int last_tried = -1;
- int this_try = -1;
+ int unwind = 1;
+ int last_tried = -1;
+ int this_try = -1;
int read_child = -1;
- priv = this->private;
- children = priv->children;
+ priv = this->private;
+ children = priv->children;
- local = frame->local;
+ local = frame->local;
read_child = (long) cookie;
- if (op_ret == -1) {
+ if (op_ret == -1) {
retry:
- last_tried = local->cont.getxattr.last_tried;
+ last_tried = local->cont.getxattr.last_tried;
- if (all_tried (last_tried, priv->child_count)) {
- goto out;
- }
- this_try = ++local->cont.getxattr.last_tried;
+ if (all_tried (last_tried, priv->child_count)) {
+ goto out;
+ }
+ this_try = ++local->cont.getxattr.last_tried;
if (this_try == read_child) {
goto retry;
}
- unwind = 0;
- STACK_WIND_COOKIE (frame, afr_getxattr_cbk,
- (void *) (long) read_child,
- children[this_try],
- children[this_try]->fops->getxattr,
- &local->loc,
- local->cont.getxattr.name);
- }
+ unwind = 0;
+ STACK_WIND_COOKIE (frame, afr_getxattr_cbk,
+ (void *) (long) read_child,
+ children[this_try],
+ children[this_try]->fops->getxattr,
+ &local->loc,
+ local->cont.getxattr.name);
+ }
out:
- if (unwind) {
+ if (unwind) {
if (op_ret >= 0 && dict)
__filter_xattrs (dict);
- AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict);
- }
+ AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict);
+ }
- return 0;
+ return 0;
}
int32_t
afr_getxattr_unwind (call_frame_t *frame,
- int op_ret, int op_errno, dict_t *dict)
+ int op_ret, int op_errno, dict_t *dict)
{
AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict);
@@ -667,33 +667,33 @@ afr_getxattr_unwind (call_frame_t *frame,
int32_t
afr_getxattr (call_frame_t *frame, xlator_t *this,
- loc_t *loc, const char *name)
+ loc_t *loc, const char *name)
{
- afr_private_t * priv = NULL;
- xlator_t ** children = NULL;
- int call_child = 0;
- afr_local_t * local = NULL;
+ afr_private_t * priv = NULL;
+ xlator_t ** children = NULL;
+ int call_child = 0;
+ afr_local_t * local = NULL;
xlator_list_t * trav = NULL;
xlator_t ** sub_volumes= NULL;
int read_child = -1;
int i = 0;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
- priv = this->private;
- VALIDATE_OR_GOTO (priv->children, out);
+ priv = this->private;
+ VALIDATE_OR_GOTO (priv->children, out);
- children = priv->children;
+ children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ ALLOC_OR_GOTO (local, afr_local_t, out);
+ frame->local = local;
loc_copy (&local->loc, loc);
if (name)
@@ -714,7 +714,7 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
sub_volumes = alloca ( priv->child_count * sizeof (xlator_t *));
for (i = 0, trav = this->children; trav ;
- trav = trav->next, i++) {
+ trav = trav->next, i++) {
*(sub_volumes + i) = trav->xlator;
}
@@ -728,7 +728,7 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
op_errno = EINVAL;
goto out;
- }
+ }
return 0;
}
@@ -741,7 +741,7 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
sub_volumes = alloca ( priv->child_count * sizeof (xlator_t *));
for (i = 0, trav = this->children; trav ;
- trav = trav->next, i++) {
+ trav = trav->next, i++) {
*(sub_volumes + i) = trav->xlator;
@@ -784,17 +784,17 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
}
- STACK_WIND_COOKIE (frame, afr_getxattr_cbk,
- (void *) (long) call_child,
- children[call_child], children[call_child]->fops->getxattr,
- loc, name);
+ STACK_WIND_COOKIE (frame, afr_getxattr_cbk,
+ (void *) (long) call_child,
+ children[call_child], children[call_child]->fops->getxattr,
+ loc, name);
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, NULL);
- }
- return 0;
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, NULL);
+ }
+ return 0;
}
@@ -816,140 +816,140 @@ out:
int32_t
afr_readv_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno,
- struct iovec *vector, int32_t count, struct iatt *buf,
+ xlator_t *this, int32_t op_ret, int32_t op_errno,
+ struct iovec *vector, int32_t count, struct iatt *buf,
struct iobref *iobref)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
- int unwind = 1;
- int last_tried = -1;
- int this_try = -1;
+ int unwind = 1;
+ int last_tried = -1;
+ int this_try = -1;
int read_child = -1;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
- priv = this->private;
- VALIDATE_OR_GOTO (priv->children, out);
+ priv = this->private;
+ VALIDATE_OR_GOTO (priv->children, out);
- children = priv->children;
+ children = priv->children;
- local = frame->local;
+ local = frame->local;
read_child = (long) cookie;
- if (op_ret == -1) {
- retry:
- last_tried = local->cont.readv.last_tried;
-
- if (all_tried (last_tried, priv->child_count)) {
- goto out;
- }
- this_try = ++local->cont.readv.last_tried;
-
- if (this_try == read_child) {
- /*
- skip the read child since if we are here
- we must have already tried that child
- */
- goto retry;
- }
-
- unwind = 0;
-
- STACK_WIND_COOKIE (frame, afr_readv_cbk,
- (void *) (long) read_child,
- children[this_try],
- children[this_try]->fops->readv,
- local->fd, local->cont.readv.size,
- local->cont.readv.offset);
- }
+ if (op_ret == -1) {
+ retry:
+ last_tried = local->cont.readv.last_tried;
+
+ if (all_tried (last_tried, priv->child_count)) {
+ goto out;
+ }
+ this_try = ++local->cont.readv.last_tried;
+
+ if (this_try == read_child) {
+ /*
+ skip the read child since if we are here
+ we must have already tried that child
+ */
+ goto retry;
+ }
+
+ unwind = 0;
+
+ STACK_WIND_COOKIE (frame, afr_readv_cbk,
+ (void *) (long) read_child,
+ children[this_try],
+ children[this_try]->fops->readv,
+ local->fd, local->cont.readv.size,
+ local->cont.readv.offset);
+ }
out:
- if (unwind) {
+ if (unwind) {
if (buf && local)
buf->ia_ino = local->cont.readv.ino;
- AFR_STACK_UNWIND (readv, frame, op_ret, op_errno,
+ AFR_STACK_UNWIND (readv, frame, op_ret, op_errno,
vector, count, buf, iobref);
- }
+ }
- return 0;
+ return 0;
}
int32_t
afr_readv (call_frame_t *frame, xlator_t *this,
- fd_t *fd, size_t size, off_t offset)
+ fd_t *fd, size_t size, off_t offset)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- xlator_t ** children = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
int32_t read_child = -1;
- int call_child = 0;
+ int call_child = 0;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
- VALIDATE_OR_GOTO (fd, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (fd, out);
- priv = this->private;
- children = priv->children;
+ priv = this->private;
+ children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ frame->local = local;
read_child = afr_read_child (this, fd->inode);
if ((read_child >= 0) && (priv->child_up[read_child])) {
call_child = read_child;
- /*
- if read fails from the read child, we try
- all children starting with the first one
- */
+ /*
+ if read fails from the read child, we try
+ all children starting with the first one
+ */
local->cont.readv.last_tried = -1;
} else {
- call_child = afr_first_up_child (priv);
- if (call_child == -1) {
- op_errno = ENOTCONN;
- gf_log (this->name, GF_LOG_DEBUG,
- "no child is up");
- goto out;
- }
+ call_child = afr_first_up_child (priv);
+ if (call_child == -1) {
+ op_errno = ENOTCONN;
+ gf_log (this->name, GF_LOG_DEBUG,
+ "no child is up");
+ goto out;
+ }
- local->cont.readv.last_tried = call_child;
- }
+ local->cont.readv.last_tried = call_child;
+ }
- local->fd = fd_ref (fd);
+ local->fd = fd_ref (fd);
local->cont.readv.ino = fd->inode->ino;
- local->cont.readv.size = size;
- local->cont.readv.offset = offset;
+ local->cont.readv.size = size;
+ local->cont.readv.offset = offset;
- STACK_WIND_COOKIE (frame, afr_readv_cbk,
- (void *) (long) call_child,
- children[call_child],
- children[call_child]->fops->readv,
- fd, size, offset);
+ STACK_WIND_COOKIE (frame, afr_readv_cbk,
+ (void *) (long) call_child,
+ children[call_child],
+ children[call_child]->fops->readv,
+ fd, size, offset);
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (readv, frame, op_ret, op_errno, NULL, 0, NULL,
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (readv, frame, op_ret, op_errno, NULL, 0, NULL,
NULL);
- }
- return 0;
+ }
+ return 0;
}
/* }}} */
diff --git a/xlators/cluster/afr/src/afr-open.c b/xlators/cluster/afr/src/afr-open.c
index 8c87ce89328..5b96c4e3464 100644
--- a/xlators/cluster/afr/src/afr-open.c
+++ b/xlators/cluster/afr/src/afr-open.c
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2007-2010 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2007-2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
#include <libgen.h>
@@ -57,24 +57,24 @@
int
-afr_open_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+afr_open_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
struct iatt *postbuf)
{
- afr_local_t * local = frame->local;
+ afr_local_t * local = frame->local;
- AFR_STACK_UNWIND (open, frame, local->op_ret, local->op_errno,
- local->fd);
- return 0;
+ AFR_STACK_UNWIND (open, frame, local->op_ret, local->op_errno,
+ local->fd);
+ return 0;
}
int
afr_open_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret, int32_t op_errno,
- fd_t *fd)
+ xlator_t *this, int32_t op_ret, int32_t op_errno,
+ fd_t *fd)
{
- afr_local_t * local = NULL;
+ afr_local_t * local = NULL;
int child_index = (long) cookie;
@@ -83,18 +83,18 @@ afr_open_cbk (call_frame_t *frame, void *cookie,
int ret = 0;
- int call_count = -1;
+ int call_count = -1;
- local = frame->local;
+ local = frame->local;
- LOCK (&frame->lock);
- {
- if (op_ret == -1) {
- local->op_errno = op_errno;
- }
+ LOCK (&frame->lock);
+ {
+ if (op_ret == -1) {
+ local->op_errno = op_errno;
+ }
- if (op_ret >= 0) {
- local->op_ret = op_ret;
+ if (op_ret >= 0) {
+ local->op_ret = op_ret;
local->success_count++;
ret = afr_fd_ctx_set (this, fd);
@@ -124,26 +124,26 @@ afr_open_cbk (call_frame_t *frame, void *cookie,
fd_ctx->opened_on[child_index] = 1;
fd_ctx->flags = local->cont.open.flags;
fd_ctx->wbflags = local->cont.open.wbflags;
- }
- }
+ }
+ }
unlock:
- UNLOCK (&frame->lock);
+ UNLOCK (&frame->lock);
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0) {
- if ((local->cont.open.flags & O_TRUNC)
- && (local->op_ret >= 0)) {
- STACK_WIND (frame, afr_open_ftruncate_cbk,
- this, this->fops->ftruncate,
- fd, 0);
- } else {
+ if (call_count == 0) {
+ if ((local->cont.open.flags & O_TRUNC)
+ && (local->op_ret >= 0)) {
+ STACK_WIND (frame, afr_open_ftruncate_cbk,
+ this, this->fops->ftruncate,
+ fd, 0);
+ } else {
AFR_STACK_UNWIND (open, frame, local->op_ret,
local->op_errno, local->fd);
- }
- }
+ }
+ }
- return 0;
+ return 0;
}
@@ -151,67 +151,67 @@ int
afr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
fd_t *fd, int32_t wbflags)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
- int i = 0;
- int ret = -1;
+ int i = 0;
+ int ret = -1;
- int32_t call_count = 0;
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- int32_t wind_flags = flags & (~O_TRUNC);
+ int32_t call_count = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ int32_t wind_flags = flags & (~O_TRUNC);
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
- VALIDATE_OR_GOTO (loc, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (loc, out);
- priv = this->private;
+ priv = this->private;
if (afr_is_split_brain (this, loc->inode)) {
- /* self-heal failed */
- op_errno = EIO;
- goto out;
- }
+ /* self-heal failed */
+ op_errno = EIO;
+ goto out;
+ }
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (local, afr_local_t, out);
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
- goto out;
- }
+ ret = AFR_LOCAL_INIT (local, priv);
+ if (ret < 0) {
+ op_errno = -ret;
+ goto out;
+ }
- frame->local = local;
- call_count = local->call_count;
+ frame->local = local;
+ call_count = local->call_count;
loc_copy (&local->loc, loc);
- local->cont.open.flags = flags;
+ local->cont.open.flags = flags;
local->cont.open.wbflags = wbflags;
- local->fd = fd_ref (fd);
+ local->fd = fd_ref (fd);
- for (i = 0; i < priv->child_count; i++) {
- if (local->child_up[i]) {
- STACK_WIND_COOKIE (frame, afr_open_cbk, (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->open,
- loc, wind_flags, fd, wbflags);
+ for (i = 0; i < priv->child_count; i++) {
+ if (local->child_up[i]) {
+ STACK_WIND_COOKIE (frame, afr_open_cbk, (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->open,
+ loc, wind_flags, fd, wbflags);
- if (!--call_count)
- break;
- }
- }
+ if (!--call_count)
+ break;
+ }
+ }
- op_ret = 0;
+ op_ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (open, frame, op_ret, op_errno, fd);
- }
+ if (op_ret == -1) {
+ AFR_STACK_UNWIND (open, frame, op_ret, op_errno, fd);
+ }
- return 0;
+ return 0;
}
@@ -447,7 +447,7 @@ int
afr_openfd_flush_done (call_frame_t *frame, xlator_t *this)
{
afr_private_t *priv = NULL;
- afr_local_t *local = NULL;
+ afr_local_t *local = NULL;
uint64_t ctx;
afr_fd_ctx_t * fd_ctx = NULL;
@@ -455,7 +455,7 @@ afr_openfd_flush_done (call_frame_t *frame, xlator_t *this)
int _ret = -1;
priv = this->private;
- local = frame->local;
+ local = frame->local;
LOCK (&local->fd->lock);
{
@@ -481,7 +481,7 @@ out:
fd_unref (local->fd);
local->openfd_flush_cbk (frame, this);
- return 0;
+ return 0;
}
@@ -489,11 +489,11 @@ out:
int
afr_openfd_xaction (call_frame_t *frame, xlator_t *this, fd_t *fd)
{
- afr_local_t * local = NULL;
+ afr_local_t * local = NULL;
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (this->private, out);
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (this->private, out);
local = frame->local;
@@ -512,7 +512,7 @@ afr_openfd_xaction (call_frame_t *frame, xlator_t *this, fd_t *fd)
afr_transaction (frame, this, AFR_DATA_TRANSACTION);
out:
- return 0;
+ return 0;
}
diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.c b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
index f72da774127..4bb70915e84 100644
--- a/xlators/cluster/afr/src/afr-self-heal-algorithm.c
+++ b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
@@ -108,8 +108,8 @@ sh_full_loop_return (call_frame_t *rw_frame, xlator_t *this, off_t offset)
afr_self_heal_t * rw_sh = NULL;
call_frame_t *sh_frame = NULL;
- afr_local_t * sh_local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * sh_local = NULL;
+ afr_self_heal_t *sh = NULL;
afr_sh_algo_full_private_t *sh_priv = NULL;
rw_local = rw_frame->local;
@@ -133,52 +133,52 @@ sh_full_write_cbk (call_frame_t *rw_frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
struct iatt *postbuf)
{
- afr_private_t * priv = NULL;
- afr_local_t * rw_local = NULL;
- afr_self_heal_t *rw_sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * rw_local = NULL;
+ afr_self_heal_t *rw_sh = NULL;
call_frame_t *sh_frame = NULL;
- afr_local_t * sh_local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * sh_local = NULL;
+ afr_self_heal_t *sh = NULL;
- int child_index = (long) cookie;
- int call_count = 0;
+ int child_index = (long) cookie;
+ int call_count = 0;
- priv = this->private;
+ priv = this->private;
- rw_local = rw_frame->local;
- rw_sh = &rw_local->self_heal;
+ rw_local = rw_frame->local;
+ rw_sh = &rw_local->self_heal;
sh_frame = rw_sh->sh_frame;
sh_local = sh_frame->local;
sh = &sh_local->self_heal;
- gf_log (this->name, GF_LOG_TRACE,
- "wrote %d bytes of data from %s to child %d, offset %"PRId64"",
- op_ret, sh_local->loc.path, child_index,
+ gf_log (this->name, GF_LOG_TRACE,
+ "wrote %d bytes of data from %s to child %d, offset %"PRId64"",
+ op_ret, sh_local->loc.path, child_index,
rw_sh->offset - op_ret);
- LOCK (&sh_frame->lock);
- {
- if (op_ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
- "write to %s failed on subvolume %s (%s)",
- sh_local->loc.path,
- priv->children[child_index]->name,
- strerror (op_errno));
-
- sh->op_failed = 1;
- }
- }
- UNLOCK (&sh_frame->lock);
+ LOCK (&sh_frame->lock);
+ {
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "write to %s failed on subvolume %s (%s)",
+ sh_local->loc.path,
+ priv->children[child_index]->name,
+ strerror (op_errno));
+
+ sh->op_failed = 1;
+ }
+ }
+ UNLOCK (&sh_frame->lock);
- call_count = afr_frame_return (rw_frame);
+ call_count = afr_frame_return (rw_frame);
- if (call_count == 0) {
- sh_full_loop_return (rw_frame, this, rw_sh->offset - op_ret);
- }
+ if (call_count == 0) {
+ sh_full_loop_return (rw_frame, this, rw_sh->offset - op_ret);
+ }
- return 0;
+ return 0;
}
@@ -188,91 +188,91 @@ sh_full_read_cbk (call_frame_t *rw_frame, void *cookie,
struct iovec *vector, int32_t count, struct iatt *buf,
struct iobref *iobref)
{
- afr_private_t * priv = NULL;
- afr_local_t * rw_local = NULL;
- afr_self_heal_t *rw_sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * rw_local = NULL;
+ afr_self_heal_t *rw_sh = NULL;
call_frame_t *sh_frame = NULL;
- afr_local_t * sh_local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * sh_local = NULL;
+ afr_self_heal_t *sh = NULL;
- int i = 0;
- int call_count = 0;
+ int i = 0;
+ int call_count = 0;
- off_t offset = (long) cookie;
+ off_t offset = (long) cookie;
- priv = this->private;
- rw_local = rw_frame->local;
- rw_sh = &rw_local->self_heal;
+ priv = this->private;
+ rw_local = rw_frame->local;
+ rw_sh = &rw_local->self_heal;
sh_frame = rw_sh->sh_frame;
sh_local = sh_frame->local;
sh = &sh_local->self_heal;
- call_count = sh->active_sinks;
+ call_count = sh->active_sinks;
rw_local->call_count = call_count;
- gf_log (this->name, GF_LOG_TRACE,
- "read %d bytes of data from %s, offset %"PRId64"",
- op_ret, sh_local->loc.path, offset);
+ gf_log (this->name, GF_LOG_TRACE,
+ "read %d bytes of data from %s, offset %"PRId64"",
+ op_ret, sh_local->loc.path, offset);
- if (op_ret <= 0) {
+ if (op_ret <= 0) {
sh->op_failed = 1;
sh_full_loop_return (rw_frame, this, offset);
- return 0;
- }
+ return 0;
+ }
- rw_sh->offset += op_ret;
+ rw_sh->offset += op_ret;
- if (sh->file_has_holes) {
- if (iov_0filled (vector, count) == 0) {
- /* the iter function depends on the
- sh->offset already being updated
- above
- */
+ if (sh->file_has_holes) {
+ if (iov_0filled (vector, count) == 0) {
+ /* the iter function depends on the
+ sh->offset already being updated
+ above
+ */
sh_full_loop_return (rw_frame, this, offset);
- goto out;
- }
- }
+ goto out;
+ }
+ }
- for (i = 0; i < priv->child_count; i++) {
- if (sh->sources[i] || !sh_local->child_up[i])
- continue;
+ for (i = 0; i < priv->child_count; i++) {
+ if (sh->sources[i] || !sh_local->child_up[i])
+ continue;
- /* this is a sink, so write to it */
+ /* this is a sink, so write to it */
- STACK_WIND_COOKIE (rw_frame, sh_full_write_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->writev,
- sh->healing_fd, vector, count, offset,
+ STACK_WIND_COOKIE (rw_frame, sh_full_write_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->writev,
+ sh->healing_fd, vector, count, offset,
iobref);
- if (!--call_count)
- break;
- }
+ if (!--call_count)
+ break;
+ }
out:
- return 0;
+ return 0;
}
static int
sh_full_read_write (call_frame_t *frame, xlator_t *this, off_t offset)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- afr_local_t * rw_local = NULL;
- afr_self_heal_t *rw_sh = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ afr_local_t * rw_local = NULL;
+ afr_self_heal_t *rw_sh = NULL;
+ afr_self_heal_t *sh = NULL;
call_frame_t *rw_frame = NULL;
int32_t op_errno = 0;
- priv = this->private;
+ priv = this->private;
local = frame->local;
sh = &local->self_heal;
@@ -283,17 +283,17 @@ sh_full_read_write (call_frame_t *frame, xlator_t *this, off_t offset)
ALLOC_OR_GOTO (rw_local, afr_local_t, out);
rw_frame->local = rw_local;
- rw_sh = &rw_local->self_heal;
+ rw_sh = &rw_local->self_heal;
rw_sh->offset = offset;
rw_sh->sh_frame = frame;
- STACK_WIND_COOKIE (rw_frame, sh_full_read_cbk,
- (void *) (long) offset,
- priv->children[sh->source],
- priv->children[sh->source]->fops->readv,
- sh->healing_fd, sh->block_size,
- offset);
+ STACK_WIND_COOKIE (rw_frame, sh_full_read_cbk,
+ (void *) (long) offset,
+ priv->children[sh->source],
+ priv->children[sh->source]->fops->readv,
+ sh->healing_fd, sh->block_size,
+ offset);
return 0;
out:
@@ -301,16 +301,16 @@ out:
sh_full_loop_driver (frame, this, _gf_false);
- return 0;
+ return 0;
}
static int
sh_full_loop_driver (call_frame_t *frame, xlator_t *this, gf_boolean_t is_first_call)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ afr_self_heal_t *sh = NULL;
afr_sh_algo_full_private_t *sh_priv = NULL;
gf_boolean_t is_driver_done = _gf_false;
blksize_t block_size = 0;
@@ -318,9 +318,9 @@ sh_full_loop_driver (call_frame_t *frame, xlator_t *this, gf_boolean_t is_first_
int loop = 0;
- priv = this->private;
- local = frame->local;
- sh = &local->self_heal;
+ priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
sh_priv = sh->private;
LOCK (&sh_priv->lock);
@@ -330,8 +330,8 @@ sh_full_loop_driver (call_frame_t *frame, xlator_t *this, gf_boolean_t is_first_
offset = sh_priv->offset;
block_size = sh->block_size;
while ((sh->op_failed == 0) &&
- (sh_priv->loops_running < priv->data_self_heal_window_size)
- && (sh_priv->offset < sh->file_size)) {
+ (sh_priv->loops_running < priv->data_self_heal_window_size)
+ && (sh_priv->offset < sh->file_size)) {
loop++;
gf_log (this->name, GF_LOG_TRACE,
@@ -365,7 +365,7 @@ sh_full_loop_driver (call_frame_t *frame, xlator_t *this, gf_boolean_t is_first_
sh_full_loop_driver_done (frame, this);
}
- return 0;
+ return 0;
}
@@ -545,8 +545,8 @@ sh_diff_loop_return (call_frame_t *rw_frame, xlator_t *this,
afr_self_heal_t * rw_sh = NULL;
call_frame_t *sh_frame = NULL;
- afr_local_t * sh_local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * sh_local = NULL;
+ afr_self_heal_t *sh = NULL;
afr_sh_algo_diff_private_t *sh_priv = NULL;
priv = this->private;
@@ -575,24 +575,24 @@ sh_diff_write_cbk (call_frame_t *rw_frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *buf,
struct iatt *postbuf)
{
- afr_private_t * priv = NULL;
- afr_local_t * rw_local = NULL;
- afr_self_heal_t * rw_sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * rw_local = NULL;
+ afr_self_heal_t * rw_sh = NULL;
call_frame_t *sh_frame = NULL;
- afr_local_t * sh_local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * sh_local = NULL;
+ afr_self_heal_t *sh = NULL;
afr_sh_algo_diff_private_t *sh_priv;
struct sh_diff_loop_state *loop_state;
- int call_count = 0;
+ int call_count = 0;
int child_index = 0;
int loop_index = 0;
- priv = this->private;
- rw_local = rw_frame->local;
- rw_sh = &rw_local->self_heal;
+ priv = this->private;
+ rw_local = rw_frame->local;
+ rw_sh = &rw_local->self_heal;
sh_frame = rw_sh->sh_frame;
sh_local = sh_frame->local;
@@ -603,32 +603,32 @@ sh_diff_write_cbk (call_frame_t *rw_frame, void *cookie, xlator_t *this,
loop_index = __loop_index ((uint32_t) (long) cookie);
loop_state = sh_priv->loops[loop_index];
- gf_log (this->name, GF_LOG_TRACE,
- "wrote %d bytes of data from %s to child %d, offset %"PRId64"",
- op_ret, sh_local->loc.path, child_index,
+ gf_log (this->name, GF_LOG_TRACE,
+ "wrote %d bytes of data from %s to child %d, offset %"PRId64"",
+ op_ret, sh_local->loc.path, child_index,
loop_state->offset);
- LOCK (&sh_frame->lock);
- {
- if (op_ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
- "write to %s failed on subvolume %s (%s)",
- sh_local->loc.path,
- priv->children[child_index]->name,
- strerror (op_errno));
-
- sh->op_failed = 1;
- }
- }
- UNLOCK (&sh_frame->lock);
+ LOCK (&sh_frame->lock);
+ {
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "write to %s failed on subvolume %s (%s)",
+ sh_local->loc.path,
+ priv->children[child_index]->name,
+ strerror (op_errno));
+
+ sh->op_failed = 1;
+ }
+ }
+ UNLOCK (&sh_frame->lock);
- call_count = afr_frame_return (rw_frame);
+ call_count = afr_frame_return (rw_frame);
- if (call_count == 0) {
- sh_diff_loop_return (rw_frame, this, loop_state);
- }
+ if (call_count == 0) {
+ sh_diff_loop_return (rw_frame, this, loop_state);
+ }
- return 0;
+ return 0;
}
@@ -638,27 +638,27 @@ sh_diff_read_cbk (call_frame_t *rw_frame, void *cookie,
struct iovec *vector, int32_t count, struct iatt *buf,
struct iobref *iobref)
{
- afr_private_t * priv = NULL;
- afr_local_t * rw_local = NULL;
- afr_self_heal_t * rw_sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * rw_local = NULL;
+ afr_self_heal_t * rw_sh = NULL;
afr_sh_algo_diff_private_t * sh_priv = NULL;
call_frame_t *sh_frame = NULL;
- afr_local_t * sh_local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * sh_local = NULL;
+ afr_self_heal_t *sh = NULL;
int loop_index;
struct sh_diff_loop_state *loop_state;
uint32_t wcookie;
- int i = 0;
- int call_count = 0;
+ int i = 0;
+ int call_count = 0;
- priv = this->private;
- rw_local = rw_frame->local;
- rw_sh = &rw_local->self_heal;
+ priv = this->private;
+ rw_local = rw_frame->local;
+ rw_sh = &rw_local->self_heal;
sh_frame = rw_sh->sh_frame;
sh_local = sh_frame->local;
@@ -668,31 +668,31 @@ sh_diff_read_cbk (call_frame_t *rw_frame, void *cookie,
loop_index = __loop_index ((uint32_t) (long) cookie);
loop_state = sh_priv->loops[loop_index];
- call_count = sh_diff_number_of_writes_needed (loop_state->write_needed,
+ call_count = sh_diff_number_of_writes_needed (loop_state->write_needed,
priv->child_count);
- rw_local->call_count = call_count;
+ rw_local->call_count = call_count;
- gf_log (this->name, GF_LOG_TRACE,
- "read %d bytes of data from %s, offset %"PRId64"",
- op_ret, sh_local->loc.path, loop_state->offset);
+ gf_log (this->name, GF_LOG_TRACE,
+ "read %d bytes of data from %s, offset %"PRId64"",
+ op_ret, sh_local->loc.path, loop_state->offset);
- if ((op_ret <= 0) ||
+ if ((op_ret <= 0) ||
(call_count == 0)) {
sh_diff_loop_return (rw_frame, this, loop_state);
- return 0;
- }
+ return 0;
+ }
- if (sh->file_has_holes) {
- if (iov_0filled (vector, count) == 0) {
+ if (sh->file_has_holes) {
+ if (iov_0filled (vector, count) == 0) {
sh_diff_loop_return (rw_frame, this, loop_state);
- goto out;
- }
- }
+ goto out;
+ }
+ }
- for (i = 0; i < priv->child_count; i++) {
+ for (i = 0; i < priv->child_count; i++) {
if (loop_state->write_needed[i]) {
wcookie = __make_cookie (loop_index, i);
@@ -709,7 +709,7 @@ sh_diff_read_cbk (call_frame_t *rw_frame, void *cookie,
}
out:
- return 0;
+ return 0;
}
@@ -717,22 +717,22 @@ static int
sh_diff_read (call_frame_t *rw_frame, xlator_t *this,
int loop_index)
{
- afr_private_t * priv = NULL;
- afr_local_t * rw_local = NULL;
- afr_self_heal_t * rw_sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * rw_local = NULL;
+ afr_self_heal_t * rw_sh = NULL;
afr_sh_algo_diff_private_t * sh_priv = NULL;
struct sh_diff_loop_state *loop_state;
call_frame_t *sh_frame = NULL;
- afr_local_t * sh_local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * sh_local = NULL;
+ afr_self_heal_t *sh = NULL;
uint32_t cookie;
- priv = this->private;
- rw_local = rw_frame->local;
- rw_sh = &rw_local->self_heal;
+ priv = this->private;
+ rw_local = rw_frame->local;
+ rw_sh = &rw_local->self_heal;
sh_frame = rw_sh->sh_frame;
sh_local = sh_frame->local;
@@ -743,14 +743,14 @@ sh_diff_read (call_frame_t *rw_frame, xlator_t *this,
cookie = __make_cookie (loop_index, sh->source);
- STACK_WIND_COOKIE (rw_frame, sh_diff_read_cbk,
- (void *) (long) cookie,
- priv->children[sh->source],
- priv->children[sh->source]->fops->readv,
- sh->healing_fd, sh_priv->block_size,
- loop_state->offset);
+ STACK_WIND_COOKIE (rw_frame, sh_diff_read_cbk,
+ (void *) (long) cookie,
+ priv->children[sh->source],
+ priv->children[sh->source]->fops->readv,
+ sh->healing_fd, sh_priv->block_size,
+ loop_state->offset);
- return 0;
+ return 0;
}
@@ -759,13 +759,13 @@ sh_diff_checksum_cbk (call_frame_t *rw_frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno,
uint32_t weak_checksum, uint8_t *strong_checksum)
{
- afr_private_t * priv = NULL;
- afr_local_t * rw_local = NULL;
- afr_self_heal_t *rw_sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * rw_local = NULL;
+ afr_self_heal_t *rw_sh = NULL;
call_frame_t *sh_frame = NULL;
- afr_local_t * sh_local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * sh_local = NULL;
+ afr_self_heal_t *sh = NULL;
afr_sh_algo_diff_private_t * sh_priv = NULL;
@@ -777,10 +777,10 @@ sh_diff_checksum_cbk (call_frame_t *rw_frame, void *cookie, xlator_t *this,
int i = 0;
int write_needed = 0;
- priv = this->private;
+ priv = this->private;
- rw_local = rw_frame->local;
- rw_sh = &rw_local->self_heal;
+ rw_local = rw_frame->local;
+ rw_sh = &rw_local->self_heal;
sh_frame = rw_sh->sh_frame;
sh_local = sh_frame->local;
@@ -817,8 +817,8 @@ sh_diff_checksum_cbk (call_frame_t *rw_frame, void *cookie, xlator_t *this,
loop_state->checksum + (sh->source * MD5_DIGEST_LEN),
MD5_DIGEST_LEN)) {
/*
- Checksums differ, so this block
- must be written to this sink
+ Checksums differ, so this block
+ must be written to this sink
*/
gf_log (this->name, GF_LOG_TRACE,
@@ -880,11 +880,11 @@ sh_diff_find_unused_loop (afr_sh_algo_diff_private_t *sh_priv, int max)
static int
sh_diff_checksum (call_frame_t *frame, xlator_t *this, off_t offset)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- afr_local_t * rw_local = NULL;
- afr_self_heal_t * sh = NULL;
- afr_self_heal_t * rw_sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ afr_local_t * rw_local = NULL;
+ afr_self_heal_t * sh = NULL;
+ afr_self_heal_t * rw_sh = NULL;
afr_sh_algo_diff_private_t * sh_priv = NULL;
@@ -899,9 +899,9 @@ sh_diff_checksum (call_frame_t *frame, xlator_t *this, off_t offset)
int call_count = 0;
int i = 0;
- priv = this->private;
- local = frame->local;
- sh = &local->self_heal;
+ priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
sh_priv = sh->private;
@@ -912,7 +912,7 @@ sh_diff_checksum (call_frame_t *frame, xlator_t *this, off_t offset)
ALLOC_OR_GOTO (rw_local, afr_local_t, out);
rw_frame->local = rw_local;
- rw_sh = &rw_local->self_heal;
+ rw_sh = &rw_local->self_heal;
rw_sh->offset = sh->offset;
rw_sh->sh_frame = frame;
@@ -971,9 +971,9 @@ sh_diff_loop_driver (call_frame_t *frame, xlator_t *this,
gf_boolean_t is_first_call,
struct sh_diff_loop_state *loop_state)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- afr_self_heal_t * sh = NULL;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ afr_self_heal_t * sh = NULL;
afr_sh_algo_diff_private_t *sh_priv = NULL;
gf_boolean_t is_driver_done = _gf_false;
blksize_t block_size = 0;
@@ -983,9 +983,9 @@ sh_diff_loop_driver (call_frame_t *frame, xlator_t *this,
off_t offset = 0;
char sh_type_str[256] = {0,};
- priv = this->private;
- local = frame->local;
- sh = &local->self_heal;
+ priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
sh_priv = sh->private;
afr_self_heal_type_str_get(sh, sh_type_str, sizeof(sh_type_str));
@@ -999,8 +999,8 @@ sh_diff_loop_driver (call_frame_t *frame, xlator_t *this,
offset = sh_priv->offset;
block_size = sh_priv->block_size;
while ((0 == sh->op_failed) &&
- (sh_priv->loops_running < priv->data_self_heal_window_size)
- && (sh_priv->offset < sh->file_size)) {
+ (sh_priv->loops_running < priv->data_self_heal_window_size)
+ && (sh_priv->offset < sh->file_size)) {
loop++;
gf_log (this->name, GF_LOG_TRACE,
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 0fd8dae69f9..ca7dd92d8ed 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
#include <libgen.h>
@@ -53,75 +53,75 @@
int
afr_sh_data_done (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- /*
- TODO: cleanup sh->*
- */
+ /*
+ TODO: cleanup sh->*
+ */
if (sh->healing_fd && !sh->healing_fd_opened) {
/* unref only if we created the fd ourselves */
- fd_unref (sh->healing_fd);
- sh->healing_fd = NULL;
+ fd_unref (sh->healing_fd);
+ sh->healing_fd = NULL;
}
/* for (i = 0; i < priv->child_count; i++) */
/* sh->locked_nodes[i] = 0; */
- gf_log (this->name, GF_LOG_TRACE,
- "self heal of %s completed",
- local->loc.path);
+ gf_log (this->name, GF_LOG_TRACE,
+ "self heal of %s completed",
+ local->loc.path);
- sh->completion_cbk (frame, this);
+ sh->completion_cbk (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_data_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- afr_local_t *local = NULL;
- afr_private_t *priv = NULL;
- int call_count = 0;
+ afr_local_t *local = NULL;
+ afr_private_t *priv = NULL;
+ int call_count = 0;
int child_index = (long) cookie;
- local = frame->local;
- priv = this->private;
+ local = frame->local;
+ priv = this->private;
- LOCK (&frame->lock);
- {
+ LOCK (&frame->lock);
+ {
if (op_ret == -1) {
gf_log (this->name, GF_LOG_DEBUG,
"flush or setattr failed on %s on subvolume %s: %s",
local->loc.path, priv->children[child_index]->name,
strerror (op_errno));
}
- }
- UNLOCK (&frame->lock);
+ }
+ UNLOCK (&frame->lock);
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0) {
- afr_sh_data_done (frame, this);
- }
+ if (call_count == 0) {
+ afr_sh_data_done (frame, this);
+ }
- return 0;
+ return 0;
}
int
afr_sh_data_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *statpre, struct iatt *statpost)
+ int32_t op_ret, int32_t op_errno, struct iatt *statpre, struct iatt *statpost)
{
afr_sh_data_flush_cbk (frame, cookie, this, op_ret, op_errno);
@@ -132,12 +132,12 @@ afr_sh_data_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int
afr_sh_data_close (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_private_t *priv = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t *local = NULL;
+ afr_private_t *priv = NULL;
+ afr_self_heal_t *sh = NULL;
- int i = 0;
- int call_count = 0;
+ int i = 0;
+ int call_count = 0;
int source = 0;
int32_t valid = 0;
@@ -151,10 +151,10 @@ afr_sh_data_close (call_frame_t *frame, xlator_t *this)
valid |= (GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME);
- stbuf.ia_atime = sh->buf[source].ia_atime;
- stbuf.ia_atime_nsec = sh->buf[source].ia_atime_nsec;
- stbuf.ia_mtime = sh->buf[source].ia_mtime;
- stbuf.ia_mtime_nsec = sh->buf[source].ia_mtime_nsec;
+ stbuf.ia_atime = sh->buf[source].ia_atime;
+ stbuf.ia_atime_nsec = sh->buf[source].ia_atime_nsec;
+ stbuf.ia_mtime = sh->buf[source].ia_mtime;
+ stbuf.ia_mtime_nsec = sh->buf[source].ia_mtime_nsec;
if (sh->healing_fd_opened) {
/* not our job to close the fd */
@@ -163,25 +163,25 @@ afr_sh_data_close (call_frame_t *frame, xlator_t *this)
return 0;
}
- if (!sh->healing_fd) {
- afr_sh_data_done (frame, this);
- return 0;
- }
+ if (!sh->healing_fd) {
+ afr_sh_data_done (frame, this);
+ return 0;
+ }
- call_count = (sh->active_sinks + 1) * 2;
- local->call_count = call_count;
+ call_count = (sh->active_sinks + 1) * 2;
+ local->call_count = call_count;
- /* closed source */
- gf_log (this->name, GF_LOG_TRACE,
- "closing fd of %s on %s",
- local->loc.path, priv->children[sh->source]->name);
+ /* closed source */
+ gf_log (this->name, GF_LOG_TRACE,
+ "closing fd of %s on %s",
+ local->loc.path, priv->children[sh->source]->name);
- STACK_WIND_COOKIE (frame, afr_sh_data_flush_cbk,
- (void *) (long) sh->source,
- priv->children[sh->source],
- priv->children[sh->source]->fops->flush,
- sh->healing_fd);
- call_count--;
+ STACK_WIND_COOKIE (frame, afr_sh_data_flush_cbk,
+ (void *) (long) sh->source,
+ priv->children[sh->source],
+ priv->children[sh->source]->fops->flush,
+ sh->healing_fd);
+ call_count--;
STACK_WIND_COOKIE (frame, afr_sh_data_setattr_cbk,
(void *) (long) sh->source,
@@ -194,69 +194,69 @@ afr_sh_data_close (call_frame_t *frame, xlator_t *this)
if (call_count == 0)
return 0;
- for (i = 0; i < priv->child_count; i++) {
- if (sh->sources[i] || !local->child_up[i])
- continue;
+ for (i = 0; i < priv->child_count; i++) {
+ if (sh->sources[i] || !local->child_up[i])
+ continue;
- gf_log (this->name, GF_LOG_TRACE,
- "closing fd of %s on %s",
- local->loc.path, priv->children[i]->name);
+ gf_log (this->name, GF_LOG_TRACE,
+ "closing fd of %s on %s",
+ local->loc.path, priv->children[i]->name);
- STACK_WIND_COOKIE (frame, afr_sh_data_flush_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->flush,
- sh->healing_fd);
+ STACK_WIND_COOKIE (frame, afr_sh_data_flush_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->flush,
+ sh->healing_fd);
call_count--;
STACK_WIND_COOKIE (frame, afr_sh_data_setattr_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->setattr,
- &local->loc, &stbuf, valid);
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->setattr,
+ &local->loc, &stbuf, valid);
- if (!--call_count)
- break;
- }
+ if (!--call_count)
+ break;
+ }
- return 0;
+ return 0;
}
int
afr_sh_data_unlck_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- afr_local_t * local = NULL;
- int call_count = 0;
- int child_index = (long) cookie;
-
-
- local = frame->local;
-
- LOCK (&frame->lock);
- {
- if (op_ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
- "locking inode of %s on child %d failed: %s",
- local->loc.path, child_index,
- strerror (op_errno));
- } else {
- gf_log (this->name, GF_LOG_TRACE,
- "inode of %s on child %d locked",
- local->loc.path, child_index);
- }
- }
- UNLOCK (&frame->lock);
-
- call_count = afr_frame_return (frame);
-
- if (call_count == 0) {
- afr_sh_data_close (frame, this);
- }
-
- return 0;
+ afr_local_t * local = NULL;
+ int call_count = 0;
+ int child_index = (long) cookie;
+
+
+ local = frame->local;
+
+ LOCK (&frame->lock);
+ {
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "locking inode of %s on child %d failed: %s",
+ local->loc.path, child_index,
+ strerror (op_errno));
+ } else {
+ gf_log (this->name, GF_LOG_TRACE,
+ "inode of %s on child %d locked",
+ local->loc.path, child_index);
+ }
+ }
+ UNLOCK (&frame->lock);
+
+ call_count = afr_frame_return (frame);
+
+ if (call_count == 0) {
+ afr_sh_data_close (frame, this);
+ }
+
+ return 0;
}
@@ -265,197 +265,197 @@ afr_sh_data_unlock (call_frame_t *frame, xlator_t *this)
{
afr_local_t *local = NULL;
afr_internal_lock_t *int_lock = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_self_heal_t *sh = NULL;
local = frame->local;
int_lock = &local->internal_lock;
- sh = &local->self_heal;
+ sh = &local->self_heal;
GF_ASSERT (!sh->data_lock_held);
int_lock->lock_cbk = afr_sh_data_close;
afr_unlock (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_data_finish (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
- local = frame->local;
- sh = &local->self_heal;
+ local = frame->local;
+ sh = &local->self_heal;
- gf_log (this->name, GF_LOG_TRACE,
- "finishing data selfheal of %s", local->loc.path);
+ gf_log (this->name, GF_LOG_TRACE,
+ "finishing data selfheal of %s", local->loc.path);
if (!sh->data_lock_held)
afr_sh_data_unlock (frame, this);
else
afr_sh_data_close (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_data_erase_pending_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret,
- int32_t op_errno, dict_t *xattr)
+ xlator_t *this, int32_t op_ret,
+ int32_t op_errno, dict_t *xattr)
{
- int call_count = 0;
+ int call_count = 0;
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0)
- afr_sh_data_finish (frame, this);
+ if (call_count == 0)
+ afr_sh_data_finish (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_data_erase_pending (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int call_count = 0;
- int i = 0;
- dict_t **erase_xattr = NULL;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int call_count = 0;
+ int i = 0;
+ dict_t **erase_xattr = NULL;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success,
+ afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success,
priv->child_count, AFR_DATA_TRANSACTION);
- erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
- gf_afr_mt_dict_t);
-
- for (i = 0; i < priv->child_count; i++) {
- if (sh->xattr[i]) {
- call_count++;
-
- erase_xattr[i] = get_new_dict();
- dict_ref (erase_xattr[i]);
- }
- }
-
- afr_sh_delta_to_xattr (priv, sh->delta_matrix, erase_xattr,
- priv->child_count, AFR_DATA_TRANSACTION);
-
- local->call_count = call_count;
- for (i = 0; i < priv->child_count; i++) {
- if (!erase_xattr[i])
- continue;
-
- gf_log (this->name, GF_LOG_TRACE,
- "erasing pending flags from %s on %s",
- local->loc.path, priv->children[i]->name);
-
- STACK_WIND_COOKIE (frame, afr_sh_data_erase_pending_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->fxattrop,
- sh->healing_fd,
- GF_XATTROP_ADD_ARRAY, erase_xattr[i]);
- if (!--call_count)
- break;
- }
-
- for (i = 0; i < priv->child_count; i++) {
- if (erase_xattr[i]) {
- dict_unref (erase_xattr[i]);
- }
- }
- GF_FREE (erase_xattr);
-
- return 0;
+ erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
+ gf_afr_mt_dict_t);
+
+ for (i = 0; i < priv->child_count; i++) {
+ if (sh->xattr[i]) {
+ call_count++;
+
+ erase_xattr[i] = get_new_dict();
+ dict_ref (erase_xattr[i]);
+ }
+ }
+
+ afr_sh_delta_to_xattr (priv, sh->delta_matrix, erase_xattr,
+ priv->child_count, AFR_DATA_TRANSACTION);
+
+ local->call_count = call_count;
+ for (i = 0; i < priv->child_count; i++) {
+ if (!erase_xattr[i])
+ continue;
+
+ gf_log (this->name, GF_LOG_TRACE,
+ "erasing pending flags from %s on %s",
+ local->loc.path, priv->children[i]->name);
+
+ STACK_WIND_COOKIE (frame, afr_sh_data_erase_pending_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->fxattrop,
+ sh->healing_fd,
+ GF_XATTROP_ADD_ARRAY, erase_xattr[i]);
+ if (!--call_count)
+ break;
+ }
+
+ for (i = 0; i < priv->child_count; i++) {
+ if (erase_xattr[i]) {
+ dict_unref (erase_xattr[i]);
+ }
+ }
+ GF_FREE (erase_xattr);
+
+ return 0;
}
int
afr_sh_data_trim_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
struct iatt *postbuf)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- int call_count = 0;
- int child_index = 0;
-
- priv = this->private;
- local = frame->local;
-
- child_index = (long) cookie;
-
- LOCK (&frame->lock);
- {
- if (op_ret == -1)
- gf_log (this->name, GF_LOG_DEBUG,
- "ftruncate of %s on subvolume %s failed (%s)",
- local->loc.path,
- priv->children[child_index]->name,
- strerror (op_errno));
- else
- gf_log (this->name, GF_LOG_TRACE,
- "ftruncate of %s on subvolume %s completed",
- local->loc.path,
- priv->children[child_index]->name);
- }
- UNLOCK (&frame->lock);
-
- call_count = afr_frame_return (frame);
-
- if (call_count == 0) {
- afr_sh_data_erase_pending (frame, this);
- }
-
- return 0;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ int call_count = 0;
+ int child_index = 0;
+
+ priv = this->private;
+ local = frame->local;
+
+ child_index = (long) cookie;
+
+ LOCK (&frame->lock);
+ {
+ if (op_ret == -1)
+ gf_log (this->name, GF_LOG_DEBUG,
+ "ftruncate of %s on subvolume %s failed (%s)",
+ local->loc.path,
+ priv->children[child_index]->name,
+ strerror (op_errno));
+ else
+ gf_log (this->name, GF_LOG_TRACE,
+ "ftruncate of %s on subvolume %s completed",
+ local->loc.path,
+ priv->children[child_index]->name);
+ }
+ UNLOCK (&frame->lock);
+
+ call_count = afr_frame_return (frame);
+
+ if (call_count == 0) {
+ afr_sh_data_erase_pending (frame, this);
+ }
+
+ return 0;
}
int
afr_sh_data_trim_sinks (call_frame_t *frame, xlator_t *this)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- afr_self_heal_t *sh = NULL;
- int *sources = NULL;
- int call_count = 0;
- int i = 0;
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ afr_self_heal_t *sh = NULL;
+ int *sources = NULL;
+ int call_count = 0;
+ int i = 0;
- priv = this->private;
- local = frame->local;
- sh = &local->self_heal;
+ priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
- sources = sh->sources;
- call_count = sh->active_sinks;
+ sources = sh->sources;
+ call_count = sh->active_sinks;
- local->call_count = call_count;
+ local->call_count = call_count;
- for (i = 0; i < priv->child_count; i++) {
- if (sources[i] || !local->child_up[i])
- continue;
+ for (i = 0; i < priv->child_count; i++) {
+ if (sources[i] || !local->child_up[i])
+ continue;
- STACK_WIND_COOKIE (frame, afr_sh_data_trim_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->ftruncate,
- sh->healing_fd, sh->file_size);
+ STACK_WIND_COOKIE (frame, afr_sh_data_trim_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->ftruncate,
+ sh->healing_fd, sh->file_size);
- if (!--call_count)
- break;
- }
+ if (!--call_count)
+ break;
+ }
- return 0;
+ return 0;
}
@@ -540,41 +540,41 @@ afr_sh_data_pick_algo (call_frame_t *frame, xlator_t *this)
int
afr_sh_data_sync_prepare (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int active_sinks = 0;
- int source = 0;
- int i = 0;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int active_sinks = 0;
+ int source = 0;
+ int i = 0;
struct afr_sh_algorithm *sh_algo = NULL;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
-
- source = sh->source;
-
- for (i = 0; i < priv->child_count; i++) {
- if (sh->sources[i] == 0 && local->child_up[i] == 1) {
- active_sinks++;
- sh->success[i] = 1;
- }
- }
- sh->success[source] = 1;
-
- if (active_sinks == 0) {
- gf_log (this->name, GF_LOG_TRACE,
- "no active sinks for performing self-heal on file %s",
- local->loc.path);
- afr_sh_data_finish (frame, this);
- return 0;
- }
- sh->active_sinks = active_sinks;
-
- gf_log (this->name, GF_LOG_DEBUG,
- "self-healing file %s from subvolume %s to %d other",
- local->loc.path, priv->children[source]->name, active_sinks);
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
+
+ source = sh->source;
+
+ for (i = 0; i < priv->child_count; i++) {
+ if (sh->sources[i] == 0 && local->child_up[i] == 1) {
+ active_sinks++;
+ sh->success[i] = 1;
+ }
+ }
+ sh->success[source] = 1;
+
+ if (active_sinks == 0) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "no active sinks for performing self-heal on file %s",
+ local->loc.path);
+ afr_sh_data_finish (frame, this);
+ return 0;
+ }
+ sh->active_sinks = active_sinks;
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "self-healing file %s from subvolume %s to %d other",
+ local->loc.path, priv->children[source]->name, active_sinks);
sh->algo_completion_cbk = afr_sh_data_trim_sinks;
sh->algo_abort_cbk = afr_sh_data_finish;
@@ -583,36 +583,36 @@ afr_sh_data_sync_prepare (call_frame_t *frame, xlator_t *this)
sh_algo->fn (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_data_fix (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
+ afr_local_t *local = NULL;
afr_local_t * orig_local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int nsources = 0;
- int source = 0;
- int i = 0;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int nsources = 0;
+ int source = 0;
+ int i = 0;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- afr_sh_build_pending_matrix (priv, sh->pending_matrix, sh->xattr,
- priv->child_count, AFR_DATA_TRANSACTION);
+ afr_sh_build_pending_matrix (priv, sh->pending_matrix, sh->xattr,
+ priv->child_count, AFR_DATA_TRANSACTION);
- afr_sh_print_pending_matrix (sh->pending_matrix, this);
+ afr_sh_print_pending_matrix (sh->pending_matrix, this);
- nsources = afr_sh_mark_sources (sh, priv->child_count,
+ nsources = afr_sh_mark_sources (sh, priv->child_count,
AFR_SELF_HEAL_DATA);
- afr_sh_supress_errenous_children (sh->sources, sh->child_errno,
- priv->child_count);
+ afr_sh_supress_errenous_children (sh->sources, sh->child_errno,
+ priv->child_count);
if (nsources == 0) {
gf_log (this->name, GF_LOG_TRACE,
@@ -623,35 +623,35 @@ afr_sh_data_fix (call_frame_t *frame, xlator_t *this)
return 0;
}
- if ((nsources == -1)
- && (priv->favorite_child != -1)
- && (sh->child_errno[priv->favorite_child] == 0)) {
+ if ((nsources == -1)
+ && (priv->favorite_child != -1)
+ && (sh->child_errno[priv->favorite_child] == 0)) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Picking favorite child %s as authentic source to resolve conflicting data of %s",
- priv->children[priv->favorite_child]->name,
- local->loc.path);
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Picking favorite child %s as authentic source to resolve conflicting data of %s",
+ priv->children[priv->favorite_child]->name,
+ local->loc.path);
- sh->sources[priv->favorite_child] = 1;
+ sh->sources[priv->favorite_child] = 1;
- nsources = afr_sh_source_count (sh->sources,
- priv->child_count);
- }
+ nsources = afr_sh_source_count (sh->sources,
+ priv->child_count);
+ }
- if (nsources == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to self-heal contents of '%s' (possible split-brain). "
+ if (nsources == -1) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unable to self-heal contents of '%s' (possible split-brain). "
"Please delete the file from all but the preferred "
"subvolume.", local->loc.path);
- local->govinda_gOvinda = 1;
+ local->govinda_gOvinda = 1;
+
+ afr_sh_data_finish (frame, this);
+ return 0;
+ }
- afr_sh_data_finish (frame, this);
- return 0;
- }
+ source = afr_sh_select_source (sh->sources, priv->child_count);
- source = afr_sh_select_source (sh->sources, priv->child_count);
-
if (source == -1) {
gf_log (this->name, GF_LOG_DEBUG,
"No active sources found.");
@@ -660,33 +660,33 @@ afr_sh_data_fix (call_frame_t *frame, xlator_t *this)
return 0;
}
- sh->source = source;
- sh->block_size = 65536;
- sh->file_size = sh->buf[source].ia_size;
+ sh->source = source;
+ sh->block_size = 65536;
+ sh->file_size = sh->buf[source].ia_size;
- if (FILE_HAS_HOLES (&sh->buf[source]))
- sh->file_has_holes = 1;
+ if (FILE_HAS_HOLES (&sh->buf[source]))
+ sh->file_has_holes = 1;
orig_local = sh->orig_frame->local;
orig_local->cont.lookup.buf.ia_size = sh->buf[source].ia_size;
- /* detect changes not visible through pending flags -- JIC */
- for (i = 0; i < priv->child_count; i++) {
- if (i == source || sh->child_errno[i])
- continue;
+ /* detect changes not visible through pending flags -- JIC */
+ for (i = 0; i < priv->child_count; i++) {
+ if (i == source || sh->child_errno[i])
+ continue;
- if (SIZE_DIFFERS (&sh->buf[i], &sh->buf[source]))
- sh->sources[i] = 0;
- }
+ if (SIZE_DIFFERS (&sh->buf[i], &sh->buf[source]))
+ sh->sources[i] = 0;
+ }
afr_set_read_child (this, local->loc.inode, sh->source);
- /*
- quick-read might have read the file, so send xattr from
- the source subvolume (http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=815)
- */
+ /*
+ quick-read might have read the file, so send xattr from
+ the source subvolume (http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=815)
+ */
- dict_unref (orig_local->cont.lookup.xattr);
+ dict_unref (orig_local->cont.lookup.xattr);
if (orig_local->cont.lookup.xattrs)
orig_local->cont.lookup.xattr = dict_ref (orig_local->cont.lookup.xattrs[sh->source]);
@@ -695,43 +695,43 @@ afr_sh_data_fix (call_frame_t *frame, xlator_t *this)
sh->unwound = _gf_true;
}
- afr_sh_data_sync_prepare (frame, this);
+ afr_sh_data_sync_prepare (frame, this);
- return 0;
+ return 0;
}
int
afr_self_heal_get_source (xlator_t *this, afr_local_t *local, dict_t **xattr)
{
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
- int source = 0;
- int i = 0;
+ int source = 0;
+ int i = 0;
- sh = &local->self_heal;
- priv = this->private;
+ sh = &local->self_heal;
+ priv = this->private;
- sh->pending_matrix = GF_CALLOC (sizeof (int32_t *), priv->child_count,
+ sh->pending_matrix = GF_CALLOC (sizeof (int32_t *), priv->child_count,
gf_afr_mt_int32_t);
- for (i = 0; i < priv->child_count; i++) {
- sh->pending_matrix[i] = GF_CALLOC (sizeof (int32_t),
- priv->child_count,
- gf_afr_mt_int32_t);
- }
+ for (i = 0; i < priv->child_count; i++) {
+ sh->pending_matrix[i] = GF_CALLOC (sizeof (int32_t),
+ priv->child_count,
+ gf_afr_mt_int32_t);
+ }
- sh->sources = GF_CALLOC (priv->child_count, sizeof (*sh->sources),
+ sh->sources = GF_CALLOC (priv->child_count, sizeof (*sh->sources),
gf_afr_mt_int32_t);
- afr_sh_build_pending_matrix (priv, sh->pending_matrix, xattr,
- priv->child_count, AFR_DATA_TRANSACTION);
+ afr_sh_build_pending_matrix (priv, sh->pending_matrix, xattr,
+ priv->child_count, AFR_DATA_TRANSACTION);
- (void)afr_sh_mark_sources (sh, priv->child_count, AFR_SELF_HEAL_DATA);
+ (void)afr_sh_mark_sources (sh, priv->child_count, AFR_SELF_HEAL_DATA);
- source = afr_sh_select_source (sh->sources, priv->child_count);
+ source = afr_sh_select_source (sh->sources, priv->child_count);
- return source;
+ return source;
}
@@ -740,73 +740,73 @@ afr_sh_data_fstat_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, int32_t op_errno,
struct iatt *buf)
{
- afr_private_t *priv = NULL;
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
- int call_count = -1;
- int child_index = (long) cookie;
+ int call_count = -1;
+ int child_index = (long) cookie;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- LOCK (&frame->lock);
- {
- if (op_ret != -1) {
+ LOCK (&frame->lock);
+ {
+ if (op_ret != -1) {
gf_log (this->name, GF_LOG_TRACE,
"fstat of %s on %s succeeded",
local->loc.path,
priv->children[child_index]->name);
- sh->buf[child_index] = *buf;
- }
- }
- UNLOCK (&frame->lock);
+ sh->buf[child_index] = *buf;
+ }
+ }
+ UNLOCK (&frame->lock);
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0) {
- afr_sh_data_fix (frame, this);
- }
+ if (call_count == 0) {
+ afr_sh_data_fix (frame, this);
+ }
- return 0;
+ return 0;
}
int
afr_sh_data_fstat (call_frame_t *frame, xlator_t *this)
{
- afr_self_heal_t *sh = NULL;
- afr_local_t *local = NULL;
- afr_private_t *priv = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_local_t *local = NULL;
+ afr_private_t *priv = NULL;
- int call_count = 0;
- int i = 0;
+ int call_count = 0;
+ int i = 0;
- priv = this->private;
- local = frame->local;
- sh = &local->self_heal;
+ priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
- call_count = afr_up_children_count (priv->child_count,
+ call_count = afr_up_children_count (priv->child_count,
local->child_up);
- local->call_count = call_count;
+ local->call_count = call_count;
- for (i = 0; i < priv->child_count; i++) {
- if (local->child_up[i]) {
- STACK_WIND_COOKIE (frame, afr_sh_data_fstat_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->fstat,
- sh->healing_fd);
+ for (i = 0; i < priv->child_count; i++) {
+ if (local->child_up[i]) {
+ STACK_WIND_COOKIE (frame, afr_sh_data_fstat_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->fstat,
+ sh->healing_fd);
- if (!--call_count)
- break;
- }
- }
+ if (!--call_count)
+ break;
+ }
+ }
- return 0;
+ return 0;
}
@@ -815,92 +815,92 @@ afr_sh_data_fxattrop_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, int32_t op_errno,
dict_t *xattr)
{
- afr_private_t *priv = NULL;
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
- int call_count = -1;
- int child_index = (long) cookie;
+ int call_count = -1;
+ int child_index = (long) cookie;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- LOCK (&frame->lock);
- {
- if (op_ret != -1) {
+ LOCK (&frame->lock);
+ {
+ if (op_ret != -1) {
gf_log (this->name, GF_LOG_TRACE,
"fxattrop of %s on %s succeeded",
local->loc.path,
priv->children[child_index]->name);
- sh->xattr[child_index] = dict_ref (xattr);
- }
- }
- UNLOCK (&frame->lock);
+ sh->xattr[child_index] = dict_ref (xattr);
+ }
+ }
+ UNLOCK (&frame->lock);
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0) {
- afr_sh_data_fstat (frame, this);
- }
+ if (call_count == 0) {
+ afr_sh_data_fstat (frame, this);
+ }
- return 0;
+ return 0;
}
int
afr_sh_data_fxattrop (call_frame_t *frame, xlator_t *this)
{
- afr_self_heal_t *sh = NULL;
- afr_local_t *local = NULL;
- afr_private_t *priv = NULL;
- dict_t *xattr_req = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_local_t *local = NULL;
+ afr_private_t *priv = NULL;
+ dict_t *xattr_req = NULL;
int32_t zero_pending[3] = {0, 0, 0};
- int call_count = 0;
- int i = 0;
- int ret = 0;
+ int call_count = 0;
+ int i = 0;
+ int ret = 0;
- priv = this->private;
- local = frame->local;
- sh = &local->self_heal;
+ priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
- call_count = afr_up_children_count (priv->child_count,
+ call_count = afr_up_children_count (priv->child_count,
local->child_up);
- local->call_count = call_count;
+ local->call_count = call_count;
- xattr_req = dict_new();
- if (xattr_req) {
+ xattr_req = dict_new();
+ if (xattr_req) {
for (i = 0; i < priv->child_count; i++) {
ret = dict_set_static_bin (xattr_req, priv->pending_key[i],
zero_pending, 3 * sizeof(int32_t));
if (ret < 0)
- gf_log (this->name, GF_LOG_WARNING,
- "Unable to set dict value");
+ gf_log (this->name, GF_LOG_WARNING,
+ "Unable to set dict value");
}
}
- for (i = 0; i < priv->child_count; i++) {
- if (local->child_up[i]) {
- STACK_WIND_COOKIE (frame, afr_sh_data_fxattrop_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->fxattrop,
- sh->healing_fd, GF_XATTROP_ADD_ARRAY,
+ for (i = 0; i < priv->child_count; i++) {
+ if (local->child_up[i]) {
+ STACK_WIND_COOKIE (frame, afr_sh_data_fxattrop_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->fxattrop,
+ sh->healing_fd, GF_XATTROP_ADD_ARRAY,
xattr_req);
- if (!--call_count)
- break;
- }
- }
+ if (!--call_count)
+ break;
+ }
+ }
- if (xattr_req)
- dict_unref (xattr_req);
+ if (xattr_req)
+ dict_unref (xattr_req);
- return 0;
+ return 0;
}
@@ -954,21 +954,21 @@ afr_sh_data_lock_rec (call_frame_t *frame, xlator_t *this)
afr_nonblocking_inodelk (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_data_lock (call_frame_t *frame, xlator_t *this)
{
- afr_local_t * local = NULL;
- afr_private_t * priv = NULL;
- afr_self_heal_t * sh = NULL;
+ afr_local_t * local = NULL;
+ afr_private_t * priv = NULL;
+ afr_self_heal_t * sh = NULL;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
if (sh->data_lock_held) {
/* caller has held the lock already,
@@ -984,76 +984,76 @@ afr_sh_data_lock (call_frame_t *frame, xlator_t *this)
int
afr_sh_data_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd)
+ int32_t op_ret, int32_t op_errno, fd_t *fd)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int call_count = 0;
- int child_index = 0;
-
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
-
- child_index = (long) cookie;
-
- /* TODO: some of the open's might fail.
- In that case, modify cleanup fn to send flush on those
- fd's which are already open */
-
- LOCK (&frame->lock);
- {
- if (op_ret == -1) {
- gf_log (this->name, GF_LOG_TRACE,
- "open of %s failed on child %s (%s)",
- local->loc.path,
- priv->children[child_index]->name,
- strerror (op_errno));
- sh->op_failed = 1;
- }
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int call_count = 0;
+ int child_index = 0;
+
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
+
+ child_index = (long) cookie;
+
+ /* TODO: some of the open's might fail.
+ In that case, modify cleanup fn to send flush on those
+ fd's which are already open */
+
+ LOCK (&frame->lock);
+ {
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "open of %s failed on child %s (%s)",
+ local->loc.path,
+ priv->children[child_index]->name,
+ strerror (op_errno));
+ sh->op_failed = 1;
+ }
gf_log (this->name, GF_LOG_TRACE,
"open of %s succeeded on child %s",
local->loc.path,
priv->children[child_index]->name);
- }
- UNLOCK (&frame->lock);
+ }
+ UNLOCK (&frame->lock);
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0) {
- if (sh->op_failed) {
- afr_sh_data_finish (frame, this);
- return 0;
- }
+ if (call_count == 0) {
+ if (sh->op_failed) {
+ afr_sh_data_finish (frame, this);
+ return 0;
+ }
- gf_log (this->name, GF_LOG_TRACE,
- "fd for %s opened, commencing sync",
- local->loc.path);
+ gf_log (this->name, GF_LOG_TRACE,
+ "fd for %s opened, commencing sync",
+ local->loc.path);
afr_sh_data_lock (frame, this);
- }
+ }
- return 0;
+ return 0;
}
int
afr_sh_data_open (call_frame_t *frame, xlator_t *this)
{
- int i = 0;
- int call_count = 0;
+ int i = 0;
+ int call_count = 0;
- fd_t *fd = NULL;
+ fd_t *fd = NULL;
- afr_local_t * local = NULL;
- afr_private_t * priv = NULL;
- afr_self_heal_t *sh = NULL;
+ afr_local_t * local = NULL;
+ afr_private_t * priv = NULL;
+ afr_self_heal_t *sh = NULL;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
if (sh->healing_fd_opened) {
/* caller has opened the fd for us already, so skip open */
@@ -1062,52 +1062,51 @@ afr_sh_data_open (call_frame_t *frame, xlator_t *this)
return 0;
}
- call_count = afr_up_children_count (priv->child_count, local->child_up);
- local->call_count = call_count;
+ call_count = afr_up_children_count (priv->child_count, local->child_up);
+ local->call_count = call_count;
- fd = fd_create (local->loc.inode, frame->root->pid);
- sh->healing_fd = fd;
+ fd = fd_create (local->loc.inode, frame->root->pid);
+ sh->healing_fd = fd;
- /* open sinks */
- for (i = 0; i < priv->child_count; i++) {
- if(!local->child_up[i])
- continue;
+ /* open sinks */
+ for (i = 0; i < priv->child_count; i++) {
+ if(!local->child_up[i])
+ continue;
- STACK_WIND_COOKIE (frame, afr_sh_data_open_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->open,
- &local->loc,
- O_RDWR|O_LARGEFILE, fd, 0);
+ STACK_WIND_COOKIE (frame, afr_sh_data_open_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->open,
+ &local->loc,
+ O_RDWR|O_LARGEFILE, fd, 0);
- if (!--call_count)
- break;
- }
+ if (!--call_count)
+ break;
+ }
- return 0;
+ return 0;
}
int
afr_self_heal_data (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = this->private;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = this->private;
- local = frame->local;
- sh = &local->self_heal;
+ local = frame->local;
+ sh = &local->self_heal;
- if (sh->need_data_self_heal && priv->data_self_heal) {
- afr_sh_data_open (frame, this);
- } else {
- gf_log (this->name, GF_LOG_TRACE,
- "not doing data self heal on %s",
- local->loc.path);
- afr_sh_data_done (frame, this);
- }
+ if (sh->need_data_self_heal && priv->data_self_heal) {
+ afr_sh_data_open (frame, this);
+ } else {
+ gf_log (this->name, GF_LOG_TRACE,
+ "not doing data self heal on %s",
+ local->loc.path);
+ afr_sh_data_done (frame, this);
+ }
- return 0;
+ return 0;
}
-
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c
index e76d58850cd..3f2e657a451 100644
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
#include <libgen.h>
@@ -52,73 +52,73 @@
int
afr_sh_metadata_done (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int i = 0;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int i = 0;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
-// memset (sh->child_errno, 0, sizeof (int) * priv->child_count);
- memset (sh->buf, 0, sizeof (struct iatt) * priv->child_count);
- memset (sh->success, 0, sizeof (int) * priv->child_count);
+// memset (sh->child_errno, 0, sizeof (int) * priv->child_count);
+ memset (sh->buf, 0, sizeof (struct iatt) * priv->child_count);
+ memset (sh->success, 0, sizeof (int) * priv->child_count);
/* for (i = 0; i < priv->child_count; i++) { */
/* sh->locked_nodes[i] = 1; */
/* } */
- for (i = 0; i < priv->child_count; i++) {
- if (sh->xattr[i])
- dict_unref (sh->xattr[i]);
- sh->xattr[i] = NULL;
- }
-
- if (local->govinda_gOvinda) {
- gf_log (this->name, GF_LOG_DEBUG,
- "aborting selfheal of %s",
- local->loc.path);
- sh->completion_cbk (frame, this);
- } else {
- if (IA_ISREG (sh->type)) {
- gf_log (this->name, GF_LOG_TRACE,
- "proceeding to data check on %s",
- local->loc.path);
- afr_self_heal_data (frame, this);
- return 0;
- }
-
- if (IA_ISDIR (sh->type)) {
- gf_log (this->name, GF_LOG_TRACE,
- "proceeding to entry check on %s",
- local->loc.path);
- afr_self_heal_entry (frame, this);
- return 0;
- }
- gf_log (this->name, GF_LOG_DEBUG,
- "completed self heal of %s",
- local->loc.path);
-
- sh->completion_cbk (frame, this);
- }
-
- return 0;
+ for (i = 0; i < priv->child_count; i++) {
+ if (sh->xattr[i])
+ dict_unref (sh->xattr[i]);
+ sh->xattr[i] = NULL;
+ }
+
+ if (local->govinda_gOvinda) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "aborting selfheal of %s",
+ local->loc.path);
+ sh->completion_cbk (frame, this);
+ } else {
+ if (IA_ISREG (sh->type)) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "proceeding to data check on %s",
+ local->loc.path);
+ afr_self_heal_data (frame, this);
+ return 0;
+ }
+
+ if (IA_ISDIR (sh->type)) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "proceeding to entry check on %s",
+ local->loc.path);
+ afr_self_heal_entry (frame, this);
+ return 0;
+ }
+ gf_log (this->name, GF_LOG_DEBUG,
+ "completed self heal of %s",
+ local->loc.path);
+
+ sh->completion_cbk (frame, this);
+ }
+
+ return 0;
}
int
afr_sh_metadata_unlck_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- int call_count = 0;
+ int call_count = 0;
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0)
- afr_sh_metadata_done (frame, this);
+ if (call_count == 0)
+ afr_sh_metadata_done (frame, this);
- return 0;
+ return 0;
}
int
@@ -141,144 +141,144 @@ afr_sh_metadata_finish (call_frame_t *frame, xlator_t *this)
{
afr_sh_inode_unlock (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_metadata_erase_pending_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int32_t op_ret,
- int32_t op_errno, dict_t *xattr)
+ xlator_t *this, int32_t op_ret,
+ int32_t op_errno, dict_t *xattr)
{
- afr_local_t *local = NULL;
- int call_count = 0;
+ afr_local_t *local = NULL;
+ int call_count = 0;
- local = frame->local;
+ local = frame->local;
- LOCK (&frame->lock);
- {
- }
- UNLOCK (&frame->lock);
+ LOCK (&frame->lock);
+ {
+ }
+ UNLOCK (&frame->lock);
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0)
- afr_sh_metadata_finish (frame, this);
+ if (call_count == 0)
+ afr_sh_metadata_finish (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_metadata_erase_pending (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int call_count = 0;
- int i = 0;
- dict_t **erase_xattr = NULL;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int call_count = 0;
+ int i = 0;
+ dict_t **erase_xattr = NULL;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix,
+ afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix,
sh->success, priv->child_count,
AFR_METADATA_TRANSACTION);
- erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
+ erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
gf_afr_mt_dict_t);
- for (i = 0; i < priv->child_count; i++) {
- if (sh->xattr[i]) {
- call_count++;
-
- erase_xattr[i] = get_new_dict();
- dict_ref (erase_xattr[i]);
- }
- }
-
- afr_sh_delta_to_xattr (priv, sh->delta_matrix, erase_xattr,
- priv->child_count, AFR_METADATA_TRANSACTION);
-
- local->call_count = call_count;
-
- if (call_count == 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "metadata of %s not healed on any subvolume",
- local->loc.path);
-
- afr_sh_metadata_finish (frame, this);
- }
-
- for (i = 0; i < priv->child_count; i++) {
- if (!erase_xattr[i])
- continue;
-
- gf_log (this->name, GF_LOG_TRACE,
- "erasing pending flags from %s on %s",
- local->loc.path, priv->children[i]->name);
-
- STACK_WIND_COOKIE (frame, afr_sh_metadata_erase_pending_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->xattrop,
- &local->loc,
- GF_XATTROP_ADD_ARRAY, erase_xattr[i]);
- if (!--call_count)
- break;
- }
-
- for (i = 0; i < priv->child_count; i++) {
- if (erase_xattr[i]) {
- dict_unref (erase_xattr[i]);
- }
- }
- GF_FREE (erase_xattr);
-
- return 0;
+ for (i = 0; i < priv->child_count; i++) {
+ if (sh->xattr[i]) {
+ call_count++;
+
+ erase_xattr[i] = get_new_dict();
+ dict_ref (erase_xattr[i]);
+ }
+ }
+
+ afr_sh_delta_to_xattr (priv, sh->delta_matrix, erase_xattr,
+ priv->child_count, AFR_METADATA_TRANSACTION);
+
+ local->call_count = call_count;
+
+ if (call_count == 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "metadata of %s not healed on any subvolume",
+ local->loc.path);
+
+ afr_sh_metadata_finish (frame, this);
+ }
+
+ for (i = 0; i < priv->child_count; i++) {
+ if (!erase_xattr[i])
+ continue;
+
+ gf_log (this->name, GF_LOG_TRACE,
+ "erasing pending flags from %s on %s",
+ local->loc.path, priv->children[i]->name);
+
+ STACK_WIND_COOKIE (frame, afr_sh_metadata_erase_pending_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->xattrop,
+ &local->loc,
+ GF_XATTROP_ADD_ARRAY, erase_xattr[i]);
+ if (!--call_count)
+ break;
+ }
+
+ for (i = 0; i < priv->child_count; i++) {
+ if (erase_xattr[i]) {
+ dict_unref (erase_xattr[i]);
+ }
+ }
+ GF_FREE (erase_xattr);
+
+ return 0;
}
int
afr_sh_metadata_sync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int call_count = 0;
- int child_index = 0;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int call_count = 0;
+ int child_index = 0;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- child_index = (long) cookie;
+ child_index = (long) cookie;
- LOCK (&frame->lock);
- {
- if (op_ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
- "setting attributes failed for %s on %s (%s)",
- local->loc.path,
- priv->children[child_index]->name,
- strerror (op_errno));
+ LOCK (&frame->lock);
+ {
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "setting attributes failed for %s on %s (%s)",
+ local->loc.path,
+ priv->children[child_index]->name,
+ strerror (op_errno));
- sh->success[child_index] = 0;
- }
- }
- UNLOCK (&frame->lock);
+ sh->success[child_index] = 0;
+ }
+ }
+ UNLOCK (&frame->lock);
- call_count = afr_frame_return (frame);
+ call_count = afr_frame_return (frame);
- if (call_count == 0)
- afr_sh_metadata_erase_pending (frame, this);
+ if (call_count == 0)
+ afr_sh_metadata_erase_pending (frame, this);
- return 0;
+ return 0;
}
@@ -287,211 +287,211 @@ afr_sh_metadata_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno,
struct iatt *preop, struct iatt *postop)
{
- afr_sh_metadata_sync_cbk (frame, cookie, this, op_ret, op_errno);
+ afr_sh_metadata_sync_cbk (frame, cookie, this, op_ret, op_errno);
- return 0;
+ return 0;
}
int
afr_sh_metadata_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- afr_sh_metadata_sync_cbk (frame, cookie, this, op_ret, op_errno);
+ afr_sh_metadata_sync_cbk (frame, cookie, this, op_ret, op_errno);
- return 0;
+ return 0;
}
int
afr_sh_metadata_sync (call_frame_t *frame, xlator_t *this, dict_t *xattr)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int source = 0;
- int active_sinks = 0;
- int call_count = 0;
- int i = 0;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int source = 0;
+ int active_sinks = 0;
+ int call_count = 0;
+ int i = 0;
struct iatt stbuf;
int32_t valid = 0;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- source = sh->source;
- active_sinks = sh->active_sinks;
+ source = sh->source;
+ active_sinks = sh->active_sinks;
- /*
- * 2 calls per sink - setattr, setxattr
- */
- if (xattr)
- call_count = active_sinks * 2;
- else
- call_count = active_sinks;
+ /*
+ * 2 calls per sink - setattr, setxattr
+ */
+ if (xattr)
+ call_count = active_sinks * 2;
+ else
+ call_count = active_sinks;
- local->call_count = call_count;
+ local->call_count = call_count;
- stbuf.ia_atime = sh->buf[source].ia_atime;
- stbuf.ia_atime_nsec = sh->buf[source].ia_atime_nsec;
- stbuf.ia_mtime = sh->buf[source].ia_mtime;
- stbuf.ia_mtime_nsec = sh->buf[source].ia_mtime_nsec;
+ stbuf.ia_atime = sh->buf[source].ia_atime;
+ stbuf.ia_atime_nsec = sh->buf[source].ia_atime_nsec;
+ stbuf.ia_mtime = sh->buf[source].ia_mtime;
+ stbuf.ia_mtime_nsec = sh->buf[source].ia_mtime_nsec;
stbuf.ia_uid = sh->buf[source].ia_uid;
stbuf.ia_gid = sh->buf[source].ia_gid;
stbuf.ia_type = sh->buf[source].ia_type;
stbuf.ia_prot = sh->buf[source].ia_prot;
-
- valid = GF_SET_ATTR_MODE |
+
+ valid = GF_SET_ATTR_MODE |
GF_SET_ATTR_UID | GF_SET_ATTR_GID |
GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME;
- for (i = 0; i < priv->child_count; i++) {
- if (call_count == 0) {
- break;
- }
- if (sh->sources[i] || !local->child_up[i])
- continue;
-
- gf_log (this->name, GF_LOG_DEBUG,
- "self-healing metadata of %s from %s to %s",
- local->loc.path, priv->children[source]->name,
- priv->children[i]->name);
-
- STACK_WIND_COOKIE (frame, afr_sh_metadata_setattr_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->setattr,
- &local->loc, &stbuf, valid);
-
- call_count--;
-
- if (!xattr)
- continue;
-
- STACK_WIND_COOKIE (frame, afr_sh_metadata_xattr_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->setxattr,
- &local->loc, xattr, 0);
- call_count--;
- }
-
- return 0;
+ for (i = 0; i < priv->child_count; i++) {
+ if (call_count == 0) {
+ break;
+ }
+ if (sh->sources[i] || !local->child_up[i])
+ continue;
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "self-healing metadata of %s from %s to %s",
+ local->loc.path, priv->children[source]->name,
+ priv->children[i]->name);
+
+ STACK_WIND_COOKIE (frame, afr_sh_metadata_setattr_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->setattr,
+ &local->loc, &stbuf, valid);
+
+ call_count--;
+
+ if (!xattr)
+ continue;
+
+ STACK_WIND_COOKIE (frame, afr_sh_metadata_xattr_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->setxattr,
+ &local->loc, xattr, 0);
+ call_count--;
+ }
+
+ return 0;
}
int
afr_sh_metadata_getxattr_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xattr)
+ xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xattr)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int source = 0;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int source = 0;
int i;
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
- source = sh->source;
+ source = sh->source;
- if (op_ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
- "getxattr of %s failed on subvolume %s (%s). proceeding without xattr",
- local->loc.path, priv->children[source]->name,
- strerror (op_errno));
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "getxattr of %s failed on subvolume %s (%s). proceeding without xattr",
+ local->loc.path, priv->children[source]->name,
+ strerror (op_errno));
- afr_sh_metadata_sync (frame, this, NULL);
- } else {
+ afr_sh_metadata_sync (frame, this, NULL);
+ } else {
for (i = 0; i < priv->child_count; i++) {
dict_del (xattr, priv->pending_key[i]);
}
- afr_sh_metadata_sync (frame, this, xattr);
- }
+ afr_sh_metadata_sync (frame, this, xattr);
+ }
- return 0;
+ return 0;
}
int
afr_sh_metadata_sync_prepare (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int active_sinks = 0;
- int source = 0;
- int i = 0;
-
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
-
- source = sh->source;
-
- for (i = 0; i < priv->child_count; i++) {
- if (sh->sources[i] == 0 && local->child_up[i] == 1) {
- active_sinks++;
- sh->success[i] = 1;
- }
- }
- sh->success[source] = 1;
-
- if (active_sinks == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "no active sinks for performing self-heal on file %s",
- local->loc.path);
- afr_sh_metadata_finish (frame, this);
- return 0;
- }
- sh->active_sinks = active_sinks;
-
- gf_log (this->name, GF_LOG_TRACE,
- "syncing metadata of %s from subvolume %s to %d active sinks",
- local->loc.path, priv->children[source]->name, active_sinks);
-
- STACK_WIND (frame, afr_sh_metadata_getxattr_cbk,
- priv->children[source],
- priv->children[source]->fops->getxattr,
- &local->loc, NULL);
-
- return 0;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int active_sinks = 0;
+ int source = 0;
+ int i = 0;
+
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
+
+ source = sh->source;
+
+ for (i = 0; i < priv->child_count; i++) {
+ if (sh->sources[i] == 0 && local->child_up[i] == 1) {
+ active_sinks++;
+ sh->success[i] = 1;
+ }
+ }
+ sh->success[source] = 1;
+
+ if (active_sinks == 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "no active sinks for performing self-heal on file %s",
+ local->loc.path);
+ afr_sh_metadata_finish (frame, this);
+ return 0;
+ }
+ sh->active_sinks = active_sinks;
+
+ gf_log (this->name, GF_LOG_TRACE,
+ "syncing metadata of %s from subvolume %s to %d active sinks",
+ local->loc.path, priv->children[source]->name, active_sinks);
+
+ STACK_WIND (frame, afr_sh_metadata_getxattr_cbk,
+ priv->children[source],
+ priv->children[source]->fops->getxattr,
+ &local->loc, NULL);
+
+ return 0;
}
int
afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int nsources = 0;
- int source = 0;
- int i = 0;
-
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
-
- afr_sh_build_pending_matrix (priv, sh->pending_matrix, sh->xattr,
- priv->child_count,
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int nsources = 0;
+ int source = 0;
+ int i = 0;
+
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
+
+ afr_sh_build_pending_matrix (priv, sh->pending_matrix, sh->xattr,
+ priv->child_count,
AFR_METADATA_TRANSACTION);
- afr_sh_print_pending_matrix (sh->pending_matrix, this);
+ afr_sh_print_pending_matrix (sh->pending_matrix, this);
- nsources = afr_sh_mark_sources (sh, priv->child_count,
+ nsources = afr_sh_mark_sources (sh, priv->child_count,
AFR_SELF_HEAL_METADATA);
- afr_sh_supress_errenous_children (sh->sources, sh->child_errno,
- priv->child_count);
+ afr_sh_supress_errenous_children (sh->sources, sh->child_errno,
+ priv->child_count);
if (nsources == 0) {
gf_log (this->name, GF_LOG_TRACE,
@@ -502,34 +502,34 @@ afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this)
return 0;
}
- if ((nsources == -1)
- && (priv->favorite_child != -1)
- && (sh->child_errno[priv->favorite_child] == 0)) {
+ if ((nsources == -1)
+ && (priv->favorite_child != -1)
+ && (sh->child_errno[priv->favorite_child] == 0)) {
- gf_log (this->name, GF_LOG_WARNING,
- "Picking favorite child %s as authentic source to resolve conflicting metadata of %s",
- priv->children[priv->favorite_child]->name,
- local->loc.path);
+ gf_log (this->name, GF_LOG_WARNING,
+ "Picking favorite child %s as authentic source to resolve conflicting metadata of %s",
+ priv->children[priv->favorite_child]->name,
+ local->loc.path);
- sh->sources[priv->favorite_child] = 1;
+ sh->sources[priv->favorite_child] = 1;
- nsources = afr_sh_source_count (sh->sources,
- priv->child_count);
- }
+ nsources = afr_sh_source_count (sh->sources,
+ priv->child_count);
+ }
- if (nsources == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to self-heal permissions/ownership of '%s' "
+ if (nsources == -1) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unable to self-heal permissions/ownership of '%s' "
"(possible split-brain). Please fix the file on "
"all backend volumes", local->loc.path);
- local->govinda_gOvinda = 1;
+ local->govinda_gOvinda = 1;
- afr_sh_metadata_finish (frame, this);
- return 0;
- }
+ afr_sh_metadata_finish (frame, this);
+ return 0;
+ }
- source = afr_sh_select_source (sh->sources, priv->child_count);
+ source = afr_sh_select_source (sh->sources, priv->child_count);
if (source == -1) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -539,98 +539,98 @@ afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this)
return 0;
}
- sh->source = source;
+ sh->source = source;
- /* detect changes not visible through pending flags -- JIC */
- for (i = 0; i < priv->child_count; i++) {
- if (i == source || sh->child_errno[i])
- continue;
+ /* detect changes not visible through pending flags -- JIC */
+ for (i = 0; i < priv->child_count; i++) {
+ if (i == source || sh->child_errno[i])
+ continue;
- if (PERMISSION_DIFFERS (&sh->buf[i], &sh->buf[source]))
- sh->sources[i] = 0;
+ if (PERMISSION_DIFFERS (&sh->buf[i], &sh->buf[source]))
+ sh->sources[i] = 0;
- if (OWNERSHIP_DIFFERS (&sh->buf[i], &sh->buf[source]))
- sh->sources[i] = 0;
- }
+ if (OWNERSHIP_DIFFERS (&sh->buf[i], &sh->buf[source]))
+ sh->sources[i] = 0;
+ }
- afr_sh_metadata_sync_prepare (frame, this);
+ afr_sh_metadata_sync_prepare (frame, this);
- return 0;
+ return 0;
}
int
afr_sh_metadata_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
+ int32_t op_ret, int32_t op_errno,
inode_t *inode, struct iatt *buf, dict_t *xattr,
struct iatt *postparent)
{
- afr_local_t *local = NULL;
- afr_self_heal_t *sh = NULL;
- afr_private_t *priv = NULL;
- int call_count = 0;
- int child_index = 0;
-
-
- local = frame->local;
- sh = &local->self_heal;
- priv = this->private;
-
- child_index = (long) cookie;
-
- LOCK (&frame->lock);
- {
- if (op_ret == 0) {
- gf_log (this->name, GF_LOG_TRACE,
- "path %s on subvolume %s is of mode 0%o",
- local->loc.path,
- priv->children[child_index]->name,
- buf->ia_type);
-
- sh->buf[child_index] = *buf;
- if (xattr)
- sh->xattr[child_index] = dict_ref (xattr);
- } else {
- gf_log (this->name, GF_LOG_DEBUG,
- "path %s on subvolume %s => -1 (%s)",
- local->loc.path,
- priv->children[child_index]->name,
- strerror (op_errno));
-
- sh->child_errno[child_index] = op_errno;
- }
- }
- UNLOCK (&frame->lock);
-
- call_count = afr_frame_return (frame);
-
- if (call_count == 0)
- afr_sh_metadata_fix (frame, this);
-
- return 0;
+ afr_local_t *local = NULL;
+ afr_self_heal_t *sh = NULL;
+ afr_private_t *priv = NULL;
+ int call_count = 0;
+ int child_index = 0;
+
+
+ local = frame->local;
+ sh = &local->self_heal;
+ priv = this->private;
+
+ child_index = (long) cookie;
+
+ LOCK (&frame->lock);
+ {
+ if (op_ret == 0) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "path %s on subvolume %s is of mode 0%o",
+ local->loc.path,
+ priv->children[child_index]->name,
+ buf->ia_type);
+
+ sh->buf[child_index] = *buf;
+ if (xattr)
+ sh->xattr[child_index] = dict_ref (xattr);
+ } else {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "path %s on subvolume %s => -1 (%s)",
+ local->loc.path,
+ priv->children[child_index]->name,
+ strerror (op_errno));
+
+ sh->child_errno[child_index] = op_errno;
+ }
+ }
+ UNLOCK (&frame->lock);
+
+ call_count = afr_frame_return (frame);
+
+ if (call_count == 0)
+ afr_sh_metadata_fix (frame, this);
+
+ return 0;
}
int
afr_sh_metadata_lookup (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_private_t *priv = NULL;
- int i = 0;
- int call_count = 0;
- dict_t *xattr_req = NULL;
- int ret = 0;
+ afr_local_t *local = NULL;
+ afr_private_t *priv = NULL;
+ int i = 0;
+ int call_count = 0;
+ dict_t *xattr_req = NULL;
+ int ret = 0;
- local = frame->local;
- priv = this->private;
+ local = frame->local;
+ priv = this->private;
- call_count = afr_up_children_count (priv->child_count,
+ call_count = afr_up_children_count (priv->child_count,
local->child_up);
- local->call_count = call_count;
+ local->call_count = call_count;
- xattr_req = dict_new();
+ xattr_req = dict_new();
- if (xattr_req) {
+ if (xattr_req) {
for (i = 0; i < priv->child_count; i++) {
ret = dict_set_uint64 (xattr_req,
priv->pending_key[i],
@@ -641,26 +641,26 @@ afr_sh_metadata_lookup (call_frame_t *frame, xlator_t *this)
}
}
- for (i = 0; i < priv->child_count; i++) {
- if (local->child_up[i]) {
- gf_log (this->name, GF_LOG_TRACE,
- "looking up %s on %s",
- local->loc.path, priv->children[i]->name);
-
- STACK_WIND_COOKIE (frame, afr_sh_metadata_lookup_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->lookup,
- &local->loc, xattr_req);
- if (!--call_count)
- break;
- }
- }
-
- if (xattr_req)
- dict_unref (xattr_req);
-
- return 0;
+ for (i = 0; i < priv->child_count; i++) {
+ if (local->child_up[i]) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "looking up %s on %s",
+ local->loc.path, priv->children[i]->name);
+
+ STACK_WIND_COOKIE (frame, afr_sh_metadata_lookup_cbk,
+ (void *) (long) i,
+ priv->children[i],
+ priv->children[i]->fops->lookup,
+ &local->loc, xattr_req);
+ if (!--call_count)
+ break;
+ }
+ }
+
+ if (xattr_req)
+ dict_unref (xattr_req);
+
+ return 0;
}
int
@@ -707,25 +707,24 @@ afr_sh_metadata_lock (call_frame_t *frame, xlator_t *this)
afr_nonblocking_inodelk (frame, this);
- return 0;
+ return 0;
}
int
afr_self_heal_metadata (call_frame_t *frame, xlator_t *this)
{
- afr_local_t *local = NULL;
- afr_private_t *priv = this->private;
+ afr_local_t *local = NULL;
+ afr_private_t *priv = this->private;
- local = frame->local;
+ local = frame->local;
- if (local->self_heal.need_metadata_self_heal && priv->metadata_self_heal) {
- afr_sh_metadata_lock (frame, this);
- } else {
- afr_sh_metadata_done (frame, this);
- }
+ if (local->self_heal.need_metadata_self_heal && priv->metadata_self_heal) {
+ afr_sh_metadata_lock (frame, this);
+ } else {
+ afr_sh_metadata_done (frame, this);
+ }
- return 0;
+ return 0;
}
-
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index e6cd9bf4905..a2da671a7c7 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
@@ -37,55 +37,55 @@
struct _pump_private;
typedef struct _afr_private {
- gf_lock_t lock; /* to guard access to child_count, etc */
- unsigned int child_count; /* total number of children */
+ gf_lock_t lock; /* to guard access to child_count, etc */
+ unsigned int child_count; /* total number of children */
unsigned int read_child_rr; /* round-robin index of the read_child */
gf_lock_t read_child_lock; /* lock to protect above */
- xlator_t **children;
+ xlator_t **children;
gf_lock_t root_inode_lk;
int first_lookup;
inode_t *root_inode;
- unsigned char *child_up;
+ unsigned char *child_up;
char **pending_key;
- gf_boolean_t data_self_heal; /* on/off */
+ gf_boolean_t data_self_heal; /* on/off */
char * data_self_heal_algorithm; /* name of algorithm */
unsigned int data_self_heal_window_size; /* max number of pipelined
read/writes */
unsigned int background_self_heal_count;
unsigned int background_self_heals_started;
- gf_boolean_t metadata_self_heal; /* on/off */
- gf_boolean_t entry_self_heal; /* on/off */
+ gf_boolean_t metadata_self_heal; /* on/off */
+ gf_boolean_t entry_self_heal; /* on/off */
- gf_boolean_t data_change_log; /* on/off */
- gf_boolean_t metadata_change_log; /* on/off */
- gf_boolean_t entry_change_log; /* on/off */
+ gf_boolean_t data_change_log; /* on/off */
+ gf_boolean_t metadata_change_log; /* on/off */
+ gf_boolean_t entry_change_log; /* on/off */
- int read_child; /* read-subvolume */
- unsigned int favorite_child; /* subvolume to be preferred in resolving
- split-brain cases */
+ int read_child; /* read-subvolume */
+ unsigned int favorite_child; /* subvolume to be preferred in resolving
+ split-brain cases */
- unsigned int data_lock_server_count;
- unsigned int metadata_lock_server_count;
- unsigned int entry_lock_server_count;
+ unsigned int data_lock_server_count;
+ unsigned int metadata_lock_server_count;
+ unsigned int entry_lock_server_count;
- gf_boolean_t inodelk_trace;
- gf_boolean_t entrylk_trace;
+ gf_boolean_t inodelk_trace;
+ gf_boolean_t entrylk_trace;
- gf_boolean_t strict_readdir;
+ gf_boolean_t strict_readdir;
- unsigned int wait_count; /* # of servers to wait for success */
+ unsigned int wait_count; /* # of servers to wait for success */
uint64_t up_count; /* number of CHILD_UPs we have seen */
uint64_t down_count; /* number of CHILD_DOWNs we have seen */
- struct _pump_private *pump_private; /* Set if we are loaded as pump */
+ struct _pump_private *pump_private; /* Set if we are loaded as pump */
int use_afr_in_pump;
pthread_mutex_t mutex;
@@ -112,7 +112,7 @@ typedef struct {
gf_boolean_t data_lock_held; /* true if caller has already
acquired 0-0 lock */
- fd_t *healing_fd; /* set if callers has opened fd */
+ fd_t *healing_fd; /* set if callers has opened fd */
gf_boolean_t background; /* do self-heal in background
if possible */
@@ -128,39 +128,39 @@ typedef struct {
/* End of external interface members */
- /* array of stat's, one for each child */
- struct iatt *buf;
+ /* array of stat's, one for each child */
+ struct iatt *buf;
struct iatt parentbuf;
struct iatt entrybuf;
- /* array of xattr's, one for each child */
- dict_t **xattr;
+ /* array of xattr's, one for each child */
+ dict_t **xattr;
- /* array of errno's, one for each child */
- int *child_errno;
+ /* array of errno's, one for each child */
+ int *child_errno;
- int32_t **pending_matrix;
- int32_t **delta_matrix;
+ int32_t **pending_matrix;
+ int32_t **delta_matrix;
- int *sources;
- int source;
- int active_source;
- int active_sinks;
- int *success;
- unsigned char *locked_nodes;
+ int *sources;
+ int source;
+ int active_source;
+ int active_sinks;
+ int *success;
+ unsigned char *locked_nodes;
int lock_count;
mode_t impunging_entry_mode;
const char *linkname;
- int op_failed;
+ int op_failed;
- int file_has_holes;
- blksize_t block_size;
- off_t file_size;
- off_t offset;
+ int file_has_holes;
+ blksize_t block_size;
+ off_t file_size;
+ off_t offset;
- loc_t parent_loc;
+ loc_t parent_loc;
call_frame_t *orig_frame;
gf_boolean_t unwound;
@@ -170,19 +170,19 @@ typedef struct {
int (*flush_self_heal_cbk) (call_frame_t *frame, xlator_t *this);
- int (*completion_cbk) (call_frame_t *frame, xlator_t *this);
+ int (*completion_cbk) (call_frame_t *frame, xlator_t *this);
int (*algo_completion_cbk) (call_frame_t *frame, xlator_t *this);
int (*algo_abort_cbk) (call_frame_t *frame, xlator_t *this);
- call_frame_t *sh_frame;
+ call_frame_t *sh_frame;
} afr_self_heal_t;
typedef enum {
- AFR_DATA_TRANSACTION, /* truncate, write, ... */
- AFR_METADATA_TRANSACTION, /* chmod, chown, ... */
- AFR_ENTRY_TRANSACTION, /* create, rmdir, ... */
- AFR_ENTRY_RENAME_TRANSACTION, /* rename */
+ AFR_DATA_TRANSACTION, /* truncate, write, ... */
+ AFR_METADATA_TRANSACTION, /* chmod, chown, ... */
+ AFR_ENTRY_TRANSACTION, /* create, rmdir, ... */
+ AFR_ENTRY_RENAME_TRANSACTION, /* rename */
} afr_transaction_type;
typedef enum {
@@ -279,39 +279,39 @@ typedef struct _afr_locked_fd {
typedef struct _afr_local {
int uid;
int gid;
- unsigned int call_count;
- unsigned int success_count;
- unsigned int enoent_count;
+ unsigned int call_count;
+ unsigned int success_count;
+ unsigned int enoent_count;
- unsigned int govinda_gOvinda;
+ unsigned int govinda_gOvinda;
- unsigned int read_child_index;
+ unsigned int read_child_index;
unsigned char read_child_returned;
unsigned int first_up_child;
pid_t saved_pid;
- int32_t op_ret;
- int32_t op_errno;
+ int32_t op_ret;
+ int32_t op_errno;
- int32_t **pending;
+ int32_t **pending;
- loc_t loc;
- loc_t newloc;
+ loc_t loc;
+ loc_t newloc;
- fd_t *fd;
+ fd_t *fd;
- glusterfs_fop_t fop;
+ glusterfs_fop_t fop;
- unsigned char *child_up;
+ unsigned char *child_up;
- int32_t *child_errno;
+ int32_t *child_errno;
- dict_t *xattr_req;
+ dict_t *xattr_req;
- int32_t inodelk_count;
- int32_t entrylk_count;
+ int32_t inodelk_count;
+ int32_t entrylk_count;
afr_internal_lock_t internal_lock;
@@ -324,123 +324,123 @@ typedef struct _afr_local {
int (*openfd_flush_cbk) (call_frame_t *frame, xlator_t *this);
- /*
- This struct contains the arguments for the "continuation"
- (scheme-like) of fops
- */
-
- int op;
- struct {
- struct {
- unsigned char buf_set;
- struct statvfs buf;
- } statfs;
-
- struct {
- inode_t *inode;
- struct iatt buf;
+ /*
+ This struct contains the arguments for the "continuation"
+ (scheme-like) of fops
+ */
+
+ int op;
+ struct {
+ struct {
+ unsigned char buf_set;
+ struct statvfs buf;
+ } statfs;
+
+ struct {
+ inode_t *inode;
+ struct iatt buf;
struct iatt read_child_buf;
struct iatt postparent;
ino_t ino;
uint64_t gen;
ino_t parent_ino;
- dict_t *xattr;
- dict_t **xattrs;
+ dict_t *xattr;
+ dict_t **xattrs;
gf_boolean_t is_revalidate;
- } lookup;
+ } lookup;
- struct {
- int32_t flags;
+ struct {
+ int32_t flags;
int32_t wbflags;
- } open;
+ } open;
- struct {
- int32_t cmd;
+ struct {
+ int32_t cmd;
struct gf_flock user_flock;
struct gf_flock ret_flock;
- unsigned char *locked_nodes;
- } lk;
+ unsigned char *locked_nodes;
+ } lk;
- /* inode read */
+ /* inode read */
- struct {
- int32_t mask;
- int last_tried; /* index of the child we tried previously */
- } access;
+ struct {
+ int32_t mask;
+ int last_tried; /* index of the child we tried previously */
+ } access;
- struct {
- int last_tried;
- ino_t ino;
- } stat;
+ struct {
+ int last_tried;
+ ino_t ino;
+ } stat;
- struct {
- int last_tried;
- ino_t ino;
- } fstat;
+ struct {
+ int last_tried;
+ ino_t ino;
+ } fstat;
- struct {
- size_t size;
- int last_tried;
+ struct {
+ size_t size;
+ int last_tried;
ino_t ino;
- } readlink;
+ } readlink;
- struct {
- char *name;
- int last_tried;
- } getxattr;
+ struct {
+ char *name;
+ int last_tried;
+ } getxattr;
- struct {
+ struct {
ino_t ino;
- size_t size;
- off_t offset;
- int last_tried;
- } readv;
+ size_t size;
+ off_t offset;
+ int last_tried;
+ } readv;
- /* dir read */
+ /* dir read */
- struct {
- int success_count;
- int32_t op_ret;
- int32_t op_errno;
+ struct {
+ int success_count;
+ int32_t op_ret;
+ int32_t op_errno;
uint32_t *checksum;
- } opendir;
+ } opendir;
- struct {
- int32_t op_ret;
- int32_t op_errno;
- size_t size;
- off_t offset;
+ struct {
+ int32_t op_ret;
+ int32_t op_errno;
+ size_t size;
+ off_t offset;
gf_boolean_t failed;
- int last_tried;
- } readdir;
+ int last_tried;
+ } readdir;
- struct {
- int32_t op_ret;
- int32_t op_errno;
+ struct {
+ int32_t op_ret;
+ int32_t op_errno;
- size_t size;
- off_t offset;
- int32_t flag;
+ size_t size;
+ off_t offset;
+ int32_t flag;
- int last_tried;
- } getdents;
+ int last_tried;
+ } getdents;
- /* inode write */
+ /* inode write */
- struct {
- ino_t ino;
- struct iatt prebuf;
- struct iatt postbuf;
+ struct {
+ ino_t ino;
+ struct iatt prebuf;
+ struct iatt postbuf;
- int32_t op_ret;
+ int32_t op_ret;
- struct iovec *vector;
- struct iobref *iobref;
- int32_t count;
- off_t offset;
- } writev;
+ struct iovec *vector;
+ struct iobref *iobref;
+ int32_t count;
+ off_t offset;
+ } writev;
struct {
ino_t ino;
@@ -448,181 +448,181 @@ typedef struct _afr_local {
struct iatt postbuf;
} fsync;
- struct {
- ino_t ino;
- off_t offset;
- struct iatt prebuf;
+ struct {
+ ino_t ino;
+ off_t offset;
+ struct iatt prebuf;
struct iatt postbuf;
- } truncate;
+ } truncate;
- struct {
- ino_t ino;
- off_t offset;
- struct iatt prebuf;
+ struct {
+ ino_t ino;
+ off_t offset;
+ struct iatt prebuf;
struct iatt postbuf;
- } ftruncate;
+ } ftruncate;
- struct {
- ino_t ino;
- struct iatt in_buf;
+ struct {
+ ino_t ino;
+ struct iatt in_buf;
int32_t valid;
struct iatt preop_buf;
struct iatt postop_buf;
- } setattr;
+ } setattr;
- struct {
- ino_t ino;
- struct iatt in_buf;
+ struct {
+ ino_t ino;
+ struct iatt in_buf;
int32_t valid;
struct iatt preop_buf;
struct iatt postop_buf;
- } fsetattr;
+ } fsetattr;
- struct {
- dict_t *dict;
- int32_t flags;
- } setxattr;
+ struct {
+ dict_t *dict;
+ int32_t flags;
+ } setxattr;
- struct {
- char *name;
- } removexattr;
+ struct {
+ char *name;
+ } removexattr;
- /* dir write */
+ /* dir write */
- struct {
- ino_t ino;
+ struct {
+ ino_t ino;
uint64_t gen;
ino_t parent_ino;
- fd_t *fd;
+ fd_t *fd;
dict_t *params;
- int32_t flags;
- mode_t mode;
- inode_t *inode;
- struct iatt buf;
+ int32_t flags;
+ mode_t mode;
+ inode_t *inode;
+ struct iatt buf;
struct iatt preparent;
struct iatt postparent;
struct iatt read_child_buf;
- } create;
+ } create;
- struct {
- ino_t ino;
+ struct {
+ ino_t ino;
uint64_t gen;
ino_t parent_ino;
- dev_t dev;
- mode_t mode;
+ dev_t dev;
+ mode_t mode;
dict_t *params;
- inode_t *inode;
- struct iatt buf;
+ inode_t *inode;
+ struct iatt buf;
struct iatt preparent;
struct iatt postparent;
struct iatt read_child_buf;
- } mknod;
+ } mknod;
- struct {
- ino_t ino;
+ struct {
+ ino_t ino;
uint64_t gen;
ino_t parent_ino;
- int32_t mode;
+ int32_t mode;
dict_t *params;
- inode_t *inode;
- struct iatt buf;
+ inode_t *inode;
+ struct iatt buf;
struct iatt read_child_buf;
struct iatt preparent;
struct iatt postparent;
- } mkdir;
+ } mkdir;
- struct {
+ struct {
ino_t parent_ino;
- int32_t op_ret;
- int32_t op_errno;
+ int32_t op_ret;
+ int32_t op_errno;
struct iatt preparent;
struct iatt postparent;
- } unlink;
+ } unlink;
- struct {
+ struct {
int flags;
ino_t parent_ino;
- int32_t op_ret;
- int32_t op_errno;
+ int32_t op_ret;
+ int32_t op_errno;
struct iatt preparent;
struct iatt postparent;
- } rmdir;
+ } rmdir;
- struct {
+ struct {
ino_t oldparent_ino;
ino_t newparent_ino;
- ino_t ino;
- struct iatt buf;
+ ino_t ino;
+ struct iatt buf;
struct iatt read_child_buf;
struct iatt preoldparent;
struct iatt prenewparent;
struct iatt postoldparent;
struct iatt postnewparent;
- } rename;
+ } rename;
- struct {
- ino_t ino;
+ struct {
+ ino_t ino;
uint64_t gen;
ino_t parent_ino;
- inode_t *inode;
- struct iatt buf;
+ inode_t *inode;
+ struct iatt buf;
struct iatt read_child_buf;
struct iatt preparent;
struct iatt postparent;
- } link;
+ } link;
- struct {
- ino_t ino;
+ struct {
+ ino_t ino;
uint64_t gen;
ino_t parent_ino;
- inode_t *inode;
+ inode_t *inode;
dict_t *params;
- struct iatt buf;
+ struct iatt buf;
struct iatt read_child_buf;
- char *linkpath;
+ char *linkpath;
struct iatt preparent;
struct iatt postparent;
- } symlink;
+ } symlink;
- struct {
- int32_t flags;
- dir_entry_t *entries;
- int32_t count;
- } setdents;
- } cont;
+ struct {
+ int32_t flags;
+ dir_entry_t *entries;
+ int32_t count;
+ } setdents;
+ } cont;
- struct {
- off_t start, len;
+ struct {
+ off_t start, len;
- char *basename;
- char *new_basename;
+ char *basename;
+ char *new_basename;
- loc_t parent_loc;
- loc_t new_parent_loc;
+ loc_t parent_loc;
+ loc_t new_parent_loc;
- afr_transaction_type type;
+ afr_transaction_type type;
- int success_count;
- int erase_pending;
- int failure_count;
+ int success_count;
+ int erase_pending;
+ int failure_count;
- int last_tried;
- int32_t *child_errno;
+ int last_tried;
+ int32_t *child_errno;
- call_frame_t *main_frame;
+ call_frame_t *main_frame;
- int (*fop) (call_frame_t *frame, xlator_t *this);
+ int (*fop) (call_frame_t *frame, xlator_t *this);
- int (*done) (call_frame_t *frame, xlator_t *this);
+ int (*done) (call_frame_t *frame, xlator_t *this);
- int (*resume) (call_frame_t *frame, xlator_t *this);
+ int (*resume) (call_frame_t *frame, xlator_t *this);
- int (*unwind) (call_frame_t *frame, xlator_t *this);
+ int (*unwind) (call_frame_t *frame, xlator_t *this);
/* post-op hook */
- } transaction;
+ } transaction;
- afr_self_heal_t self_heal;
+ afr_self_heal_t self_heal;
struct marker_str marker;
} afr_local_t;
@@ -649,22 +649,22 @@ typedef struct {
/* try alloc and if it fails, goto label */
-#define ALLOC_OR_GOTO(var, type, label) do { \
- var = GF_CALLOC (sizeof (type), 1, \
- gf_afr_mt_##type); \
- if (!var) { \
- gf_log (this->name, GF_LOG_ERROR, \
- "out of memory :("); \
- op_errno = ENOMEM; \
- goto label; \
- } \
- } while (0);
+#define ALLOC_OR_GOTO(var, type, label) do { \
+ var = GF_CALLOC (sizeof (type), 1, \
+ gf_afr_mt_##type); \
+ if (!var) { \
+ gf_log (this->name, GF_LOG_ERROR, \
+ "out of memory :("); \
+ op_errno = ENOMEM; \
+ goto label; \
+ } \
+ } while (0);
/* did a call fail due to a child failing? */
-#define child_went_down(op_ret, op_errno) (((op_ret) < 0) && \
- ((op_errno == ENOTCONN) || \
- (op_errno == EBADFD)))
+#define child_went_down(op_ret, op_errno) (((op_ret) < 0) && \
+ ((op_errno == ENOTCONN) || \
+ (op_errno == EBADFD)))
#define afr_fop_failed(op_ret, op_errno) ((op_ret) == -1)
@@ -774,42 +774,42 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd);
int
afr_openfd_flush (call_frame_t *frame, xlator_t *this, fd_t *fd);
-#define AFR_STACK_UNWIND(fop, frame, params ...) \
- do { \
- afr_local_t *__local = NULL; \
- xlator_t *__this = NULL; \
- if (frame) { \
- __local = frame->local; \
- __this = frame->this; \
- frame->local = NULL; \
+#define AFR_STACK_UNWIND(fop, frame, params ...) \
+ do { \
+ afr_local_t *__local = NULL; \
+ xlator_t *__this = NULL; \
+ if (frame) { \
+ __local = frame->local; \
+ __this = frame->this; \
+ frame->local = NULL; \
} \
- STACK_UNWIND_STRICT (fop, frame, params); \
- afr_local_cleanup (__local, __this); \
- GF_FREE (__local); \
+ STACK_UNWIND_STRICT (fop, frame, params); \
+ afr_local_cleanup (__local, __this); \
+ GF_FREE (__local); \
} while (0);
-#define AFR_STACK_DESTROY(frame) \
- do { \
- afr_local_t *__local = NULL; \
- xlator_t *__this = NULL; \
- __local = frame->local; \
- __this = frame->this; \
- frame->local = NULL; \
- STACK_DESTROY (frame->root); \
- afr_local_cleanup (__local, __this); \
- GF_FREE (__local); \
+#define AFR_STACK_DESTROY(frame) \
+ do { \
+ afr_local_t *__local = NULL; \
+ xlator_t *__this = NULL; \
+ __local = frame->local; \
+ __this = frame->this; \
+ frame->local = NULL; \
+ STACK_DESTROY (frame->root); \
+ afr_local_cleanup (__local, __this); \
+ GF_FREE (__local); \
} while (0);
/* allocate and return a string that is the basename of argument */
static inline char *
AFR_BASENAME (const char *str)
{
- char *__tmp_str = NULL;
- char *__basename_str = NULL;
- __tmp_str = gf_strdup (str);
- __basename_str = gf_strdup (basename (__tmp_str));
- GF_FREE (__tmp_str);
- return __basename_str;
+ char *__tmp_str = NULL;
+ char *__basename_str = NULL;
+ __tmp_str = gf_strdup (str);
+ __basename_str = gf_strdup (basename (__tmp_str));
+ GF_FREE (__tmp_str);
+ return __basename_str;
}
/* initialize local_t */
@@ -818,35 +818,35 @@ AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
{
int child_up_count = 0;
- local->child_up = GF_CALLOC (sizeof (*local->child_up),
+ local->child_up = GF_CALLOC (sizeof (*local->child_up),
priv->child_count,
gf_afr_mt_char);
- if (!local->child_up) {
- return -ENOMEM;
- }
+ if (!local->child_up) {
+ return -ENOMEM;
+ }
- memcpy (local->child_up, priv->child_up,
- sizeof (*local->child_up) * priv->child_count);
+ memcpy (local->child_up, priv->child_up,
+ sizeof (*local->child_up) * priv->child_count);
child_up_count = afr_up_children_count (priv->child_count, local->child_up);
if (priv->optimistic_change_log && child_up_count == priv->child_count)
local->optimistic_change_log = 1;
- local->call_count = afr_up_children_count (priv->child_count, local->child_up);
- if (local->call_count == 0)
- return -ENOTCONN;
+ local->call_count = afr_up_children_count (priv->child_count, local->child_up);
+ if (local->call_count == 0)
+ return -ENOTCONN;
- local->transaction.erase_pending = 1;
+ local->transaction.erase_pending = 1;
- local->op_ret = -1;
- local->op_errno = EUCLEAN;
+ local->op_ret = -1;
+ local->op_errno = EUCLEAN;
local->internal_lock.lock_op_ret = -1;
local->internal_lock.lock_op_errno = EUCLEAN;
- return 0;
+ return 0;
}
@@ -857,23 +857,23 @@ AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
static inline int
afr_first_up_child (afr_private_t *priv)
{
- xlator_t ** children = NULL;
- int ret = -1;
- int i = 0;
-
- LOCK (&priv->lock);
- {
- children = priv->children;
- for (i = 0; i < priv->child_count; i++) {
- if (priv->child_up[i]) {
- ret = i;
- break;
- }
- }
- }
- UNLOCK (&priv->lock);
-
- return ret;
+ xlator_t ** children = NULL;
+ int ret = -1;
+ int i = 0;
+
+ LOCK (&priv->lock);
+ {
+ children = priv->children;
+ for (i = 0; i < priv->child_count; i++) {
+ if (priv->child_up[i]) {
+ ret = i;
+ break;
+ }
+ }
+ }
+ UNLOCK (&priv->lock);
+
+ return ret;
}
@@ -884,20 +884,20 @@ afr_transaction_local_init (afr_local_t *local, afr_private_t *priv)
local->first_up_child = afr_first_up_child (priv);
- local->child_errno = GF_CALLOC (sizeof (*local->child_errno),
- priv->child_count,
+ local->child_errno = GF_CALLOC (sizeof (*local->child_errno),
+ priv->child_count,
gf_afr_mt_int32_t);
- if (!local->child_errno) {
- return -ENOMEM;
- }
+ if (!local->child_errno) {
+ return -ENOMEM;
+ }
- local->pending = GF_CALLOC (sizeof (*local->pending),
+ local->pending = GF_CALLOC (sizeof (*local->pending),
priv->child_count,
gf_afr_mt_int32_t);
- if (!local->pending) {
- return -ENOMEM;
- }
+ if (!local->pending) {
+ return -ENOMEM;
+ }
for (i = 0; i < priv->child_count; i++) {
local->pending[i] = GF_CALLOC (sizeof (*local->pending[i]),
@@ -907,37 +907,37 @@ afr_transaction_local_init (afr_local_t *local, afr_private_t *priv)
return -ENOMEM;
}
- local->internal_lock.inode_locked_nodes =
+ local->internal_lock.inode_locked_nodes =
GF_CALLOC (sizeof (*local->internal_lock.inode_locked_nodes),
priv->child_count,
gf_afr_mt_char);
- local->internal_lock.entry_locked_nodes =
+ local->internal_lock.entry_locked_nodes =
GF_CALLOC (sizeof (*local->internal_lock.entry_locked_nodes),
priv->child_count,
gf_afr_mt_char);
- local->internal_lock.locked_nodes =
+ local->internal_lock.locked_nodes =
GF_CALLOC (sizeof (*local->internal_lock.locked_nodes),
priv->child_count,
gf_afr_mt_char);
- local->internal_lock.lower_locked_nodes
+ local->internal_lock.lower_locked_nodes
= GF_CALLOC (sizeof (*local->internal_lock.lower_locked_nodes),
priv->child_count,
gf_afr_mt_char);
- local->transaction.child_errno = GF_CALLOC (sizeof (*local->transaction.child_errno),
- priv->child_count,
+ local->transaction.child_errno = GF_CALLOC (sizeof (*local->transaction.child_errno),
+ priv->child_count,
gf_afr_mt_int32_t);
local->internal_lock.transaction_lk_type = AFR_TRANSACTION_LK;
- return 0;
+ return 0;
}
int32_t
afr_marker_getxattr (call_frame_t *frame, xlator_t *this,
- loc_t *loc, const char *name,afr_local_t *local, afr_private_t *priv );
+ loc_t *loc, const char *name,afr_local_t *local, afr_private_t *priv );
#endif /* __AFR_H__ */