From 0cab34b3a5e94267bf6b39669b6e85af1fab8f3d Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Fri, 7 Feb 2014 14:29:34 -0800 Subject: core: add @xdata parameter to syncop_[f]removexattr() To be used in afr metadata self-heal Change-Id: I8dac4b19d61e331702427eeb5b606aab3d20b328 BUG: 1021686 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/6941 Tested-by: Gluster Build System Reviewed-by: Raghavendra Bhat --- api/src/glfs-fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'api') diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index f27287b9d..4bf33b859 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -2832,7 +2832,7 @@ retry: if (ret) goto out; - ret = syncop_removexattr (subvol, &loc, name); + ret = syncop_removexattr (subvol, &loc, name, 0); DECODE_SYNCOP_ERR (ret); ESTALE_RETRY (ret, errno, reval, &loc, retry); @@ -2883,7 +2883,7 @@ glfs_fremovexattr (struct glfs_fd *glfd, const char *name) goto out; } - ret = syncop_fremovexattr (subvol, fd, name); + ret = syncop_fremovexattr (subvol, fd, name, 0); DECODE_SYNCOP_ERR (ret); out: if (fd) -- cgit From 5f0a857c70863eb685ac03d4183502d3bd460b7c Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Wed, 5 Feb 2014 08:50:30 -0600 Subject: libgfapi: Add proper NULL checks Two spots check for NULL after the pointer in question has already been dereferenced. Checked for NULL (and set errno when needed) at appripriate spots, added a few NULL checks further up the stack, and some whitespace cleanup. BUG: 789278 CID: 1124800 CID: 1124805 Change-Id: I1dd4ad3f285cca36f4e3f739288f154ec120aebb Signed-off-by: Jose A. Rivera Reviewed-on: http://review.gluster.org/6908 Reviewed-by: Shyamsundar Ranganathan Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- api/src/glfs-mgmt.c | 48 ++++++++++++++++++++++++++++++------------------ api/src/glfs.c | 14 ++++++++++++++ 2 files changed, 44 insertions(+), 18 deletions(-) (limited to 'api') diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c index 6843e9cb3..afb351da0 100644 --- a/api/src/glfs-mgmt.c +++ b/api/src/glfs-mgmt.c @@ -236,11 +236,19 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, int ret = 0; ssize_t size = 0; FILE *tmpfp = NULL; - int need_retry = 0; + int need_retry = 0; struct glfs *fs = NULL; frame = myframe; ctx = frame->this->ctx; + + if (!ctx) { + gf_log (frame->this->name, GF_LOG_ERROR, "NULL context"); + errno = EINVAL; + ret = -1; + goto out; + } + fs = ((xlator_t *)ctx->master)->private; if (-1 == req->rpc_status) { @@ -260,7 +268,7 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_log (frame->this->name, GF_LOG_ERROR, "failed to get the 'volume file' from server"); ret = -1; - errno = rsp.op_errno; + errno = rsp.op_errno; goto out; } @@ -296,7 +304,7 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, */ ret = glusterfs_volfile_reconfigure (fs->oldvollen, tmpfp, fs->ctx, - fs->oldvolfile); + fs->oldvolfile); if (ret == 0) { gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, "No need to re-load volfile, reconfigure done"); @@ -323,13 +331,13 @@ out: if (rsp.spec) free (rsp.spec); - // Stop if server is running at an unsupported op-version - if (ENOTSUP == ret) { - gf_log ("mgmt", GF_LOG_ERROR, "Server is operating at an " - "op-version which is not supported"); - errno = ENOTSUP; - glfs_init_done (fs, -1); - } + // Stop if server is running at an unsupported op-version + if (ENOTSUP == ret) { + gf_log ("mgmt", GF_LOG_ERROR, "Server is operating at an " + "op-version which is not supported"); + errno = ENOTSUP; + glfs_init_done (fs, -1); + } if (ret && ctx && !ctx->active) { /* Do it only for the first time */ @@ -339,10 +347,10 @@ out: "failed to fetch volume file (key:%s)", ctx->cmd_args.volfile_id); if (!need_retry) { - if (!errno) - errno = EINVAL; + if (!errno) + errno = EINVAL; glfs_init_done (fs, -1); - } + } } if (tmpfp) @@ -420,6 +428,10 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, this = mydata; ctx = this->ctx; + + if (!ctx) + goto out; + fs = ((xlator_t *)ctx->master)->private; cmd_args = &ctx->cmd_args; @@ -434,22 +446,22 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, "%d connect attempts left", cmd_args->max_connect_attempts); if (0 >= cmd_args->max_connect_attempts) { - errno = ENOTCONN; + errno = ENOTCONN; glfs_init_done (fs, -1); - } + } } break; case RPC_CLNT_CONNECT: rpc_clnt_set_connected (&((struct rpc_clnt*)ctx->mgmt)->conn); ret = glfs_volfile_fetch (fs); - if (ret && ctx && (ctx->active == NULL)) { + if (ret && (ctx->active == NULL)) { /* Do it only for the first time */ /* Exit the process.. there are some wrong options */ gf_log ("glfs-mgmt", GF_LOG_ERROR, "failed to fetch volume file (key:%s)", ctx->cmd_args.volfile_id); - errno = EINVAL; + errno = EINVAL; glfs_init_done (fs, -1); } @@ -457,7 +469,7 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, default: break; } - +out: return 0; } diff --git a/api/src/glfs.c b/api/src/glfs.c index 174076e39..ea10fb55c 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -589,6 +589,13 @@ glfs_init_async (struct glfs *fs, glfs_init_cbk cbk) { int ret = -1; + if (!fs || !fs->ctx) { + gf_log ("glfs", GF_LOG_ERROR, + "fs is not properly initialized."); + errno = EINVAL; + return ret; + } + fs->init_cbk = cbk; ret = glfs_init_common (fs); @@ -602,6 +609,13 @@ glfs_init (struct glfs *fs) { int ret = -1; + if (!fs || !fs->ctx) { + gf_log ("glfs", GF_LOG_ERROR, + "fs is not properly initialized."); + errno = EINVAL; + return ret; + } + ret = glfs_init_common (fs); if (ret) return ret; -- cgit From ff0cd7c4e326d848d5fa6591c7cc8ce54711d2d7 Mon Sep 17 00:00:00 2001 From: Poornima G Date: Wed, 19 Feb 2014 14:12:29 +0530 Subject: libgfapi: In glfs_resolve_at(), do not override the previous return value. Overriding ret to contain glfs_loc_touchup()s' return value implies that if glfs_loc_touchup() is successful, glfs_resolve_at() is also successful which is not necessarily true. This was causing glfs_resolve_at() to succeed even if it couldn't resolve, thus create and other fops would fail. Hence overriding ret only if glfs_loc_touchup() fails. Change-Id: I0804afbd120b3798abe07e870bfc40bf162bc289 BUG: 1066837 Signed-off-by: Poornima G Reviewed-on: http://review.gluster.org/7125 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- api/src/glfs-resolve.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'api') diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index 0ad9ce723..7cd1e47bc 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -450,7 +450,9 @@ glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at, ret = 0; } - ret = glfs_loc_touchup (loc); + if (glfs_loc_touchup (loc) < 0) { + ret = -1; + } out: GF_FREE (path); -- cgit