"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xlators/cluster/afr/src/afr-inode-read.c" between
glusterfs-8.4.tar.gz and glusterfs-8.5.tar.gz

About: GlusterFS is a network/cluster filesystem. The storage server (or each in a cluster) runs glusterfsd and the clients use mount command or glusterfs client to mount the exported filesystem. Release series 8.x.

afr-inode-read.c  (glusterfs-8.4):afr-inode-read.c  (glusterfs-8.5)
skipping to change at line 18 skipping to change at line 18
cases as published by the Free Software Foundation. cases as published by the Free Software Foundation.
*/ */
#include <libgen.h> #include <libgen.h>
#include <unistd.h> #include <unistd.h>
#include <fnmatch.h> #include <fnmatch.h>
#include <sys/time.h> #include <sys/time.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <urcu/uatomic.h>
#include <glusterfs/glusterfs.h> #include <glusterfs/glusterfs.h>
#include "afr.h" #include "afr.h"
#include <glusterfs/dict.h> #include <glusterfs/dict.h>
#include <glusterfs/logging.h> #include <glusterfs/logging.h>
#include <glusterfs/list.h> #include <glusterfs/list.h>
#include <glusterfs/byte-order.h> #include <glusterfs/byte-order.h>
#include <glusterfs/defaults.h> #include <glusterfs/defaults.h>
#include <glusterfs/common-utils.h> #include <glusterfs/common-utils.h>
#include <glusterfs/compat-errno.h> #include <glusterfs/compat-errno.h>
#include <glusterfs/compat.h> #include <glusterfs/compat.h>
skipping to change at line 869 skipping to change at line 871
op_ret = local->replies[read_subvol].op_ret; op_ret = local->replies[read_subvol].op_ret;
op_errno = local->replies[read_subvol].op_errno; op_errno = local->replies[read_subvol].op_errno;
dict = local->replies[read_subvol].xdata; dict = local->replies[read_subvol].xdata;
} }
AFR_STACK_UNWIND(getxattr, frame, op_ret, op_errno, dict, xdata); AFR_STACK_UNWIND(getxattr, frame, op_ret, op_errno, dict, xdata);
} }
return 0; return 0;
} }
int32_t static int32_t
afr_getxattr_lockinfo_cbk(call_frame_t *frame, void *cookie, xlator_t *this, afr_update_local_dicts(call_frame_t *frame, dict_t *dict, dict_t *xdata)
int32_t op_ret, int32_t op_errno, dict_t *dict,
dict_t *xdata)
{ {
int call_cnt = 0, len = 0; afr_local_t *local;
char *lockinfo_buf = NULL; dict_t *local_dict;
dict_t *lockinfo = NULL, *newdict = NULL; dict_t *local_xdata;
afr_local_t *local = NULL; int32_t ret;
LOCK(&frame->lock);
{
local = frame->local;
call_cnt = --local->call_count; local = frame->local;
local_dict = NULL;
local_xdata = NULL;
if ((op_ret < 0) || (!dict && !xdata)) { ret = -ENOMEM;
goto unlock;
}
if (xdata) { if ((dict != NULL) && (local->dict == NULL)) {
if (!local->xdata_rsp) { local_dict = dict_new();
local->xdata_rsp = dict_new(); if (local_dict == NULL) {
if (!local->xdata_rsp) { goto done;
local->op_ret = -1;
local->op_errno = ENOMEM;
goto unlock;
}
}
} }
}
if (!dict) { if ((xdata != NULL) && (local->xdata_rsp == NULL)) {
goto unlock; local_xdata = dict_new();
if (local_xdata == NULL) {
goto done;
} }
}
op_ret = dict_get_ptr_and_len(dict, GF_XATTR_LOCKINFO_KEY, if ((local_dict != NULL) || (local_xdata != NULL)) {
(void **)&lockinfo_buf, &len); /* TODO: Maybe it would be better to preallocate both dicts before
* sending the requests. This way we don't need to use a LOCK()
* here. */
LOCK(&frame->lock);
if (!lockinfo_buf) { if ((local_dict != NULL) && (local->dict == NULL)) {
goto unlock; local->dict = local_dict;
local_dict = NULL;
} }
if (!local->dict) { if ((local_xdata != NULL) && (local->xdata_rsp == NULL)) {
local->dict = dict_new(); local->xdata_rsp = local_xdata;
if (!local->dict) { local_xdata = NULL;
local->op_ret = -1;
local->op_errno = ENOMEM;
goto unlock;
}
} }
}
unlock:
UNLOCK(&frame->lock);
if (lockinfo_buf != NULL) { UNLOCK(&frame->lock);
lockinfo = dict_new();
if (lockinfo == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
} else {
op_ret = dict_unserialize(lockinfo_buf, len, &lockinfo);
if (lockinfo && local->dict) {
dict_copy(lockinfo, local->dict);
}
}
} }
if (xdata && local->xdata_rsp) { if (dict != NULL) {
dict_copy(xdata, local->xdata_rsp); if (dict_copy(dict, local->dict) < 0) {
goto done;
}
} }
if (!call_cnt) { if (xdata != NULL) {
newdict = dict_new(); if (dict_copy(xdata, local->xdata_rsp) < 0) {
if (!newdict) { goto done;
local->op_ret = -1;
local->op_errno = ENOMEM;
goto unwind;
}
op_ret = dict_allocate_and_serialize(
local->dict, (char **)&lockinfo_buf, (unsigned int *)&len);
if (op_ret != 0) {
local->op_ret = -1;
goto unwind;
} }
}
op_ret = dict_set_dynptr(newdict, GF_XATTR_LOCKINFO_KEY, ret = 0;
(void *)lockinfo_buf, len);
if (op_ret < 0) {
local->op_ret = -1;
local->op_errno = -op_ret;
goto unwind;
}
unwind: done:
AFR_STACK_UNWIND(getxattr, frame, op_ret, op_errno, newdict, if (local_dict != NULL) {
local->xdata_rsp); dict_unref(local_dict);
} }
dict_unref(lockinfo); if (local_xdata != NULL) {
dict_unref(local_xdata);
}
return 0; return ret;
} }
int32_t static void
afr_fgetxattr_lockinfo_cbk(call_frame_t *frame, void *cookie, xlator_t *this, afr_getxattr_lockinfo_cbk_common(call_frame_t *frame, int32_t op_ret,
int32_t op_ret, int32_t op_errno, dict_t *dict, int32_t op_errno, dict_t *dict, dict_t *xdata,
dict_t *xdata) bool is_fgetxattr)
{ {
int call_cnt = 0, len = 0; int len = 0;
char *lockinfo_buf = NULL; char *lockinfo_buf = NULL;
dict_t *lockinfo = NULL, *newdict = NULL; dict_t *lockinfo = NULL, *newdict = NULL;
afr_local_t *local = NULL; afr_local_t *local = NULL;
LOCK(&frame->lock); local = frame->local;
{
local = frame->local;
call_cnt = --local->call_count;
if ((op_ret < 0) || (!dict && !xdata)) {
goto unlock;
}
if (xdata) {
if (!local->xdata_rsp) {
local->xdata_rsp = dict_new();
if (!local->xdata_rsp) {
local->op_ret = -1;
local->op_errno = ENOMEM;
goto unlock;
}
}
}
if (!dict) {
goto unlock;
}
if ((op_ret >= 0) && (dict != NULL)) {
op_ret = dict_get_ptr_and_len(dict, GF_XATTR_LOCKINFO_KEY, op_ret = dict_get_ptr_and_len(dict, GF_XATTR_LOCKINFO_KEY,
(void **)&lockinfo_buf, &len); (void **)&lockinfo_buf, &len);
if (lockinfo_buf != NULL) {
if (!lockinfo_buf) { lockinfo = dict_new();
goto unlock; if (lockinfo == NULL) {
} op_ret = -1;
} else {
if (!local->dict) { op_ret = dict_unserialize(lockinfo_buf, len, &lockinfo);
local->dict = dict_new();
if (!local->dict) {
local->op_ret = -1;
local->op_errno = ENOMEM;
goto unlock;
} }
} }
} }
unlock:
UNLOCK(&frame->lock);
if (lockinfo_buf != NULL) { if ((op_ret >= 0) && ((lockinfo != NULL) || (xdata != NULL))) {
lockinfo = dict_new(); op_ret = afr_update_local_dicts(frame, lockinfo, xdata);
if (lockinfo == NULL) { if (lockinfo != NULL) {
local->op_ret = -1; dict_unref(lockinfo);
local->op_errno = ENOMEM;
} else {
op_ret = dict_unserialize(lockinfo_buf, len, &lockinfo);
if (lockinfo && local->dict) {
dict_copy(lockinfo, local->dict);
}
} }
} }
if (xdata && local->xdata_rsp) { if (op_ret < 0) {
dict_copy(xdata, local->xdata_rsp); local->op_ret = -1;
local->op_errno = ENOMEM;
} }
if (!call_cnt) { if (uatomic_sub_return(&local->call_count, 1) == 0) {
newdict = dict_new(); newdict = dict_new();
if (!newdict) { if (!newdict) {
local->op_ret = -1; local->op_ret = -1;
local->op_errno = ENOMEM; local->op_errno = op_errno = ENOMEM;
goto unwind; goto unwind;
} }
op_ret = dict_allocate_and_serialize( op_ret = dict_allocate_and_serialize(
local->dict, (char **)&lockinfo_buf, (unsigned int *)&len); local->dict, (char **)&lockinfo_buf, (unsigned int *)&len);
if (op_ret != 0) { if (op_ret != 0) {
local->op_ret = -1; local->op_ret = -1;
local->op_errno = op_errno = ENOMEM;
goto unwind; goto unwind;
} }
op_ret = dict_set_dynptr(newdict, GF_XATTR_LOCKINFO_KEY, op_ret = dict_set_dynptr(newdict, GF_XATTR_LOCKINFO_KEY,
(void *)lockinfo_buf, len); (void *)lockinfo_buf, len);
if (op_ret < 0) { if (op_ret < 0) {
local->op_ret = -1; GF_FREE(lockinfo_buf);
local->op_errno = -op_ret; local->op_ret = op_ret = -1;
local->op_errno = op_errno = -op_ret;
goto unwind; goto unwind;
} }
unwind: unwind:
AFR_STACK_UNWIND(fgetxattr, frame, op_ret, op_errno, newdict, /* TODO: These unwinds use op_ret and op_errno instead of local->op_ret
local->xdata_rsp); * and local->op_errno. This doesn't seem right because any
* failure during processing of each answer could be silently
* ignored. This is kept this was the old behavior and because
* local->op_ret is initialized as -1 and local->op_errno is
* initialized as EUCLEAN, which makes these values useless. */
if (is_fgetxattr) {
AFR_STACK_UNWIND(fgetxattr, frame, op_ret, op_errno, newdict,
local->xdata_rsp);
} else {
AFR_STACK_UNWIND(getxattr, frame, op_ret, op_errno, newdict,
local->xdata_rsp);
}
if (newdict != NULL) {
dict_unref(newdict);
}
} }
}
dict_unref(lockinfo); static int32_t
afr_getxattr_lockinfo_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict,
dict_t *xdata)
{
afr_getxattr_lockinfo_cbk_common(frame, op_ret, op_errno, dict, xdata,
false);
return 0;
}
static int32_t
afr_fgetxattr_lockinfo_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict,
dict_t *xdata)
{
afr_getxattr_lockinfo_cbk_common(frame, op_ret, op_errno, dict, xdata,
true);
return 0; return 0;
} }
int32_t int32_t
afr_fgetxattr_pathinfo_cbk(call_frame_t *frame, void *cookie, xlator_t *this, afr_fgetxattr_pathinfo_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict, int32_t op_ret, int32_t op_errno, dict_t *dict,
dict_t *xdata) dict_t *xdata)
{ {
afr_local_t *local = NULL; afr_local_t *local = NULL;
 End of changes. 36 change blocks. 
142 lines changed or deleted 112 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)