summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/glfs-fops.c36
-rw-r--r--api/src/glfs-handleops.c15
-rw-r--r--api/src/glfs-internal.h20
-rw-r--r--api/src/glfs-resolve.c10
-rw-r--r--libglusterfs/src/syncop.c117
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c44
-rw-r--r--xlators/cluster/afr/src/pump.c6
-rw-r--r--xlators/cluster/dht/src/dht-helper.c24
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c176
-rw-r--r--xlators/cluster/dht/src/dht-selfheal.c5
-rw-r--r--xlators/features/locks/src/posix.c3
-rw-r--r--xlators/features/qemu-block/src/bdrv-xlator.c15
-rw-r--r--xlators/features/qemu-block/src/qb-coroutines.c15
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c18
14 files changed, 343 insertions, 161 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 5ea54567d74..67d5616fe21 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -124,6 +124,7 @@ retry:
}
ret = syncop_open (subvol, &loc, flags, glfd->fd);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
out:
@@ -169,6 +170,7 @@ glfs_close (struct glfs_fd *glfd)
}
ret = syncop_flush (subvol, fd);
+ DECODE_SYNCOP_ERR (ret);
out:
fs = glfd->fs;
glfs_fd_destroy (glfd);
@@ -273,6 +275,7 @@ glfs_fstat (struct glfs_fd *glfd, struct stat *stat)
}
ret = syncop_fstat (subvol, fd, &iatt);
+ DECODE_SYNCOP_ERR (ret);
if (ret == 0 && stat)
glfs_iatt_to_stat (glfd->fs, &iatt, stat);
@@ -392,9 +395,11 @@ retry:
if (ret == 0) {
ret = syncop_open (subvol, &loc, flags, glfd->fd);
+ DECODE_SYNCOP_ERR (ret);
} else {
ret = syncop_create (subvol, &loc, flags, mode, glfd->fd,
xattr_req, &iatt);
+ DECODE_SYNCOP_ERR (ret);
}
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -484,6 +489,7 @@ glfs_preadv (struct glfs_fd *glfd, const struct iovec *iovec, int iovcnt,
size = iov_length (iovec, iovcnt);
ret = syncop_readv (subvol, fd, size, offset, 0, &iov, &cnt, &iobref);
+ DECODE_SYNCOP_ERR (ret);
if (ret <= 0)
goto out;
@@ -833,6 +839,7 @@ glfs_pwritev (struct glfs_fd *glfd, const struct iovec *iovec, int iovcnt,
iov.iov_len = size;
ret = syncop_writev (subvol, fd, &iov, 1, offset, iobref, flags);
+ DECODE_SYNCOP_ERR (ret);
iobuf_unref (iobuf);
iobref_unref (iobref);
@@ -1005,6 +1012,7 @@ glfs_fsync (struct glfs_fd *glfd)
}
ret = syncop_fsync (subvol, fd, 0);
+ DECODE_SYNCOP_ERR (ret);
out:
if (fd)
fd_unref (fd);
@@ -1079,6 +1087,7 @@ glfs_fdatasync (struct glfs_fd *glfd)
}
ret = syncop_fsync (subvol, fd, 1);
+ DECODE_SYNCOP_ERR (ret);
out:
if (fd)
fd_unref (fd);
@@ -1120,6 +1129,7 @@ glfs_ftruncate (struct glfs_fd *glfd, off_t offset)
}
ret = syncop_ftruncate (subvol, fd, offset);
+ DECODE_SYNCOP_ERR (ret);
out:
if (fd)
fd_unref (fd);
@@ -1188,6 +1198,7 @@ retry:
goto out;
ret = syncop_access (subvol, &loc, mode);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
out:
@@ -1263,6 +1274,7 @@ retry:
}
ret = syncop_symlink (subvol, &loc, data, xattr_req, &iatt);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -1313,6 +1325,7 @@ retry:
}
ret = syncop_readlink (subvol, &loc, &linkval, bufsiz);
+ DECODE_SYNCOP_ERR (ret);
if (ret > 0) {
memcpy (buf, linkval, ret);
GF_FREE (linkval);
@@ -1392,6 +1405,7 @@ retry:
}
ret = syncop_mknod (subvol, &loc, mode, dev, xattr_req, &iatt);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -1473,6 +1487,7 @@ retry:
}
ret = syncop_mkdir (subvol, &loc, mode, xattr_req, &iatt);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -1522,6 +1537,7 @@ retry:
}
ret = syncop_unlink (subvol, &loc);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -1568,6 +1584,7 @@ retry:
}
ret = syncop_rmdir (subvol, &loc, 0);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -1631,6 +1648,7 @@ retrynew:
/* TODO: check if new or old is a prefix of the other, and fail EINVAL */
ret = syncop_rename (subvol, &oldloc, &newloc);
+ DECODE_SYNCOP_ERR (ret);
if (ret == -1 && errno == ESTALE) {
if (reval < DEFAULT_REVAL_COUNT) {
@@ -1708,6 +1726,7 @@ retrynew:
newloc.inode = inode_ref (oldloc.inode);
ret = syncop_link (subvol, &oldloc, &newloc);
+ DECODE_SYNCOP_ERR (ret);
if (ret == -1 && errno == ESTALE) {
loc_wipe (&oldloc);
@@ -1782,6 +1801,7 @@ retry:
}
ret = syncop_opendir (subvol, &loc, glfd->fd);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
out:
@@ -1972,6 +1992,7 @@ glfd_entry_refresh (struct glfs_fd *glfd, int plus)
else
ret = syncop_readdir (subvol, fd, 131072, glfd->offset,
&entries);
+ DECODE_SYNCOP_ERR (ret);
if (ret >= 0) {
if (plus)
gf_link_inodes_from_dirent (THIS, fd->inode, &entries);
@@ -2150,6 +2171,7 @@ retry:
goto out;
ret = syncop_statfs (subvol, &loc, buf);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
out:
@@ -2191,6 +2213,7 @@ retry:
goto out;
ret = syncop_setattr (subvol, &loc, iatt, valid, 0, 0);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
out:
@@ -2226,6 +2249,7 @@ glfs_fsetattr (struct glfs_fd *glfd, struct iatt *iatt, int valid)
}
ret = syncop_fsetattr (subvol, fd, iatt, valid, 0, 0);
+ DECODE_SYNCOP_ERR (ret);
out:
if (fd)
fd_unref (fd);
@@ -2442,6 +2466,7 @@ retry:
goto out;
ret = syncop_getxattr (subvol, &loc, &xattr, name);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -2500,6 +2525,7 @@ glfs_fgetxattr (struct glfs_fd *glfd, const char *name, void *value,
}
ret = syncop_fgetxattr (subvol, fd, &xattr, name);
+ DECODE_SYNCOP_ERR (ret);
if (ret)
goto out;
@@ -2570,6 +2596,7 @@ retry:
goto out;
ret = syncop_getxattr (subvol, &loc, &xattr, NULL);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -2625,6 +2652,7 @@ glfs_flistxattr (struct glfs_fd *glfd, void *value, size_t size)
}
ret = syncop_fgetxattr (subvol, fd, &xattr, NULL);
+ DECODE_SYNCOP_ERR (ret);
if (ret)
goto out;
@@ -2697,6 +2725,7 @@ retry:
}
ret = syncop_setxattr (subvol, &loc, xattr, flags);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -2760,6 +2789,7 @@ glfs_fsetxattr (struct glfs_fd *glfd, const char *name, const void *value,
}
ret = syncop_fsetxattr (subvol, fd, xattr, flags);
+ DECODE_SYNCOP_ERR (ret);
out:
if (xattr)
dict_unref (xattr);
@@ -2803,6 +2833,7 @@ retry:
goto out;
ret = syncop_removexattr (subvol, &loc, name);
+ DECODE_SYNCOP_ERR (ret);
ESTALE_RETRY (ret, errno, reval, &loc, retry);
@@ -2853,6 +2884,7 @@ glfs_fremovexattr (struct glfs_fd *glfd, const char *name)
}
ret = syncop_fremovexattr (subvol, fd, name);
+ DECODE_SYNCOP_ERR (ret);
out:
if (fd)
fd_unref (fd);
@@ -2887,6 +2919,7 @@ glfs_fallocate (struct glfs_fd *glfd, int keep_size, off_t offset, size_t len)
}
ret = syncop_fallocate (subvol, fd, keep_size, offset, len);
+ DECODE_SYNCOP_ERR (ret);
out:
if (fd)
fd_unref(fd);
@@ -2921,6 +2954,7 @@ glfs_discard (struct glfs_fd *glfd, off_t offset, size_t len)
}
ret = syncop_discard (subvol, fd, offset, len);
+ DECODE_SYNCOP_ERR (ret);
out:
if (fd)
fd_unref(fd);
@@ -2952,6 +2986,7 @@ glfs_zerofill (struct glfs_fd *glfd, off_t offset, off_t len)
}
ret = syncop_zerofill (subvol, fd, offset, len);
+ DECODE_SYNCOP_ERR (ret);
out:
if (fd)
fd_unref(fd);
@@ -3200,6 +3235,7 @@ glfs_posix_lock (struct glfs_fd *glfd, int cmd, struct flock *flock)
gf_flock_from_flock (&gf_flock, flock);
gf_flock_from_flock (&saved_flock, flock);
ret = syncop_lk (subvol, fd, cmd, &gf_flock);
+ DECODE_SYNCOP_ERR (ret);
gf_flock_to_flock (&gf_flock, flock);
if (ret == 0 && (cmd == F_SETLK || cmd == F_SETLKW))
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index 0f996d3a2da..5bba38b5f0c 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -152,6 +152,7 @@ glfs_h_stat (struct glfs *fs, struct glfs_object *object, struct stat *stat)
/* fop/op */
ret = syncop_stat (subvol, &loc, &iatt);
+ DECODE_SYNCOP_ERR (ret);
/* populate out args */
if (!ret && stat) {
@@ -258,6 +259,7 @@ glfs_h_setattrs (struct glfs *fs, struct glfs_object *object, struct stat *stat,
/* fop/op */
ret = syncop_setattr (subvol, &loc, &iatt, glvalid, 0, 0);
+ DECODE_SYNCOP_ERR (ret);
out:
loc_wipe (&loc);
@@ -331,6 +333,7 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags)
/* fop/op */
ret = syncop_open (subvol, &loc, flags, glfd->fd);
+ DECODE_SYNCOP_ERR (ret);
out:
loc_wipe (&loc);
@@ -420,6 +423,7 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,
/* fop/op */
ret = syncop_create (subvol, &loc, flags, mode, glfd->fd,
xattr_req, &iatt);
+ DECODE_SYNCOP_ERR (ret);
/* populate out args */
if (ret == 0) {
@@ -518,6 +522,7 @@ glfs_h_mkdir (struct glfs *fs, struct glfs_object *parent, const char *path,
/* fop/op */
ret = syncop_mkdir (subvol, &loc, mode, xattr_req, &iatt);
+ DECODE_SYNCOP_ERR (ret);
/* populate out args */
if ( ret == 0 ) {
@@ -606,6 +611,7 @@ glfs_h_mknod (struct glfs *fs, struct glfs_object *parent, const char *path,
/* fop/op */
ret = syncop_mknod (subvol, &loc, mode, dev, xattr_req, &iatt);
+ DECODE_SYNCOP_ERR (ret);
/* populate out args */
if (ret == 0) {
@@ -676,11 +682,13 @@ glfs_h_unlink (struct glfs *fs, struct glfs_object *parent, const char *path)
if (!IA_ISDIR(loc.inode->ia_type)) {
ret = syncop_unlink (subvol, &loc);
+ DECODE_SYNCOP_ERR (ret);
if (ret != 0) {
goto out;
}
} else {
ret = syncop_rmdir (subvol, &loc, 0);
+ DECODE_SYNCOP_ERR (ret);
if (ret != 0) {
goto out;
}
@@ -755,6 +763,7 @@ glfs_h_opendir (struct glfs *fs, struct glfs_object *object)
/* fop/op */
ret = syncop_opendir (subvol, &loc, glfd->fd);
+ DECODE_SYNCOP_ERR (ret);
out:
loc_wipe (&loc);
@@ -846,6 +855,7 @@ glfs_h_create_from_handle (struct glfs *fs, unsigned char *handle, int len,
}
ret = syncop_lookup (subvol, &loc, 0, &iatt, 0, 0);
+ DECODE_SYNCOP_ERR (ret);
if (ret) {
gf_log (subvol->name, GF_LOG_WARNING,
"inode refresh of %s failed: %s",
@@ -934,6 +944,7 @@ glfs_h_truncate (struct glfs *fs, struct glfs_object *object, off_t offset)
/* fop/op */
ret = syncop_truncate (subvol, &loc, (off_t)offset);
+ DECODE_SYNCOP_ERR (ret);
/* populate out args */
if (ret == 0)
@@ -1006,6 +1017,7 @@ glfs_h_symlink (struct glfs *fs, struct glfs_object *parent, const char *name,
/* fop/op */
ret = syncop_symlink (subvol, &loc, data, xattr_req, &iatt);
+ DECODE_SYNCOP_ERR (ret);
/* populate out args */
if (ret == 0) {
@@ -1081,6 +1093,7 @@ glfs_h_readlink (struct glfs *fs, struct glfs_object *object, char *buf,
/* fop/op */
ret = syncop_readlink (subvol, &loc, &linkval, bufsiz);
+ DECODE_SYNCOP_ERR (ret);
/* populate out args */
if (ret > 0)
@@ -1166,6 +1179,7 @@ glfs_h_link (struct glfs *fs, struct glfs_object *linksrc,
/* fop/op */
ret = syncop_link (subvol, &oldloc, &newloc);
+ DECODE_SYNCOP_ERR (ret);
if (ret == 0)
/* TODO: No iatt to pass as there has been no lookup */
@@ -1256,6 +1270,7 @@ glfs_h_rename (struct glfs *fs, struct glfs_object *olddir, const char *oldname,
/* TODO: check if new or old is a prefix of the other, and fail EINVAL */
ret = syncop_rename (subvol, &oldloc, &newloc);
+ DECODE_SYNCOP_ERR (ret);
if (ret == 0)
inode_rename (oldloc.parent->table, oldloc.parent, oldloc.name,
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index ec1d5579df7..f04557323a0 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -18,6 +18,26 @@
#define DEFAULT_REVAL_COUNT 1
+/*
+ * syncop_xxx() calls are executed in two ways, one is inside a synctask where
+ * the executing function will do 'swapcontext' and the other is without
+ * synctask where the executing thread is made to wait using pthread_cond_wait.
+ * Executing thread may change when syncop_xxx() is executed inside a synctask.
+ * This leads to errno_location change i.e. errno may give errno of
+ * non-executing thread. So errno is not touched inside a synctask execution.
+ * All gfapi calls are executed using the second way of executing syncop_xxx()
+ * where the executing thread waits using pthread_cond_wait so it is ok to set
+ * errno in these cases. The following macro makes syncop_xxx() behave just
+ * like a system call, where -1 is returned and errno is set when a failure
+ * occurs.
+ */
+#define DECODE_SYNCOP_ERR(ret) do { \
+ if (ret < 0) { \
+ errno = -ret; \
+ ret = -1; \
+ } \
+ } while (0)
+
#define ESTALE_RETRY(ret,errno,reval,loc,label) do { \
if (ret == -1 && errno == ESTALE) { \
if (reval < DEFAULT_REVAL_COUNT) { \
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
index 4ca2eb6fcf4..c88330aa48e 100644
--- a/api/src/glfs-resolve.c
+++ b/api/src/glfs-resolve.c
@@ -48,6 +48,7 @@ glfs_first_lookup_safe (xlator_t *subvol)
loc.name = "";
ret = syncop_lookup (subvol, &loc, 0, 0, 0, 0);
+ DECODE_SYNCOP_ERR (ret);
gf_log (subvol->name, GF_LOG_DEBUG, "first lookup complete %d", ret);
@@ -98,6 +99,7 @@ glfs_refresh_inode_safe (xlator_t *subvol, inode_t *oldinode)
return NULL;
ret = syncop_lookup (subvol, &loc, 0, &iatt, 0, 0);
+ DECODE_SYNCOP_ERR (ret);
if (ret) {
gf_log (subvol->name, GF_LOG_WARNING,
@@ -181,6 +183,7 @@ glfs_resolve_symlink (struct glfs *fs, xlator_t *subvol, inode_t *inode,
loc.path = rpath;
ret = syncop_readlink (subvol, &loc, &path, 4096);
+ DECODE_SYNCOP_ERR (ret);
if (ret < 0)
goto out;
@@ -210,6 +213,7 @@ glfs_resolve_base (struct glfs *fs, xlator_t *subvol, inode_t *inode,
goto out;
ret = syncop_lookup (subvol, &loc, NULL, iatt, NULL, NULL);
+ DECODE_SYNCOP_ERR (ret);
out:
loc_wipe (&loc);
@@ -268,6 +272,7 @@ glfs_resolve_component (struct glfs *fs, xlator_t *subvol, inode_t *parent,
}
ret = syncop_lookup (subvol, &loc, NULL, &ciatt, NULL, NULL);
+ DECODE_SYNCOP_ERR (ret);
if (ret && reval) {
inode_unref (loc.inode);
loc.inode = inode_new (parent->table);
@@ -292,6 +297,7 @@ glfs_resolve_component (struct glfs *fs, xlator_t *subvol, inode_t *parent,
ret = syncop_lookup (subvol, &loc, xattr_req, &ciatt,
NULL, NULL);
+ DECODE_SYNCOP_ERR (ret);
}
if (ret)
goto out;
@@ -515,6 +521,7 @@ glfs_migrate_fd_locks_safe (struct glfs *fs, xlator_t *oldsubvol, fd_t *oldfd,
ret = syncop_fgetxattr (oldsubvol, oldfd, &lockinfo,
GF_XATTR_LOCKINFO_KEY);
+ DECODE_SYNCOP_ERR (ret);
if (ret < 0) {
gf_log (fs->volname, GF_LOG_WARNING,
"fgetxattr (%s) failed (%s) on graph %s (%d)",
@@ -533,6 +540,7 @@ glfs_migrate_fd_locks_safe (struct glfs *fs, xlator_t *oldsubvol, fd_t *oldfd,
}
ret = syncop_fsetxattr (newsubvol, newfd, lockinfo, 0);
+ DECODE_SYNCOP_ERR (ret);
if (ret < 0) {
gf_log (fs->volname, GF_LOG_WARNING,
"fsetxattr (%s) failed (%s) on graph %s (%d)",
@@ -568,6 +576,7 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
if (!oldsubvol->switched) {
ret = syncop_fsync (oldsubvol, oldfd, 0);
+ DECODE_SYNCOP_ERR (ret);
if (ret) {
gf_log (fs->volname, GF_LOG_WARNING,
"fsync() failed (%s) on %s graph %s (%d)",
@@ -614,6 +623,7 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
ret = syncop_open (newsubvol, &loc,
oldfd->flags & ~(O_TRUNC|O_EXCL|O_CREAT),
newfd);
+ DECODE_SYNCOP_ERR (ret);
loc_wipe (&loc);
if (ret) {
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index 1f36e57766c..efcd9c5f3a9 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -983,7 +983,8 @@ syncop_lookup (xlator_t *subvol, loc_t *loc, dict_t *xdata_req,
else if (args.xdata)
dict_unref (args.xdata);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1059,7 +1060,8 @@ syncop_readdirp (xlator_t *subvol,
list_splice_init (&args.entries.list, &entries->list);
/* TODO: need to free all the 'args.entries' in 'else' case */
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1118,7 +1120,8 @@ syncop_readdir (xlator_t *subvol,
list_splice_init (&args.entries.list, &entries->list);
/* TODO: need to free all the 'args.entries' in 'else' case */
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1153,7 +1156,8 @@ syncop_opendir (xlator_t *subvol,
SYNCOP (subvol, (&args), syncop_opendir_cbk, subvol->fops->opendir,
loc, fd, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1182,7 +1186,8 @@ syncop_fsyncdir (xlator_t *subvol, fd_t *fd, int datasync)
SYNCOP (subvol, (&args), syncop_fsyncdir_cbk, subvol->fops->fsyncdir,
fd, datasync, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1210,7 +1215,8 @@ syncop_removexattr (xlator_t *subvol, loc_t *loc, const char *name)
SYNCOP (subvol, (&args), syncop_removexattr_cbk, subvol->fops->removexattr,
loc, name, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1238,7 +1244,8 @@ syncop_fremovexattr (xlator_t *subvol, fd_t *fd, const char *name)
SYNCOP (subvol, (&args), syncop_fremovexattr_cbk,
subvol->fops->fremovexattr, fd, name, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1267,7 +1274,8 @@ syncop_setxattr (xlator_t *subvol, loc_t *loc, dict_t *dict, int32_t flags)
SYNCOP (subvol, (&args), syncop_setxattr_cbk, subvol->fops->setxattr,
loc, dict, flags, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1296,7 +1304,8 @@ syncop_fsetxattr (xlator_t *subvol, fd_t *fd, dict_t *dict, int32_t flags)
SYNCOP (subvol, (&args), syncop_fsetxattr_cbk, subvol->fops->fsetxattr,
fd, dict, flags, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1331,7 +1340,8 @@ syncop_listxattr (xlator_t *subvol, loc_t *loc, dict_t **dict)
else if (args.xattr)
dict_unref (args.xattr);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1348,7 +1358,8 @@ syncop_getxattr (xlator_t *subvol, loc_t *loc, dict_t **dict, const char *key)
else if (args.xattr)
dict_unref (args.xattr);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1365,7 +1376,8 @@ syncop_fgetxattr (xlator_t *subvol, fd_t *fd, dict_t **dict, const char *key)
else if (args.xattr)
dict_unref (args.xattr);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1404,7 +1416,8 @@ syncop_statfs (xlator_t *subvol, loc_t *loc, struct statvfs *buf)
if (buf)
*buf = args.statvfs_buf;
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1445,7 +1458,8 @@ syncop_setattr (xlator_t *subvol, loc_t *loc, struct iatt *iatt, int valid,
if (postop)
*postop = args.iatt2;
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1464,7 +1478,8 @@ syncop_fsetattr (xlator_t *subvol, fd_t *fd, struct iatt *iatt, int valid,
if (postop)
*postop = args.iatt2;
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1493,7 +1508,8 @@ syncop_open (xlator_t *subvol, loc_t *loc, int32_t flags, fd_t *fd)
SYNCOP (subvol, (&args), syncop_open_cbk, subvol->fops->open,
loc, flags, fd, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1555,7 +1571,8 @@ syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off,
iobref_unref (args.iobref);
out:
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1588,7 +1605,8 @@ syncop_writev (xlator_t *subvol, fd_t *fd, const struct iovec *vector,
fd, (struct iovec *) vector, count, offset, flags, iobref,
NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1604,7 +1622,8 @@ int syncop_write (xlator_t *subvol, fd_t *fd, const char *buf, int size,
SYNCOP (subvol, (&args), syncop_writev_cbk, subvol->fops->writev,
fd, &vec, 1, offset, flags, iobref, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1647,10 +1666,11 @@ syncop_create (xlator_t *subvol, loc_t *loc, int32_t flags, mode_t mode,
SYNCOP (subvol, (&args), syncop_create_cbk, subvol->fops->create,
loc, flags, mode, 0, fd, xdata);
- errno = args.op_errno;
if (iatt)
*iatt = args.iatt1;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1680,7 +1700,8 @@ syncop_unlink (xlator_t *subvol, loc_t *loc)
SYNCOP (subvol, (&args), syncop_unlink_cbk, subvol->fops->unlink, loc,
0, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1709,7 +1730,8 @@ syncop_rmdir (xlator_t *subvol, loc_t *loc, int flags)
SYNCOP (subvol, (&args), syncop_rmdir_cbk, subvol->fops->rmdir, loc,
flags, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1741,7 +1763,8 @@ syncop_link (xlator_t *subvol, loc_t *oldloc, loc_t *newloc)
SYNCOP (subvol, (&args), syncop_link_cbk, subvol->fops->link,
oldloc, newloc, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1775,7 +1798,8 @@ syncop_rename (xlator_t *subvol, loc_t *oldloc, loc_t *newloc)
SYNCOP (subvol, (&args), syncop_rename_cbk, subvol->fops->rename,
oldloc, newloc, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1806,7 +1830,8 @@ syncop_ftruncate (xlator_t *subvol, fd_t *fd, off_t offset)
SYNCOP (subvol, (&args), syncop_ftruncate_cbk, subvol->fops->ftruncate,
fd, offset, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1818,7 +1843,8 @@ syncop_truncate (xlator_t *subvol, loc_t *loc, off_t offset)
SYNCOP (subvol, (&args), syncop_ftruncate_cbk, subvol->fops->truncate,
loc, offset, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1848,7 +1874,8 @@ syncop_fsync (xlator_t *subvol, fd_t *fd, int dataonly)
SYNCOP (subvol, (&args), syncop_fsync_cbk, subvol->fops->fsync,
fd, dataonly, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1879,7 +1906,8 @@ syncop_flush (xlator_t *subvol, fd_t *fd)
SYNCOP (subvol, (&args), syncop_flush_cbk, subvol->fops->flush,
fd, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1914,7 +1942,8 @@ syncop_fstat (xlator_t *subvol, fd_t *fd, struct iatt *stbuf)
if (stbuf)
*stbuf = args.iatt1;
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1930,7 +1959,8 @@ syncop_stat (xlator_t *subvol, loc_t *loc, struct iatt *stbuf)
if (stbuf)
*stbuf = args.iatt1;
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -1964,10 +1994,11 @@ syncop_symlink (xlator_t *subvol, loc_t *loc, const char *newpath, dict_t *dict,
SYNCOP (subvol, (&args), syncop_symlink_cbk, subvol->fops->symlink,
newpath, loc, 0, dict);
- errno = args.op_errno;
if (iatt)
*iatt = args.iatt1;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -2004,7 +2035,8 @@ syncop_readlink (xlator_t *subvol, loc_t *loc, char **buffer, size_t size)
*buffer = args.buffer;
else GF_FREE (args.buffer);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -2038,10 +2070,11 @@ syncop_mknod (xlator_t *subvol, loc_t *loc, mode_t mode, dev_t rdev,
SYNCOP (subvol, (&args), syncop_mknod_cbk, subvol->fops->mknod,
loc, mode, rdev, 0, dict);
- errno = args.op_errno;
if (iatt)
*iatt = args.iatt1;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -2077,10 +2110,11 @@ syncop_mkdir (xlator_t *subvol, loc_t *loc, mode_t mode, dict_t *dict,
SYNCOP (subvol, (&args), syncop_mkdir_cbk, subvol->fops->mkdir,
loc, mode, 0, dict);
- errno = args.op_errno;
if (iatt)
*iatt = args.iatt1;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -2108,7 +2142,8 @@ syncop_access (xlator_t *subvol, loc_t *loc, int32_t mask)
SYNCOP (subvol, (&args), syncop_access_cbk, subvol->fops->access,
loc, mask, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -2139,7 +2174,8 @@ syncop_fallocate(xlator_t *subvol, fd_t *fd, int32_t keep_size, off_t offset,
SYNCOP (subvol, (&args), syncop_fallocate_cbk, subvol->fops->fallocate,
fd, keep_size, offset, len, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -2169,7 +2205,8 @@ syncop_discard(xlator_t *subvol, fd_t *fd, off_t offset, size_t len)
SYNCOP (subvol, (&args), syncop_discard_cbk, subvol->fops->discard,
fd, offset, len, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -2198,7 +2235,8 @@ syncop_zerofill(xlator_t *subvol, fd_t *fd, off_t offset, off_t len)
SYNCOP (subvol, (&args), syncop_zerofill_cbk, subvol->fops->zerofill,
fd, offset, len, NULL);
- errno = args.op_errno;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
@@ -2230,8 +2268,9 @@ syncop_lk (xlator_t *subvol, fd_t *fd, int cmd, struct gf_flock *flock)
SYNCOP (subvol, (&args), syncop_lk_cbk, subvol->fops->lk,
fd, cmd, flock, NULL);
- errno = args.op_errno;
*flock = args.flock;
+ if (args.op_ret < 0)
+ return -args.op_errno;
return args.op_ret;
}
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index 5f85c3047d4..9e5c1b3e79f 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -336,8 +336,9 @@ _get_path_from_gfid_loc (xlator_t *this, xlator_t *readdir_xl, loc_t *child,
ret = syncop_getxattr (readdir_xl, child, &xattr, GFID_TO_PATH_KEY);
if (ret < 0) {
- if ((errno == ENOENT || errno == ESTALE) && missing)
+ if ((-ret == ENOENT || -ret == ESTALE) && missing)
*missing = _gf_true;
+ ret = -1;
goto out;
}
ret = dict_get_str (xattr, GFID_TO_PATH_KEY, &path);
@@ -437,10 +438,10 @@ _remove_stale_index (xlator_t *this, xlator_t *readdir_xl,
gf_log (this->name, GF_LOG_DEBUG, "Removing stale index "
"for %s on %s", index_loc.name, readdir_xl->name);
ret = syncop_unlink (readdir_xl, &index_loc);
- if(ret && (errno != ENOENT)) {
+ if((ret < 0) && (-ret != ENOENT)) {
gf_log(this->name, GF_LOG_ERROR, "%s: Failed to remove index "
"on %s - %s",index_loc.name, readdir_xl->name,
- strerror (errno));
+ strerror (-ret));
}
index_loc.path = NULL;
loc_wipe (&index_loc);
@@ -467,8 +468,10 @@ _count_hard_links_under_base_indices_dir (xlator_t *this,
child = crawl_data->child;
ret = syncop_lookup (readdir_xl, childloc, NULL, iattr, NULL, &parent);
- if (ret)
+ if (ret) {
+ ret = -1;
goto out;
+ }
ret = dict_get_int32 (output, this->name, &xl_id);
if (ret)
@@ -648,8 +651,10 @@ _self_heal_entry (xlator_t *this, afr_crawl_data_t *crawl_data, gf_dirent_t *ent
ret = syncop_lookup (this, child, xattr_req,
iattr, &xattr_rsp, &parentbuf);
- _crawl_post_sh_action (this, parent, child, ret, errno, xattr_rsp,
+ _crawl_post_sh_action (this, parent, child, ret, -ret, xattr_rsp,
crawl_data);
+ if (ret < 0)
+ ret = -1;
if (xattr_rsp)
dict_unref (xattr_rsp);
if (ret == 0)
@@ -1190,8 +1195,10 @@ afr_crawl_build_start_loc (xlator_t *this, afr_crawl_data_t *crawl_data,
afr_build_root_loc (this, &rootloc);
ret = syncop_getxattr (readdir_xl, &rootloc, &xattr,
GF_XATTROP_INDEX_GFID);
- if (ret < 0)
+ if (ret < 0) {
+ ret = -1;
goto out;
+ }
ret = dict_get_ptr (xattr, GF_XATTROP_INDEX_GFID, &index_gfid);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "failed to get index "
@@ -1210,11 +1217,12 @@ afr_crawl_build_start_loc (xlator_t *this, afr_crawl_data_t *crawl_data,
ret = syncop_lookup (readdir_xl, dirloc, NULL,
&iattr, NULL, &parent);
if (ret < 0) {
- if (errno != ENOENT) {
+ if (-ret != ENOENT) {
gf_log (this->name, GF_LOG_ERROR, "lookup "
"failed on index dir on %s - (%s)",
- readdir_xl->name, strerror (errno));
+ readdir_xl->name, strerror (-ret));
}
+ ret = -1;
goto out;
}
ret = _link_inode_update_loc (this, dirloc, &iattr);
@@ -1224,8 +1232,10 @@ afr_crawl_build_start_loc (xlator_t *this, afr_crawl_data_t *crawl_data,
afr_build_root_loc (this, &rootloc);
ret = syncop_getxattr (readdir_xl, &rootloc, &xattr,
GF_BASE_INDICES_HOLDER_GFID);
- if (ret < 0)
+ if (ret < 0) {
+ ret = -1;
goto out;
+ }
ret = dict_get_ptr (xattr, GF_BASE_INDICES_HOLDER_GFID,
&base_indices_holder_vgfid);
if (ret < 0) {
@@ -1246,16 +1256,17 @@ afr_crawl_build_start_loc (xlator_t *this, afr_crawl_data_t *crawl_data,
ret = syncop_lookup (readdir_xl, dirloc, NULL, &iattr, NULL,
&parent);
if (ret < 0) {
- if (errno != ENOENT) {
+ if (-ret != ENOENT) {
gf_log (this->name, GF_LOG_ERROR, "lookup "
"failed for base_indices_holder dir"
" on %s - (%s)", readdir_xl->name,
- strerror (errno));
+ strerror (-ret));
} else {
gf_log (this->name, GF_LOG_ERROR, "base_indices"
"_holder is not yet created.");
}
+ ret = -1;
goto out;
}
ret = _link_inode_update_loc (this, dirloc, &iattr);
@@ -1290,6 +1301,7 @@ afr_crawl_opendir (xlator_t *this, afr_crawl_data_t *crawl_data, fd_t **dirfd,
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR,
"opendir failed on %s", dirloc->path);
+ ret = -1;
goto out;
}
} else {
@@ -1442,8 +1454,13 @@ _crawl_directory (fd_t *fd, loc_t *loc, afr_crawl_data_t *crawl_data)
else
ret = syncop_readdir (readdir_xl, fd, 131072, offset,
&entries);
- if (ret <= 0)
+ if (ret < 0) {
+ ret = -1;
+ break;
+ } else if (ret == 0) {
break;
+ }
+
ret = 0;
free_entries = _gf_true;
@@ -1503,7 +1520,8 @@ afr_find_child_position (xlator_t *this, int child, afr_child_pos_t *pos)
GF_XATTR_NODE_UUID_KEY);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "getxattr failed on %s - "
- "(%s)", priv->children[child]->name, strerror (errno));
+ "(%s)", priv->children[child]->name, strerror (-ret));
+ ret = -1;
goto out;
}
diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c
index a7f72fb30e9..9027e2a3318 100644
--- a/xlators/cluster/afr/src/pump.c
+++ b/xlators/cluster/afr/src/pump.c
@@ -504,9 +504,10 @@ pump_xattr_cleaner (call_frame_t *frame, void *cookie, xlator_t *this,
for (i = 0; i < priv->child_count; i++) {
ret = syncop_removexattr (priv->children[i], &loc,
PUMP_SOURCE_COMPLETE);
- if (ret)
+ if (ret) {
gf_log (this->name, GF_LOG_DEBUG, "removexattr "
- "failed with %s", strerror (errno));
+ "failed with %s", strerror (-ret));
+ }
}
loc_wipe (&loc);
@@ -598,6 +599,7 @@ pump_lookup_sink (loc_t *loc)
if (ret) {
gf_log (this->name, GF_LOG_DEBUG,
"Lookup on sink child failed");
+ ret = -1;
goto out;
}
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 00a98f1cfa5..76bfbaedb77 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -769,17 +769,20 @@ dht_migration_complete_check_task (void *data)
dst_node = dht_linkfile_subvol (this, NULL, NULL, dict);
if (ret) {
- if (!dht_inode_missing(errno) || (!local->loc.inode)) {
+ if (!dht_inode_missing(-ret) || (!local->loc.inode)) {
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to get the 'linkto' xattr %s",
- local->loc.path, strerror (errno));
+ local->loc.path, strerror (-ret));
+ ret = -1;
goto out;
}
/* Need to do lookup on hashed subvol, then get the file */
ret = syncop_lookup (this, &local->loc, NULL, &stbuf, NULL,
NULL);
- if (ret)
+ if (ret) {
+ ret = -1;
goto out;
+ }
dst_node = dht_subvol_get_cached (this, local->loc.inode);
}
@@ -799,6 +802,7 @@ dht_migration_complete_check_task (void *data)
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to lookup the file on %s",
local->loc.path, dst_node->name);
+ ret = -1;
goto out;
}
@@ -869,10 +873,11 @@ dht_migration_complete_check_task (void *data)
ret = syncop_open (dst_node, &tmp_loc,
iter_fd->flags, iter_fd);
- if (ret == -1) {
+ if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "failed to open "
"the fd (%p, flags=0%o) on file %s @ %s",
iter_fd, iter_fd->flags, path, dst_node->name);
+ ret = -1;
open_failed = 1;
}
}
@@ -955,11 +960,12 @@ dht_rebalance_inprogress_task (void *data)
conf->link_xattr_name);
}
- if (ret) {
+ if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to get the 'linkto' xattr %s",
- local->loc.path, strerror (errno));
- goto out;
+ local->loc.path, strerror (-ret));
+ ret = -1;
+ goto out;
}
dst_node = dht_linkfile_subvol (this, NULL, NULL, dict);
@@ -981,6 +987,7 @@ dht_rebalance_inprogress_task (void *data)
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to lookup the file on %s",
local->loc.path, dst_node->name);
+ ret = -1;
goto out;
}
@@ -1014,10 +1021,11 @@ dht_rebalance_inprogress_task (void *data)
ret = syncop_open (dst_node, &tmp_loc,
iter_fd->flags, iter_fd);
- if (ret == -1) {
+ if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "failed to send open "
"the fd (%p, flags=0%o) on file %s @ %s",
iter_fd, iter_fd->flags, path, dst_node->name);
+ ret = -1;
open_failed = 1;
}
}
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 9446dbe03ac..a5a4585f1ee 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -58,7 +58,8 @@ dht_write_with_holes (xlator_t *to, fd_t *fd, struct iovec *vec, int count,
if (ret < 0) {
gf_log (THIS->name, GF_LOG_WARNING,
"failed to write (%s)",
- strerror (errno));
+ strerror (-ret));
+ ret = -1;
goto out;
}
@@ -76,7 +77,8 @@ dht_write_with_holes (xlator_t *to, fd_t *fd, struct iovec *vec, int count,
/* 'path' will be logged in calling function */
gf_log (THIS->name, GF_LOG_WARNING,
"failed to write (%s)",
- strerror (errno));
+ strerror (-ret));
+ ret = -1;
goto out;
}
}
@@ -158,7 +160,8 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs,
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Linkto setxattr "
"failed %s -> %s (%s)", cached_subvol->name,
- loc->name, strerror (errno));
+ loc->name, strerror (-ret));
+ ret = -1;
goto out;
}
goto out;
@@ -173,7 +176,8 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs,
ret = syncop_link (hashed_subvol, loc, loc);
if (ret) {
- op_errno = errno;
+ op_errno = -ret;
+ ret = -1;
gf_log (this->name, GF_LOG_ERROR, "link of %s -> %s"
" failed on subvol %s (%s)", loc->name,
uuid_utoa(loc->gfid),
@@ -185,7 +189,8 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs,
ret = syncop_lookup (hashed_subvol, loc, NULL, &iatt, NULL, NULL);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed lookup %s on %s (%s)"
- , loc->name, hashed_subvol->name, strerror (errno));
+ , loc->name, hashed_subvol->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -289,11 +294,12 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
goto out;
}
}
- if ((ret == -1) && (errno != ENOENT)) {
+ if ((ret < 0) && (-ret != ENOENT)) {
/* File exists in destination, but not accessible */
gf_log (THIS->name, GF_LOG_WARNING,
"%s: failed to lookup file (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -304,21 +310,22 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR,
"failed to create %s on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
+ ret = -1;
goto out;
}
ret = syncop_fsetxattr (to, fd, xattr, 0);
- if (ret == -1)
+ if (ret < 0)
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to set xattr on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
ret = syncop_ftruncate (to, fd, stbuf->ia_size);
if (ret < 0)
gf_log (this->name, GF_LOG_ERROR,
"ftruncate failed for %s on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
ret = syncop_fsetattr (to, fd, stbuf,
(GF_SET_ATTR_UID | GF_SET_ATTR_GID),
@@ -326,7 +333,7 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
if (ret < 0)
gf_log (this->name, GF_LOG_ERROR,
"chown failed for %s on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
if (dst_fd)
*dst_fd = fd;
@@ -356,7 +363,8 @@ __dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"failed to get statfs of %s on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -364,7 +372,8 @@ __dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"failed to get statfs of %s on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -463,6 +472,8 @@ __dht_rebalance_migrate_data (xlator_t *from, xlator_t *to, fd_t *src, fd_t *dst
if (ret >= 0)
ret = 0;
+ else
+ ret = -1;
return ret;
}
@@ -491,10 +502,11 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc,
}
ret = syncop_open (from, loc, O_RDWR, fd);
- if (ret == -1) {
+ if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR,
"failed to open file %s on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -517,7 +529,8 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"failed to set xattr on %s in %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -531,7 +544,8 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"failed to set mode on %s in %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -571,9 +585,10 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
/* check in the destination if the file is link file */
ret = syncop_lookup (to, loc, dict, &stbuf, &rsp_dict, NULL);
- if ((ret == -1) && (errno != ENOENT)) {
+ if ((ret < 0) && (-ret != ENOENT)) {
gf_log (this->name, GF_LOG_WARNING, "%s: lookup failed (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -596,7 +611,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to delete the linkfile (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
+ ret = -1;
goto out;
}
}
@@ -616,7 +632,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
if (ret < 0) {
gf_log (this->name, GF_LOG_WARNING,
"%s: readlink on symlink failed (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -624,7 +641,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: creating symlink failed (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -637,7 +655,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
ia_minor (buf->ia_rdev)), dict, 0);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "%s: mknod failed (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -648,13 +667,16 @@ done:
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to perform setattr on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
+ ret = -1;
}
ret = syncop_unlink (from, loc);
- if (ret)
+ if (ret) {
gf_log (this->name, GF_LOG_WARNING, "%s: unlink failed (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
+ ret = -1;
+ }
out:
if (dict)
@@ -708,7 +730,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
ret = syncop_lookup (from, loc, dict, &stbuf, &xattr_rsp, NULL);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "%s: lookup failed on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -732,10 +755,12 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
/* TODO: move all xattr related operations to fd based operations */
ret = syncop_listxattr (from, loc, &xattr);
- if (ret == -1)
+ if (ret < 0) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to get xattr from %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
+ }
/* create the destination, with required modes/xattr */
ret = __dht_rebalance_create_dst_file (to, from, loc, &stbuf,
@@ -760,7 +785,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
ret = syncop_fstat (from, src_fd, &stbuf);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "failed to lookup %s on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -779,7 +805,7 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to reset target size back to 0 (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
}
ret = -1;
@@ -789,10 +815,12 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
/* TODO: Sync the locks */
ret = syncop_fsync (to, dst_fd, 0);
- if (ret)
+ if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to fsync on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
+ ret = -1;
+ }
/* Phase 2 - Data-Migration Complete, Housekeeping updates pending */
@@ -802,7 +830,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
/* Failed to get the stat info */
gf_log (this->name, GF_LOG_ERROR,
"failed to fstat file %s on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -824,7 +853,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to perform setattr on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -835,7 +865,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to perform setattr on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
+ ret = -1;
}
/* Make the source as a linkfile first before deleting it */
@@ -845,7 +876,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_WARNING, \
"%s: failed to perform setattr on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -855,7 +887,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to perform truncate on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
}
/* remove the 'linkto' xattr from the destination */
@@ -863,7 +896,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to perform removexattr on %s (%s)",
- loc->path, to->name, strerror (errno));
+ loc->path, to->name, strerror (-ret));
+ ret = -1;
}
/* Do a stat and check the gfid before unlink */
@@ -871,7 +905,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to do a stat on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
@@ -881,7 +916,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to perform unlink on %s (%s)",
- loc->path, from->name, strerror (errno));
+ loc->path, from->name, strerror (-ret));
+ ret = -1;
goto out;
}
}
@@ -890,7 +926,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
if (ret) {
gf_log (this->name, GF_LOG_DEBUG,
"%s: failed to lookup the file on subvolumes (%s)",
- loc->path, strerror (errno));
+ loc->path, strerror (-ret));
+ ret = -1;
}
gf_log (this->name, GF_LOG_INFO,
@@ -1053,10 +1090,10 @@ gf_defrag_handle_migrate_error (int32_t op_errno, gf_defrag_info_t *defrag)
{
/* if errno is not ENOSPC or ENOTCONN, we can still continue
with rebalance process */
- if ((errno != ENOSPC) || (errno != ENOTCONN))
+ if ((op_errno != ENOSPC) || (op_errno != ENOTCONN))
return 1;
- if (errno == ENOTCONN) {
+ if (op_errno == ENOTCONN) {
/* Most probably mount point went missing (mostly due
to a brick down), say rebalance failure to user,
let him restart it if everything is fine */
@@ -1064,7 +1101,7 @@ gf_defrag_handle_migrate_error (int32_t op_errno, gf_defrag_info_t *defrag)
return -1;
}
- if (errno == ENOSPC) {
+ if (op_errno == ENOSPC) {
/* rebalance process itself failed, may be
remote brick went down, or write failed due to
disk full etc etc.. */
@@ -1105,10 +1142,6 @@ gf_defrag_pattern_match (gf_defrag_info_t *defrag, char *name, uint64_t size)
* have been fixed
*/
-#ifdef GF_LINUX_HOST_OS
-#pragma GCC push_options
-#pragma GCC optimize ("O0")
-#endif
int
gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
dict_t *migrate_data)
@@ -1126,7 +1159,6 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
int32_t op_errno = 0;
char *uuid_str = NULL;
uuid_t node_uuid = {0,};
- int readdir_operrno = 0;
struct timeval dir_start = {0,};
struct timeval end = {0,};
double elapsed = {0,};
@@ -1148,6 +1180,7 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to open dir %s",
loc->path);
+ ret = -1;
goto out;
}
@@ -1160,14 +1193,11 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
gf_log (this->name, GF_LOG_ERROR, "Readdir returned %s."
" Aborting migrate-data",
- strerror(readdir_operrno));
+ strerror(-ret));
+ ret = -1;
goto out;
}
- /* Need to keep track of ENOENT errno, that means, there is no
- need to send more readdirp() */
- readdir_operrno = errno;
-
if (list_empty (&entries.list))
break;
@@ -1232,6 +1262,7 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "%s"
" lookup failed", entry_loc.path);
+ ret = -1;
continue;
}
@@ -1240,6 +1271,7 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
if(ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "Failed to "
"get node-uuid for %s", entry_loc.path);
+ ret = -1;
continue;
}
@@ -1249,6 +1281,7 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
gf_log (this->name, GF_LOG_ERROR, "Failed to "
"get node-uuid from dict for %s",
entry_loc.path);
+ ret = -1;
continue;
}
@@ -1282,7 +1315,7 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
ret = syncop_getxattr (this, &entry_loc, &dict,
GF_XATTR_LINKINFO_KEY);
if (ret < 0) {
- if (errno != ENODATA) {
+ if (-ret != ENODATA) {
loglevel = GF_LOG_ERROR;
defrag->total_failures += 1;
} else {
@@ -1290,7 +1323,8 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
}
gf_log (this->name, loglevel, "%s: failed to "
"get "GF_XATTR_LINKINFO_KEY" key - %s",
- entry_loc.path, strerror (errno));
+ entry_loc.path, strerror (-ret));
+ ret = -1;
continue;
}
@@ -1314,8 +1348,8 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
}
}
- if (ret == -1) {
- op_errno = errno;
+ if (ret < 0) {
+ op_errno = -ret;
ret = gf_defrag_handle_migrate_error (op_errno,
defrag);
@@ -1350,9 +1384,6 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
gf_dirent_free (&entries);
free_entries = _gf_false;
INIT_LIST_HEAD (&entries.list);
-
- if (readdir_operrno == ENOENT)
- break;
}
gettimeofday (&end, NULL);
@@ -1375,10 +1406,6 @@ out:
return ret;
}
-#ifdef GF_LINUX_HOST_OS
-#pragma GCC pop_options
-#endif
-
int
gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
@@ -1394,12 +1421,12 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
dict_t *dict = NULL;
off_t offset = 0;
struct iatt iatt = {0,};
- int readdirp_errno = 0;
ret = syncop_lookup (this, loc, NULL, &iatt, NULL, NULL);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Lookup failed on %s",
loc->path);
+ ret = -1;
goto out;
}
@@ -1433,14 +1460,11 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "Readdir returned %s"
- ". Aborting fix-layout",strerror(errno));
+ ". Aborting fix-layout",strerror(-ret));
+ ret = -1;
goto out;
}
- /* Need to keep track of ENOENT errno, that means, there is no
- need to send more readdirp() */
- readdirp_errno = errno;
-
if (list_empty (&entries.list))
break;
@@ -1494,6 +1518,7 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "%s"
" lookup failed", entry_loc.path);
+ ret = -1;
continue;
}
@@ -1505,6 +1530,7 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
defrag->defrag_status =
GF_DEFRAG_STATUS_FAILED;
defrag->total_failures ++;
+ ret = -1;
goto out;
}
ret = gf_defrag_fix_layout (this, defrag, &entry_loc,
@@ -1521,8 +1547,6 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
gf_dirent_free (&entries);
free_entries = _gf_false;
INIT_LIST_HEAD (&entries.list);
- if (readdirp_errno == ENOENT)
- break;
}
ret = 0;
@@ -1587,6 +1611,7 @@ gf_defrag_start_crawl (void *data)
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "look up on / failed");
+ ret = -1;
goto out;
}
@@ -1607,6 +1632,7 @@ gf_defrag_start_crawl (void *data)
gf_log (this->name, GF_LOG_ERROR, "fix layout on %s failed",
loc.path);
defrag->total_failures++;
+ ret = -1;
goto out;
}
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
index 3fe96b1c716..06fa1ed3a2e 100644
--- a/xlators/cluster/dht/src/dht-selfheal.c
+++ b/xlators/cluster/dht/src/dht-selfheal.c
@@ -1012,10 +1012,11 @@ dht_dir_attr_heal (void *data)
ret = syncop_setattr (subvol, &local->loc, &local->stbuf,
(GF_SET_ATTR_UID | GF_SET_ATTR_GID),
NULL, NULL);
- if (ret)
+ if (ret) {
gf_log ("dht", GF_LOG_ERROR, "Failed to set uid/gid on"
" %s on %s subvol (%s)", local->loc.path,
- subvol->name, strerror (errno));
+ subvol->name, strerror (-ret));
+ }
}
out:
return 0;
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index fce0d509f17..2db327687f3 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -552,7 +552,8 @@ fetch_pathinfo (xlator_t *this, inode_t *inode, int32_t *op_errno,
ret = syncop_getxattr (FIRST_CHILD(this), &loc, &dict,
GF_XATTR_PATHINFO_KEY);
if (ret < 0) {
- *op_errno = errno;
+ *op_errno = -ret;
+ ret = -1;
goto out;
}
diff --git a/xlators/features/qemu-block/src/bdrv-xlator.c b/xlators/features/qemu-block/src/bdrv-xlator.c
index 106c5977535..aaf028cfea5 100644
--- a/xlators/features/qemu-block/src/bdrv-xlator.c
+++ b/xlators/features/qemu-block/src/bdrv-xlator.c
@@ -109,7 +109,7 @@ qemu_gluster_open (BlockDriverState *bs, QDict *options, int bdrv_flags)
NULL);
if (ret) {
loc_wipe(&loc);
- return -errno;
+ return ret;
}
s->inode = inode_ref(loc.inode);
@@ -153,7 +153,7 @@ qemu_gluster_create (const char *filename, QEMUOptionParameter *options)
ret = syncop_fstat (FIRST_CHILD(THIS), fd, &stat);
if (ret) {
fd_unref (fd);
- return -errno;
+ return ret;
}
if (stat.ia_size) {
@@ -166,7 +166,7 @@ qemu_gluster_create (const char *filename, QEMUOptionParameter *options)
ret = syncop_ftruncate (FIRST_CHILD(THIS), fd, total_size);
if (ret) {
fd_unref (fd);
- return -errno;
+ return ret;
}
}
@@ -196,10 +196,8 @@ qemu_gluster_co_readv (BlockDriverState *bs, int64_t sector_num, int nb_sectors,
ret = syncop_readv (FIRST_CHILD(THIS), fd, size, offset, 0,
&iov, &count, &iobref);
- if (ret < 0) {
- ret = -errno;
+ if (ret < 0)
goto out;
- }
iov_copy (qiov->iov, qiov->niov, iov, count); /* *choke!* */
@@ -249,8 +247,6 @@ qemu_gluster_co_writev (BlockDriverState *bs, int64_t sector_num, int nb_sectors
iov.iov_len = size;
ret = syncop_writev (FIRST_CHILD(THIS), fd, &iov, 1, offset, iobref, 0);
- if (ret < 0)
- ret = -errno;
out:
if (iobuf)
@@ -306,9 +302,6 @@ qemu_gluster_truncate (BlockDriverState *bs, int64_t offset)
fd_unref (fd);
- if (ret < 0)
- return ret;
-
return ret;
}
diff --git a/xlators/features/qemu-block/src/qb-coroutines.c b/xlators/features/qemu-block/src/qb-coroutines.c
index 7c52adb21ed..974312f1268 100644
--- a/xlators/features/qemu-block/src/qb-coroutines.c
+++ b/xlators/features/qemu-block/src/qb-coroutines.c
@@ -86,7 +86,7 @@ qb_format_and_resume (void *opaque)
GF_FREE(qb_inode->backing_fname);
if (ret) {
loc_wipe(&loc);
- ret = errno;
+ ret = -ret;
goto err;
}
@@ -150,11 +150,10 @@ qb_format_and_resume (void *opaque)
ret = syncop_fsetxattr (FIRST_CHILD(THIS), fd, xattr, 0);
if (ret) {
- ret = errno;
gf_log (frame->this->name, GF_LOG_ERROR,
"failed to setxattr for %s",
uuid_utoa (inode->gfid));
- QB_STUB_UNWIND (stub, -1, ret);
+ QB_STUB_UNWIND (stub, -1, -ret);
fd_unref (fd);
dict_unref (xattr);
return 0;
@@ -476,7 +475,10 @@ qb_co_truncate (void *opaque)
}
}
- syncop_fstat (FIRST_CHILD(this), local->fd, &stub->args_cbk.prestat);
+ ret = syncop_fstat (FIRST_CHILD(this), local->fd,
+ &stub->args_cbk.prestat);
+ if (ret < 0)
+ goto out;
stub->args_cbk.prestat.ia_size = qb_inode->size;
ret = bdrv_truncate (qb_inode->bs, stub->args.offset);
@@ -487,7 +489,10 @@ qb_co_truncate (void *opaque)
qb_inode->size = offset;
- syncop_fstat (FIRST_CHILD(this), local->fd, &stub->args_cbk.poststat);
+ ret = syncop_fstat (FIRST_CHILD(this), local->fd,
+ &stub->args_cbk.poststat);
+ if (ret < 0)
+ goto out;
stub->args_cbk.poststat.ia_size = qb_inode->size;
qb_update_size_xattr (this, local->fd, qb_inode->fmt, qb_inode->size);
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index ee12d869c53..315259ece7b 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -4026,12 +4026,14 @@ fuse_nameless_lookup (xlator_t *xl, uuid_t gfid, loc_t *loc)
inode_t *linked_inode = NULL;
if ((loc == NULL) || (xl == NULL)) {
+ ret = -EINVAL;
goto out;
}
if (loc->inode == NULL) {
loc->inode = inode_new (xl->itable);
if (loc->inode == NULL) {
+ ret = -ENOMEM;
goto out;
}
}
@@ -4040,13 +4042,13 @@ fuse_nameless_lookup (xlator_t *xl, uuid_t gfid, loc_t *loc)
xattr_req = dict_new ();
if (xattr_req == NULL) {
+ ret = -ENOMEM;
goto out;
}
ret = syncop_lookup (xl, loc, xattr_req, &iatt, NULL, NULL);
- if (ret < 0) {
+ if (ret < 0)
goto out;
- }
linked_inode = inode_link (loc->inode, NULL, NULL, &iatt);
inode_unref (loc->inode);
@@ -4095,9 +4097,10 @@ fuse_migrate_fd_open (xlator_t *this, fd_t *basefd, fd_t *oldfd,
"name-less lookup of gfid (%s) failed (%s)"
"(old-subvolume:%s-%d new-subvolume:%s-%d)",
uuid_utoa (basefd->inode->gfid),
- strerror (errno),
+ strerror (-ret),
old_subvol->name, old_subvol->graph->id,
new_subvol->name, new_subvol->graph->id);
+ ret = -1;
goto out;
}
@@ -4115,6 +4118,7 @@ fuse_migrate_fd_open (xlator_t *this, fd_t *basefd, fd_t *oldfd,
uuid_utoa (loc.inode->gfid),
old_subvol->name, old_subvol->graph->id,
new_subvol->name, new_subvol->graph->id);
+ ret = -1;
goto out;
}
@@ -4138,9 +4142,10 @@ fuse_migrate_fd_open (xlator_t *this, fd_t *basefd, fd_t *oldfd,
gf_log ("glusterfs-fuse", GF_LOG_WARNING,
"open on basefd (ptr:%p inode-gfid:%s) failed (%s)"
"(old-subvolume:%s-%d new-subvolume:%s-%d)", basefd,
- uuid_utoa (basefd->inode->gfid), strerror (errno),
+ uuid_utoa (basefd->inode->gfid), strerror (-ret),
old_subvol->name, old_subvol->graph->id,
new_subvol->name, new_subvol->graph->id);
+ ret = -1;
goto out;
}
@@ -4208,6 +4213,7 @@ fuse_migrate_locks (xlator_t *this, fd_t *basefd, fd_t *oldfd,
oldfd, newfd, uuid_utoa (newfd->inode->gfid),
old_subvol->name, old_subvol->graph->id,
new_subvol->name, new_subvol->graph->id);
+ ret = -1;
goto out;
}
@@ -4233,6 +4239,7 @@ fuse_migrate_locks (xlator_t *this, fd_t *basefd, fd_t *oldfd,
oldfd, newfd, uuid_utoa (newfd->inode->gfid),
old_subvol->name, old_subvol->graph->id,
new_subvol->name, new_subvol->graph->id);
+ ret = -1;
goto out;
}
@@ -4300,10 +4307,11 @@ fuse_migrate_fd (xlator_t *this, fd_t *basefd, xlator_t *old_subvol,
"syncop_fsync failed (%s) on fd (%p)"
"(basefd:%p basefd-inode.gfid:%s) "
"(old-subvolume:%s-%d new-subvolume:%s-%d)",
- strerror (errno), oldfd, basefd,
+ strerror (-ret), oldfd, basefd,
uuid_utoa (basefd->inode->gfid),
old_subvol->name, old_subvol->graph->id,
new_subvol->name, new_subvol->graph->id);
+ ret = -1;
}
} else {
gf_log ("glusterfs-fuse", GF_LOG_WARNING,