summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2019-07-25 12:56:12 +0530
committerAmar Tumballi <amarts@redhat.com>2019-08-02 14:12:41 +0000
commit756f903e2adeaa520c848aa3c0664573cb584d07 (patch)
treeb4cd3bf24faa749a52b6eb0d550ffa3a1d87b4c2 /api
parent00084d5f0c84995d14fb3b626af227f60426e885 (diff)
gfapi: Fix deadlock while processing upcall
As mentioned in bug1733166, there could be potential deadlock while processing upcalls depending on how each xlator choose to act on it. The right way of fixing such issues is to change rpc callback communication process. - https://github.com/gluster/glusterfs/issues/697 Till then, making changes in gfapi layer to avoid any I/O processing. Change-Id: I2079e95339e5d761d5060707f4555cfacab95c83 fixes: bz#1733166 Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-fops.c164
1 files changed, 131 insertions, 33 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 396f18ccf5f..e6adea5ea9f 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -34,7 +34,7 @@
struct upcall_syncop_args {
struct glfs *fs;
- struct glfs_upcall *up_arg;
+ struct gf_upcall upcall_data;
};
#define READDIRBUF_SIZE (sizeof(struct dirent) + GF_NAME_MAX + 1)
@@ -5716,8 +5716,28 @@ out:
static int
upcall_syncop_args_free(struct upcall_syncop_args *args)
{
- if (args && args->up_arg)
- GLFS_FREE(args->up_arg);
+ dict_t *dict = NULL;
+ struct gf_upcall *upcall_data = NULL;
+
+ if (args) {
+ upcall_data = &args->upcall_data;
+ switch (upcall_data->event_type) {
+ case GF_UPCALL_CACHE_INVALIDATION:
+ dict = ((struct gf_upcall_cache_invalidation *)(upcall_data
+ ->data))
+ ->dict;
+ break;
+ case GF_UPCALL_RECALL_LEASE:
+ dict = ((struct gf_upcall_recall_lease *)(upcall_data->data))
+ ->dict;
+ break;
+ }
+ if (dict)
+ dict_unref(dict);
+
+ GF_FREE(upcall_data->client_uid);
+ GF_FREE(upcall_data->data);
+ }
GF_FREE(args);
return 0;
}
@@ -5727,14 +5747,7 @@ glfs_upcall_syncop_cbk(int ret, call_frame_t *frame, void *opaque)
{
struct upcall_syncop_args *args = opaque;
- /* Here we not using upcall_syncop_args_free as application
- * will be cleaning up the args->up_arg using glfs_free
- * post processing upcall.
- */
- if (ret) {
- upcall_syncop_args_free(args);
- } else
- GF_FREE(args);
+ (void)upcall_syncop_args_free(args);
return 0;
}
@@ -5743,29 +5756,17 @@ static int
glfs_cbk_upcall_syncop(void *opaque)
{
struct upcall_syncop_args *args = opaque;
+ struct gf_upcall *upcall_data = NULL;
struct glfs_upcall *up_arg = NULL;
struct glfs *fs;
+ int ret = -1;
fs = args->fs;
- up_arg = args->up_arg;
-
- if (fs->up_cbk && up_arg) {
- (fs->up_cbk)(up_arg, fs->up_data);
- return 0;
- }
-
- return -1;
-}
+ upcall_data = &args->upcall_data;
-static struct upcall_syncop_args *
-upcall_syncop_args_init(struct glfs *fs, struct gf_upcall *upcall_data)
-{
- struct upcall_syncop_args *args = NULL;
- int ret = -1;
- struct glfs_upcall *up_arg = NULL;
-
- if (!fs || !upcall_data)
+ if (!upcall_data) {
goto out;
+ }
up_arg = GLFS_CALLOC(1, sizeof(struct gf_upcall), glfs_release_upcall,
glfs_mt_upcall_entry_t);
@@ -5795,6 +5796,8 @@ upcall_syncop_args_init(struct glfs *fs, struct gf_upcall *upcall_data)
if (up_arg->reason == GLFS_UPCALL_EVENT_NULL) {
gf_msg(THIS->name, GF_LOG_DEBUG, errno, API_MSG_INVALID_ENTRY,
"Upcall_EVENT_NULL received. Skipping it.");
+ ret = 0;
+ GLFS_FREE(up_arg);
goto out;
} else if (ret) {
gf_msg(THIS->name, GF_LOG_ERROR, errno, API_MSG_INVALID_ENTRY,
@@ -5802,6 +5805,85 @@ upcall_syncop_args_init(struct glfs *fs, struct gf_upcall *upcall_data)
goto out;
}
+ if (fs->up_cbk && up_arg)
+ (fs->up_cbk)(up_arg, fs->up_data);
+
+ /* application takes care of calling glfs_free on up_arg post
+ * their processing */
+
+out:
+ return ret;
+}
+
+static struct gf_upcall_cache_invalidation *
+gf_copy_cache_invalidation(struct gf_upcall_cache_invalidation *src)
+{
+ struct gf_upcall_cache_invalidation *dst = NULL;
+
+ if (!src)
+ goto out;
+
+ dst = GF_CALLOC(1, sizeof(struct gf_upcall_cache_invalidation),
+ glfs_mt_upcall_entry_t);
+
+ if (!dst) {
+ gf_msg(THIS->name, GF_LOG_ERROR, ENOMEM, API_MSG_ALLOC_FAILED,
+ "Upcall entry allocation failed.");
+ goto out;
+ }
+
+ dst->flags = src->flags;
+ dst->expire_time_attr = src->expire_time_attr;
+ dst->stat = src->stat;
+ dst->p_stat = src->p_stat;
+ dst->oldp_stat = src->oldp_stat;
+
+ if (src->dict)
+ dst->dict = dict_copy_with_ref(src->dict, NULL);
+
+ return dst;
+out:
+ return NULL;
+}
+
+static struct gf_upcall_recall_lease *
+gf_copy_recall_lease(struct gf_upcall_recall_lease *src)
+{
+ struct gf_upcall_recall_lease *dst = NULL;
+
+ if (!src)
+ goto out;
+
+ dst = GF_CALLOC(1, sizeof(struct gf_upcall_recall_lease),
+ glfs_mt_upcall_entry_t);
+
+ if (!dst) {
+ gf_msg(THIS->name, GF_LOG_ERROR, ENOMEM, API_MSG_ALLOC_FAILED,
+ "Upcall entry allocation failed.");
+ goto out;
+ }
+
+ dst->lease_type = src->lease_type;
+ memcpy(dst->tid, src->tid, 16);
+
+ if (src->dict)
+ dst->dict = dict_copy_with_ref(src->dict, NULL);
+
+ return dst;
+out:
+ return NULL;
+}
+
+static struct upcall_syncop_args *
+upcall_syncop_args_init(struct glfs *fs, struct gf_upcall *upcall_data)
+{
+ struct upcall_syncop_args *args = NULL;
+ int ret = -1;
+ struct gf_upcall *t_data = NULL;
+
+ if (!fs || !upcall_data)
+ goto out;
+
args = GF_CALLOC(1, sizeof(struct upcall_syncop_args),
glfs_mt_upcall_entry_t);
if (!args) {
@@ -5819,15 +5901,31 @@ upcall_syncop_args_init(struct glfs *fs, struct gf_upcall *upcall_data)
* notification without taking any lock/ref.
*/
args->fs = fs;
- args->up_arg = up_arg;
+ t_data = &(args->upcall_data);
+ t_data->client_uid = gf_strdup(upcall_data->client_uid);
- /* application takes care of calling glfs_free on up_arg post
- * their processing */
+ gf_uuid_copy(t_data->gfid, upcall_data->gfid);
+ t_data->event_type = upcall_data->event_type;
+
+ switch (t_data->event_type) {
+ case GF_UPCALL_CACHE_INVALIDATION:
+ t_data->data = gf_copy_cache_invalidation(
+ (struct gf_upcall_cache_invalidation *)upcall_data->data);
+ break;
+ case GF_UPCALL_RECALL_LEASE:
+ t_data->data = gf_copy_recall_lease(
+ (struct gf_upcall_recall_lease *)upcall_data->data);
+ break;
+ }
+
+ if (!t_data->data)
+ goto out;
return args;
out:
- if (up_arg) {
- GLFS_FREE(up_arg);
+ if (ret) {
+ GF_FREE(args->upcall_data.client_uid);
+ GF_FREE(args);
}
return NULL;
-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -856,7 +856,7 @@ gsyncd_getpidfile (char *master, char *slave, char *pidfile,
snprintf (temp_conf_path, sizeof(temp_conf_path) - 1,
"%s/"GSYNC_CONF_TEMPLATE, priv->workdir);
- ret = lstat (conf_path, &stbuf);
+ ret = sys_lstat (conf_path, &stbuf);
if (!ret) {
gf_msg_debug (this->name, 0, "Using passed config template(%s).",
conf_path);
@@ -866,7 +866,7 @@ gsyncd_getpidfile (char *master, char *slave, char *pidfile,
GD_MSG_FILE_OP_FAILED,
"Config file (%s) missing. Looking for template "
"config file (%s)", conf_path, temp_conf_path);
- ret = lstat (temp_conf_path, &stbuf);
+ ret = sys_lstat (temp_conf_path, &stbuf);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, ENOENT,
GD_MSG_FILE_OP_FAILED,
@@ -1485,7 +1485,7 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo,
goto out;
}
- ret = lstat (statefile, &stbuf);
+ ret = sys_lstat (statefile, &stbuf);
if (ret) {
snprintf (msg, sizeof (msg), "Session between %s and %s has"
" not been created. Please create session and retry.",
@@ -2021,10 +2021,10 @@ glusterd_op_stage_sys_exec (dict_t *dict, char **op_errstr)
sprintf (command_path, GSYNCD_PREFIX"/peer_%s", command);
/* check if it's executable */
- ret = access (command_path, X_OK);
+ ret = sys_access (command_path, X_OK);
if (!ret)
/* check if it's a regular file */
- ret = stat (command_path, &st);
+ ret = sys_stat (command_path, &st);
if (!ret && !S_ISREG (st.st_mode))
ret = -1;
@@ -2105,7 +2105,7 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr)
snprintf (abs_filename, sizeof(abs_filename),
"%s/%s", priv->workdir, filename);
- ret = lstat (abs_filename, &stbuf);
+ ret = sys_lstat (abs_filename, &stbuf);
if (ret) {
snprintf (errmsg, sizeof (errmsg), "Source file"
" does not exist in %s", priv->workdir);
@@ -2168,7 +2168,7 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave,
snprintf (temp_conf_path, sizeof(temp_conf_path) - 1,
"%s/"GSYNC_CONF_TEMPLATE, priv->workdir);
- ret = lstat (conf_path, &stbuf);
+ ret = sys_lstat (conf_path, &stbuf);
if (!ret) {
gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_CONFIG_INFO,
"Using passed config template(%s).",
@@ -2179,7 +2179,7 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave,
GD_MSG_FILE_OP_FAILED,
"Config file (%s) missing. Looking for template config"
" file (%s)", conf_path, temp_conf_path);
- ret = lstat (temp_conf_path, &stbuf);
+ ret = sys_lstat (temp_conf_path, &stbuf);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, ENOENT,
GD_MSG_FILE_OP_FAILED, "Template "
@@ -2399,7 +2399,7 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol,
ret = 0;
out:
GF_FREE (slave_url_buf);
- unlink (log_file_path);
+ sys_unlink (log_file_path);
gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2636,7 +2636,7 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
conf->workdir);
hook_script[ret] = '\0';
- ret = lstat (common_pem_file, &stbuf);
+ ret = sys_lstat (common_pem_file, &stbuf);
if (ret) {
snprintf (errmsg, sizeof (errmsg), "%s"
" required for push-pem is"
@@ -2651,7 +2651,7 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
goto out;
}
- ret = lstat (hook_script, &stbuf);
+ ret = sys_lstat (hook_script, &stbuf);
if (ret) {
snprintf (errmsg, sizeof (errmsg),
"The hook-script (%s) required "
@@ -2703,7 +2703,7 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
goto out;
}
- ret = lstat (statefile, &stbuf);
+ ret = sys_lstat (statefile, &stbuf);
if (!ret && !is_force) {
snprintf (errmsg, sizeof (errmsg), "Session between %s"
" and %s is already created.",
@@ -2909,7 +2909,7 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
* as this command acts as a fail safe method to stop geo-rep
* session. */
if (!((type == GF_GSYNC_OPTION_TYPE_STOP) && is_force)) {
- ret = lstat (statefile, &stbuf);
+ ret = sys_lstat (statefile, &stbuf);
if (ret) {
snprintf (errmsg, sizeof(errmsg), "Geo-replication"
" session between %s and %s does not exist.",
@@ -3181,7 +3181,7 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
goto out;
}
- ret = read (pfd, buf, 1024);
+ ret = sys_read (pfd, buf, 1024);
if (ret > 0) {
pid = strtol (buf, NULL, 10);
if (is_pause) {
@@ -3317,7 +3317,7 @@ stop_gsync (char *master, char *slave, char **msg,
if (pfd < 0)
goto out;
- ret = read (pfd, buf, 1024);
+ ret = sys_read (pfd, buf, 1024);
if (ret > 0) {
pid = strtol (buf, NULL, 10);
ret = kill (-pid, SIGTERM);
@@ -3339,7 +3339,7 @@ stop_gsync (char *master, char *slave, char **msg,
usleep (50000);
}
kill (-pid, SIGKILL);
- unlink (pidfile);
+ sys_unlink (pidfile);
}
ret = 0;
@@ -3557,7 +3557,7 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
if ((!strcmp (op_name, "state_file")) && (op_value)) {
- ret = lstat (op_value, &stbuf);
+ ret = sys_lstat (op_value, &stbuf);
if (ret) {
ret = dict_get_str (dict, "slave_host", &slave_host);
if (ret) {
@@ -3580,7 +3580,7 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
slave_vol,
"Switching Status "
"File");
- if (ret || lstat (op_value, &stbuf)) {
+ if (ret || sys_lstat (op_value, &stbuf)) {
gf_msg (this->name, GF_LOG_ERROR, errno,
GD_MSG_FILE_OP_FAILED, "Unable to "
"create %s. Error : %s", op_value,
@@ -3635,7 +3635,7 @@ glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen)
"Unable to read gsyncd status file");
return -1;
}
- ret = read (status_fd, buf, blen - 1);
+ ret = sys_read (status_fd, buf, blen - 1);
if (ret > 0) {
size_t len = strnlen (buf, ret);
/* Ensure there is a NUL byte and that it's not the first. */
@@ -3650,7 +3650,7 @@ glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen)
gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR,
"Status file of gsyncd is corrupt");
- close (status_fd);
+ sys_close (status_fd);
return ret;
}
@@ -3811,7 +3811,7 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave,
snprintf (temp_conf_path, sizeof(temp_conf_path) - 1,
"%s/"GSYNC_CONF_TEMPLATE, priv->workdir);
- ret = lstat (conf_path, &stbuf);
+ ret = sys_lstat (conf_path, &stbuf);
if (!ret) {
gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_CONFIG_INFO,
"Using passed config template(%s).",
@@ -3822,7 +3822,7 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave,
GD_MSG_FILE_OP_FAILED,
"Config file (%s) missing. Looking for template "
"config file (%s)", conf_path, temp_conf_path);
- ret = lstat (temp_conf_path, &stbuf);
+ ret = sys_lstat (temp_conf_path, &stbuf);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, ENOENT,
GD_MSG_FILE_OP_FAILED, "Template "
@@ -4231,7 +4231,7 @@ glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo,
goto out;
}
- ret = lstat (statefile, &stbuf);
+ ret = sys_lstat (statefile, &stbuf);
if (ret) {
gf_msg (this->name, GF_LOG_INFO, ENOENT,
GD_MSG_FILE_OP_FAILED,
@@ -4433,7 +4433,7 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave,
volinfo->volname, slave_host, slave_vol);
geo_rep_dir[ret] = '\0';
- ret = rmdir (geo_rep_dir);
+ ret = sys_rmdir (geo_rep_dir);
if (ret) {
if (errno == ENOENT)
gf_msg_debug (this->name, 0, "Geo Rep Dir(%s) Not Present.",
@@ -4656,7 +4656,7 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
uuid_utoa_r (MY_UUID, uuid_str);
if (!strcmp (uuid_str, host_uuid)) {
- ret = lstat (abs_filename, &stbuf);
+ ret = sys_lstat (abs_filename, &stbuf);
if (ret) {
snprintf (errmsg, sizeof (errmsg), "Source file"
" does not exist in %s", priv->workdir);
@@ -4691,7 +4691,7 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
}
do {
- ret = read (fd, buf, sizeof(buf));
+ ret = sys_read (fd, buf, sizeof(buf));
if (ret > 0) {
memcpy (contents+bytes_read, buf, ret);
bytes_read += ret;
@@ -4785,7 +4785,7 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
goto out;
}
- bytes_writen = write (fd, contents, contents_size);
+ bytes_writen = sys_write (fd, contents, contents_size);
if (bytes_writen != contents_size) {
snprintf (errmsg, sizeof (errmsg), "Failed to write"
@@ -4797,13 +4797,13 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
goto out;
}
- fchmod (fd, file_mode);
+ sys_fchmod (fd, file_mode);
}
ret = 0;
out:
if (fd != -1)
- close (fd);
+ sys_close (fd);
if (free_contents)
GF_FREE(contents);
@@ -5541,13 +5541,13 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,
goto out;
}
- ret = lstat (conf_path, &stbuf);
+ ret = sys_lstat (conf_path, &stbuf);
if (!ret) {
gf_msg_debug (this->name, 0, "Session already running."
" Not creating config file again.");
} else {
ret = create_conf_file (conf, conf_path);
- if (ret || lstat (conf_path, &stbuf)) {
+ if (ret || sys_lstat (conf_path, &stbuf)) {
snprintf (errmsg, sizeof (errmsg), "Failed to create"
" config file(%s).", conf_path);
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -5556,7 +5556,7 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,
}
}
- ret = lstat (statefile, &stbuf);
+ ret = sys_lstat (statefile, &stbuf);
if (!ret) {
gf_msg_debug (this->name, 0, "Session already running."
" Not creating status file again.");
@@ -5565,7 +5565,7 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,
ret = glusterd_create_status_file (volinfo->volname, slave,
slave_host, slave_vol,
"Created");
- if (ret || lstat (statefile, &stbuf)) {
+ if (ret || sys_lstat (statefile, &stbuf)) {
snprintf (errmsg, sizeof (errmsg), "Unable to create %s"
". Error : %s", statefile, strerror (errno));
*op_errstr = gf_strdup (errmsg);
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index b01a70d62c4..24e0084a093 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -16,6 +16,7 @@
#include "protocol-common.h"
#include "xlator.h"
#include "logging.h"
+#include "syscall.h"
#include "timer.h"
#include "defaults.h"
#include "compat.h"
@@ -3215,12 +3216,12 @@ __glusterd_handle_umount (rpcsvc_request_t *req)
synclock_lock (&priv->big_lock);
if (rsp.op_ret == 0) {
if (realpath (umnt_req.path, mntp))
- rmdir (mntp);
+ sys_rmdir (mntp);
else {
rsp.op_ret = -1;
rsp.op_errno = errno;
}
- if (unlink (umnt_req.path) != 0) {
+ if (sys_unlink (umnt_req.path) != 0) {
rsp.op_ret = -1;
rsp.op_errno = errno;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index 7e3955465a4..e3f949aed0b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -11,6 +11,7 @@
#include "xlator.h"
#include "defaults.h"
#include "glusterfs.h"
+#include "syscall.h"
#include "compat-errno.h"
#include "glusterd.h"
@@ -306,7 +307,7 @@ gotvolinfo:
if (ret == -1)
goto out;
- ret = stat (path, &stbuf);
+ ret = sys_stat (path, &stbuf);
if ((ret == -1) && (errno == ENOENT)) {
strncpy (dup_volid, volid_ptr, (PATH_MAX - 1));
@@ -330,7 +331,7 @@ gotvolinfo:
path_prefix, volinfo->volname,
(trusted_str ? trusted_str : ""),
dup_volid);
- ret = stat (path, &stbuf);
+ ret = sys_stat (path, &stbuf);
}
out:
if (dup_volname)
@@ -798,7 +799,7 @@ __server_getspec (rpcsvc_request_t *req)
if (ret == 0) {
/* to allocate the proper buffer to hold the file data */
- ret = stat (filename, &stbuf);
+ ret = sys_stat (filename, &stbuf);
if (ret < 0){
gf_msg ("glusterd", GF_LOG_ERROR, errno,
GD_MSG_FILE_OP_FAILED,
@@ -828,7 +829,7 @@ __server_getspec (rpcsvc_request_t *req)
op_errno = ENOMEM;
goto fail;
}
- ret = read (spec_fd, rsp.spec, file_len);
+ ret = sys_read (spec_fd, rsp.spec, file_len);
}
if (brick_name) {
@@ -847,7 +848,7 @@ __server_getspec (rpcsvc_request_t *req)
/* convert to XDR */
fail:
if (spec_fd > 0)
- close (spec_fd);
+ sys_close (spec_fd);
rsp.op_ret = ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.c b/xlators/mgmt/glusterd/src/glusterd-hooks.c
index 4db5460c798..45a5912a1eb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-hooks.c
+++ b/xlators/mgmt/glusterd/src/glusterd-hooks.c
@@ -15,6 +15,7 @@
#include "logging.h"
#include "run.h"
#include "defaults.h"
+#include "syscall.h"
#include "compat.h"
#include "compat-errno.h"
#include "glusterd.h"
@@ -343,7 +344,7 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx,
goto out;
}
- hookdir = opendir (hooks_path);
+ hookdir = sys_opendir (hooks_path);
if (!hookdir) {
ret = -1;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -420,7 +421,7 @@ out:
}
if (hookdir)
- closedir (hookdir);
+ sys_closedir (hookdir);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
index 938a066e9a0..e1bb755fd3b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
@@ -16,6 +16,7 @@
#include "glusterd-utils.h"
#include "glusterd-volgen.h"
#include "glusterd-messages.h"
+#include "syscall.h"
#include <signal.h>
@@ -253,7 +254,7 @@ cont:
snprintf (logfile, PATH_MAX, "%s.%"PRIu64,
brickinfo->logfile, key);
- ret = rename (brickinfo->logfile, logfile);
+ ret = sys_rename (brickinfo->logfile, logfile);
if (ret)
gf_msg ("glusterd", GF_LOG_WARNING, errno,
GD_MSG_FILE_OP_FAILED, "rename failed");
diff --git a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
index 4ed2fb7035d..3125612d2cf 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
@@ -17,6 +17,7 @@
#include "dict.h"
#include "list.h"
#include "logging.h"
+#include "syscall.h"
#include "defaults.h"
#include "compat.h"
#include "compat-errno.h"
@@ -587,16 +588,16 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)
sla = strrchr (mtptemp, '/');
*sla = '\0';
- ret = mkdir (mtptemp, 0700);
+ ret = sys_mkdir (mtptemp, 0700);
if (ret == 0)
- ret = chown (mtptemp, uid, 0);
+ ret = sys_chown (mtptemp, uid, 0);
else if (errno == EEXIST)
ret = 0;
if (ret == -1) {
*op_errno = errno;
goto out;
}
- ret = lstat (mtptemp, &st);
+ ret = sys_lstat (mtptemp, &st);
if (ret == -1) {
*op_errno = errno;
goto out;
@@ -628,7 +629,7 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)
*op_errno = errno;
goto out;
}
- close (ret);
+ sys_close (ret);
/*** assembly the path from cookie to mountpoint */
sla = strchr (sla - 1, '/');
@@ -642,9 +643,9 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)
/*** create cookie link in (to-be) mountpoint,
move it over to the final place */
*cookieswitch = '/';
- ret = symlink (mntlink, mtptemp);
+ ret = sys_symlink (mntlink, mtptemp);
if (ret != -1)
- ret = rename (mtptemp, cookie);
+ ret = sys_rename (mtptemp, cookie);
*cookieswitch = '\0';
if (ret == -1) {
*op_errno = errno;
@@ -674,12 +675,12 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)
strerror (*op_errno));
if (mtptemp) {
*cookieswitch = '/';
- unlink (mtptemp);
+ sys_unlink (mtptemp);
*cookieswitch = '\0';
- rmdir (mtptemp);
+ sys_rmdir (mtptemp);
}
if (cookie) {
- unlink (cookie);
+ sys_unlink (cookie);
GF_FREE (cookie);
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 39c989fa53e..ed8fae1dc4b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1220,7 +1220,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
/* Checks whether a directory with
given option exists or not */
- if (!stat(trash_path, &stbuf)) {
+ if (!sys_stat (trash_path, &stbuf)) {
snprintf (errstr,
sizeof (errstr),
"Path %s exists",
@@ -2487,12 +2487,12 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
for (count = 1; ret != -1 ; count++) {
- sprintf (str, "key%d", count);
+ snprintf (str, sizeof str, "key%d", count);
ret = dict_get_str (dict, str, &key);
if (ret)
break;
- sprintf (str, "value%d", count);
+ snprintf (str, sizeof str, "value%d", count);
ret = dict_get_str (dict, str, &value);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c
index b95f73ea5a6..5fc7f2c48b5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-pmap.c
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c
@@ -10,6 +10,7 @@
#include "xlator.h"
#include "glusterfs.h"
+#include "syscall.h"
#include "compat-errno.h"
#include "glusterd.h"
@@ -42,7 +43,7 @@ pmap_port_isfree (int port)
return -1;
ret = bind (sock, (struct sockaddr *)&sin, sizeof (sin));
- close (sock);
+ sys_close (sock);
return (ret == 0) ? 1 : 0;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 074c767654b..863c87e40bf 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -764,7 +764,7 @@ glusterd_copy_to_tmp_file (int src_fd, int dst_fd)
this = THIS;
GF_ASSERT (this);
- while ((bytes_read = read (src_fd, (void *)&buf, entry_sz)) > 0) {
+ while ((bytes_read = sys_read (src_fd, (void *)&buf, entry_sz)) > 0) {
if (bytes_read % 16 != 0) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_QUOTA_CONF_CORRUPT, "quota.conf "
@@ -772,7 +772,7 @@ glusterd_copy_to_tmp_file (int src_fd, int dst_fd)
ret = -1;
goto out;
}
- ret = write (dst_fd, (void *) buf, bytes_read);
+ ret = sys_write (dst_fd, (void *) buf, bytes_read);
if (ret == -1) {
gf_msg (this->name, GF_LOG_ERROR, errno,
GD_MSG_QUOTA_CONF_WRITE_FAIL,
@@ -834,7 +834,7 @@ glusterd_store_quota_conf_upgrade (glusterd_volinfo_t *volinfo)
out:
if (conf_fd != -1)
- close (conf_fd);
+ sys_close (conf_fd);
if (ret && (fd > 0)) {
gf_store_unlink_tmppath (volinfo->quota_conf_shandle);
@@ -906,7 +906,7 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
if (version < 1.2f && conf->op_version >= GD_OP_VERSION_3_7_0) {
/* Upgrade quota.conf file to newer format */
- close (conf_fd);
+ sys_close (conf_fd);
ret = glusterd_store_quota_conf_upgrade(volinfo);
if (ret)
goto out;
@@ -959,7 +959,7 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
type = GF_QUOTA_CONF_TYPE_USAGE;
for (;;) {
- bytes_read = read (conf_fd, (void *)&buf, sizeof (buf));
+ bytes_read = sys_read (conf_fd, (void *)&buf, sizeof (buf));
if (bytes_read <= 0) {
/*The flag @is_first_read is TRUE when the loop is
* entered, and is set to false if the first read
@@ -983,7 +983,7 @@ glusterd_store_quota_config (glusterd