summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2018-06-27 14:59:40 +0530
committerAmar Tumballi <amarts@redhat.com>2018-07-11 04:11:59 +0000
commit69f77d28c3ecacba77fbae2f789b5110641347f3 (patch)
tree746f1470476a981b6becaedb6c7c1e681f457f41 /xlators/storage/posix/src/posix-helpers.c
parentaf6c6429f9743f287baaad68f8e3d56ed7390d1b (diff)
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 <xhernandez@redhat.com> Signed-off-by: Poornima G <pgurusid@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c49
1 files changed, 40 insertions, 9 deletions
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;
}