From 69f77d28c3ecacba77fbae2f789b5110641347f3 Mon Sep 17 00:00:00 2001 From: Poornima G Date: Wed, 27 Jun 2018 14:59:40 +0530 Subject: md-cache: Do not invalidate cache post set/remove xattr Since setxattr and removexattr fops cbk do not carry poststat, the stat cache was being invalidated in setxatr/remoxattr cbk. Hence the further lookup wouldn't be served from cache. To prevent this invalidation, md-cache is modified to get the poststat in set/removexattr_cbk in dict. Co-authored with Xavi Hernandez. Change-Id: I6b946be2d20b807e2578825743c25ba5927a60b4 fixes: bz#1586018 Signed-off-by: Xavi Hernandez Signed-off-by: Poornima G --- xlators/storage/posix/src/posix-helpers.c | 49 +++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'xlators/storage/posix/src/posix-helpers.c') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index b02adf308ff..f4165cc1111 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -2846,25 +2846,56 @@ posix_is_bulk_removexattr (char *name, dict_t *xdata) } int32_t -posix_set_iatt_in_dict (dict_t *dict, struct iatt *in_stbuf) +posix_set_iatt_in_dict (dict_t *dict, struct iatt *preop, struct iatt *postop) { int ret = -1; struct iatt *stbuf = NULL; int32_t len = sizeof(struct iatt); + struct iatt *prebuf = NULL; + struct iatt *postbuf = NULL; - if (!dict || !in_stbuf) + if (!dict) return ret; - stbuf = GF_CALLOC (1, len, gf_common_mt_char); - if (!stbuf) - return ret; + if (postop) { + stbuf = GF_CALLOC (1, len, gf_common_mt_char); + if (!stbuf) + goto out; + memcpy (stbuf, postop, len); + ret = dict_set_iatt (dict, DHT_IATT_IN_XDATA_KEY, stbuf, + false); + if (ret < 0) { + GF_FREE (stbuf); + goto out; + } + } - memcpy (stbuf, in_stbuf, len); + if (preop) { + prebuf = GF_CALLOC (1, len, gf_common_mt_char); + if (!prebuf) + goto out; + memcpy (prebuf, preop, len); + ret = dict_set_iatt (dict, GF_PRESTAT, prebuf, false); + if (ret < 0) { + GF_FREE (prebuf); + goto out; + } + } - ret = dict_set_iatt (dict, DHT_IATT_IN_XDATA_KEY, stbuf, false); - if (ret) - GF_FREE (stbuf); + if (postop) { + postbuf = GF_CALLOC (1, len, gf_common_mt_char); + if (!postbuf) + goto out; + memcpy (postbuf, postop, len); + ret = dict_set_iatt (dict, GF_POSTSTAT, postbuf, false); + if (ret < 0) { + GF_FREE (postbuf); + goto out; + } + } + ret = 0; +out: return ret; } -- cgit