summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/features/locks/src/posix.c142
1 files changed, 88 insertions, 54 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 57753dac588..dc11ab62d0f 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -38,6 +38,43 @@ static int format_brickname(char *);
int pl_lockinfo_get_brickname (xlator_t *, inode_t *, int32_t *);
static int fetch_pathinfo(xlator_t *, inode_t *, int32_t *, char **);
+#define PL_STACK_UNWIND_AND_FREE(__local, fop, frame, op_ret, params ...) \
+ do { \
+ frame->local = NULL; \
+ STACK_UNWIND_STRICT (fop, frame, op_ret, params); \
+ if (__local) { \
+ if (__local->inodelk_dom_count_req) \
+ data_unref (__local->inodelk_dom_count_req);\
+ loc_wipe (&__local->loc[0]); \
+ loc_wipe (&__local->loc[1]); \
+ if (__local->fd) \
+ fd_unref (__local->fd); \
+ mem_put (__local); \
+ } \
+ } while (0)
+
+/*
+ * The client is always requesting data, but older
+ * servers were not returning it. Newer ones are, so
+ * the client is receiving a mix of NULL and non-NULL
+ * xdata in the answers when bricks are of different
+ * versions. This triggers a bug in older clients.
+ * To prevent that, we avoid returning extra xdata to
+ * older clients (making the newer brick to behave as
+ * an old brick).
+ */
+#define PL_STACK_UNWIND_FOR_CLIENT(fop, xdata, frame, op_ret, params ...) \
+ do { \
+ pl_local_t *__local = NULL; \
+ if (frame->root->client && \
+ (frame->root->client->opversion < GD_OP_VERSION_3_10_0)) {\
+ __local = frame->local; \
+ PL_STACK_UNWIND_AND_FREE (__local, fop, frame, op_ret, params);\
+ } else { \
+ PL_STACK_UNWIND (fop, xdata, frame, op_ret, params); \
+ } \
+ } while (0)
+
#define PL_STACK_UNWIND(fop, xdata, frame, op_ret, params ...) \
do { \
pl_local_t *__local = NULL; \
@@ -67,17 +104,7 @@ static int fetch_pathinfo(xlator_t *, inode_t *, int32_t *, char **);
} \
} \
} \
- frame->local = NULL; \
- STACK_UNWIND_STRICT (fop, frame, op_ret, params); \
- if (__local) { \
- if (__local->inodelk_dom_count_req) \
- data_unref (__local->inodelk_dom_count_req);\
- loc_wipe (&__local->loc[0]); \
- loc_wipe (&__local->loc[1]); \
- if (__local->fd) \
- fd_unref (__local->fd); \
- mem_put (__local); \
- } \
+ PL_STACK_UNWIND_AND_FREE (__local, fop, frame, op_ret, params);\
if (__unref) \
dict_unref (__unref); \
} while (0)
@@ -1491,7 +1518,8 @@ int32_t
pl_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- PL_STACK_UNWIND (fsetxattr, xdata, frame, op_ret, op_errno, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (fsetxattr, xdata, frame,
+ op_ret, op_errno, xdata);
return 0;
}
@@ -1563,12 +1591,8 @@ pl_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- if (frame->root->client &&
- (frame->root->client->opversion < GD_OP_VERSION_3_10_0)) {
- STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno, xdata);
- } else {
- PL_STACK_UNWIND (flush, xdata, frame, op_ret, op_errno, xdata);
- }
+ PL_STACK_UNWIND_FOR_CLIENT (flush, xdata, frame,
+ op_ret, op_errno, xdata);
return 0;
}
@@ -3080,7 +3104,8 @@ int32_t
pl_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- PL_STACK_UNWIND (setxattr, xdata, frame, op_ret, op_errno, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (setxattr, xdata, frame,
+ op_ret, op_errno, xdata);
return 0;
}
@@ -3106,8 +3131,8 @@ pl_setxattr (call_frame_t *frame, xlator_t *this,
goto usual;
}
- PL_STACK_UNWIND (setxattr, xdata_rsp, frame, op_ret, op_errno,
- xdata_rsp);
+ PL_STACK_UNWIND_FOR_CLIENT (setxattr, xdata_rsp, frame,
+ op_ret, op_errno, xdata_rsp);
return 0;
usual:
@@ -3949,8 +3974,8 @@ pl_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
struct iatt *buf, struct iatt *preparent,
struct iatt *postparent, dict_t *xdata)
{
- PL_STACK_UNWIND (mkdir, xdata, frame, op_ret, op_errno,
- inode, buf, preparent, postparent, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (mkdir, xdata, frame, op_ret, op_errno,
+ inode, buf, preparent, postparent, xdata);
return 0;
}
@@ -3970,7 +3995,8 @@ pl_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *buf,
dict_t *xdata)
{
- PL_STACK_UNWIND (stat, xdata, frame, op_ret, op_errno, buf, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (stat, xdata, frame,
+ op_ret, op_errno, buf, xdata);
return 0;
}
@@ -3990,8 +4016,8 @@ pl_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
struct iatt *buf, struct iatt *preparent,
struct iatt *postparent, dict_t *xdata)
{
- PL_STACK_UNWIND (mknod, xdata, frame, op_ret, op_errno,
- inode, buf, preparent, postparent, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (mknod, xdata, frame, op_ret, op_errno,
+ inode, buf, preparent, postparent, xdata);
return 0;
}
@@ -4012,8 +4038,8 @@ pl_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *preparent,
struct iatt *postparent, dict_t *xdata)
{
- PL_STACK_UNWIND (rmdir, xdata, frame, op_ret, op_errno,
- preparent, postparent, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (rmdir, xdata, frame, op_ret, op_errno,
+ preparent, postparent, xdata);
return 0;
}
@@ -4034,8 +4060,8 @@ pl_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
struct iatt *buf, struct iatt *preparent,
struct iatt *postparent, dict_t *xdata)
{
- PL_STACK_UNWIND (symlink, xdata, frame, op_ret, op_errno,
- inode, buf, preparent, postparent, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (symlink, xdata, frame, op_ret, op_errno,
+ inode, buf, preparent, postparent, xdata);
return 0;
}
@@ -4057,8 +4083,8 @@ pl_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
struct iatt *buf, struct iatt *preparent,
struct iatt *postparent, dict_t *xdata)
{
- PL_STACK_UNWIND (link, xdata, frame, op_ret, op_errno,
- inode, buf, preparent, postparent, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (link, xdata, frame, op_ret, op_errno,
+ inode, buf, preparent, postparent, xdata);
return 0;
}
@@ -4078,8 +4104,8 @@ pl_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
struct iatt *postbuf,
dict_t *xdata)
{
- PL_STACK_UNWIND (fsync, xdata, frame, op_ret, op_errno,
- prebuf, postbuf, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (fsync, xdata, frame, op_ret, op_errno,
+ prebuf, postbuf, xdata);
return 0;
}
@@ -4098,8 +4124,8 @@ pl_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
dict_t *xdata)
{
- PL_STACK_UNWIND (readdir, xdata, frame, op_ret, op_errno,
- entries, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (readdir, xdata, frame, op_ret, op_errno,
+ entries, xdata);
return 0;
}
@@ -4120,7 +4146,8 @@ int32_t
pl_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- PL_STACK_UNWIND (fsyncdir, xdata, frame, op_ret, op_errno, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (fsyncdir, xdata, frame,
+ op_ret, op_errno, xdata);
return 0;
}
@@ -4140,7 +4167,8 @@ pl_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct statvfs *buf,
dict_t *xdata)
{
- PL_STACK_UNWIND (statfs, xdata, frame, op_ret, op_errno, buf, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (statfs, xdata, frame,
+ op_ret, op_errno, buf, xdata);
return 0;
}
@@ -4158,7 +4186,8 @@ int32_t
pl_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- PL_STACK_UNWIND (removexattr, xdata, frame, op_ret, op_errno, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (removexattr, xdata, frame,
+ op_ret, op_errno, xdata);
return 0;
}
@@ -4176,7 +4205,8 @@ int32_t
pl_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- PL_STACK_UNWIND (fremovexattr, xdata, frame, op_ret, op_errno, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (fremovexattr, xdata, frame,
+ op_ret, op_errno, xdata);
return 0;
}
@@ -4195,8 +4225,8 @@ pl_rchecksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, uint32_t weak_cksum,
uint8_t *strong_cksum, dict_t *xdata)
{
- PL_STACK_UNWIND (rchecksum, xdata, frame, op_ret, op_errno,
- weak_cksum, strong_cksum, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (rchecksum, xdata, frame, op_ret, op_errno,
+ weak_cksum, strong_cksum, xdata);
return 0;
}
@@ -4216,7 +4246,8 @@ pl_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict,
dict_t *xdata)
{
- PL_STACK_UNWIND (xattrop, xdata, frame, op_ret, op_errno, dict, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (xattrop, xdata, frame,
+ op_ret, op_errno, dict, xdata);
return 0;
}
@@ -4237,7 +4268,8 @@ pl_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict,
dict_t *xdata)
{
- PL_STACK_UNWIND (fxattrop, xdata, frame, op_ret, op_errno, dict, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (fxattrop, xdata, frame,
+ op_ret, op_errno, dict, xdata);
return 0;
}
@@ -4259,8 +4291,8 @@ pl_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
struct iatt *statpost,
dict_t *xdata)
{
- PL_STACK_UNWIND (setattr, xdata, frame, op_ret, op_errno,
- statpre, statpost, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (setattr, xdata, frame, op_ret, op_errno,
+ statpre, statpost, xdata);
return 0;
}
@@ -4279,8 +4311,8 @@ pl_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *statpre,
struct iatt *statpost, dict_t *xdata)
{
- PL_STACK_UNWIND (fsetattr, xdata, frame, op_ret, op_errno,
- statpre, statpost, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (fsetattr, xdata, frame, op_ret, op_errno,
+ statpre, statpost, xdata);
return 0;
}
@@ -4299,8 +4331,8 @@ pl_fallocate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *pre,
struct iatt *post, dict_t *xdata)
{
- PL_STACK_UNWIND (fallocate, xdata, frame, op_ret, op_errno,
- pre, post, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (fallocate, xdata, frame, op_ret, op_errno,
+ pre, post, xdata);
return 0;
}
@@ -4321,8 +4353,8 @@ pl_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, const char *path,
struct iatt *buf, dict_t *xdata)
{
- PL_STACK_UNWIND (readlink, xdata, frame, op_ret, op_errno,
- path, buf, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (readlink, xdata, frame, op_ret, op_errno,
+ path, buf, xdata);
return 0;
}
@@ -4340,7 +4372,8 @@ int32_t
pl_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- PL_STACK_UNWIND (access, xdata, frame, op_ret, op_errno, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (access, xdata, frame,
+ op_ret, op_errno, xdata);
return 0;
}
@@ -4359,7 +4392,8 @@ pl_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, off_t offset,
dict_t *xdata)
{
- PL_STACK_UNWIND (seek, xdata, frame, op_ret, op_errno, offset, xdata);
+ PL_STACK_UNWIND_FOR_CLIENT (seek, xdata, frame,
+ op_ret, op_errno, offset, xdata);
return 0;
}