From a97ccc632fc425156e24b7c71de97248de62b2de Mon Sep 17 00:00:00 2001 From: Anuradha Talur Date: Mon, 22 Aug 2016 22:25:40 +0530 Subject: protocol/client: Unserialize xdata even if lookup fails Problem: AFR relies on xdata returned by lookup to determine if there are any files that need healing. This info is further used to optimize readdirp. In case of lookups with negative return value, client xlator was sending NULL xdata. Due to absence of xdata, AFR conservatively assumes that there are files that need healing, which is incorrect. Solution: Even in case of unsuccessful lookups, send the xdata received by protocol client so that higher xlators can get the info that they rely on. >Change-Id: Id3a1023eb536180888eb2c0b39050000b76f7226 >BUG: 1366284 >Signed-off-by: Anuradha Talur >Reviewed-on: http://review.gluster.org/15120 >Smoke: Gluster Build System >Reviewed-by: Poornima G >Tested-by: Poornima G >CentOS-regression: Gluster Build System >NetBSD-regression: NetBSD Build System >Reviewed-by: Ashish Pandey >Reviewed-by: Pranith Kumar Karampuri >Signed-off-by: Anuradha Talur Change-Id: Ia22bcb200d599b78677e429d25877c78f7d27612 BUG: 1369211 Signed-off-by: Anuradha Talur Reviewed-on: http://review.gluster.org/15259 Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri NetBSD-regression: NetBSD Build System Smoke: Gluster Build System Reviewed-by: Krutika Dhananjay CentOS-regression: Gluster Build System --- xlators/protocol/client/src/client-rpc-fops.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 19b7cf6b0e9..a9ca27742da 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -2933,18 +2933,19 @@ client3_3_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + /* Preserve the op_errno sent by server */ op_errno = gf_error_to_errno (rsp.op_errno); - gf_stat_to_iatt (&rsp.postparent, &postparent); - if (rsp.op_ret == -1) - goto out; - - rsp.op_ret = -1; - gf_stat_to_iatt (&rsp.stat, &stbuf); + if (rsp.op_ret != -1) { + gf_stat_to_iatt (&rsp.postparent, &postparent); + gf_stat_to_iatt (&rsp.stat, &stbuf); + } GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xdata, (rsp.xdata.xdata_val), - (rsp.xdata.xdata_len), rsp.op_ret, - op_errno, out); + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + if (rsp.op_ret < 0) + goto out; if ((!gf_uuid_is_null (inode->gfid)) && (gf_uuid_compare (stbuf.ia_gfid, inode->gfid) != 0)) { @@ -2960,8 +2961,14 @@ client3_3_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, } rsp.op_ret = 0; - + ret = 0; out: + /* If dict unserialize failed on a successful fop*/ + if (rsp.op_ret == 0 && ret < 0) { + rsp.op_ret = -1; + op_errno = rsp.op_errno; + } + /* Restore appropriate op_errno in response */ rsp.op_errno = op_errno; if (rsp.op_ret == -1) { /* any error other than ENOENT */ -- cgit