summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2015-12-16 05:45:03 -0500
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-05-19 02:28:07 -0700
commit8facd588f20ef8305b6f6b53da0f6d54d300093b (patch)
tree066a5c1d7f7bf4c56685be859ca5c256e4d8c1e8
parent005d18a623dc49397e2a83a7fb80607ae0a9aed9 (diff)
upcall: pass dict with xattrs on xattr invalidation
In case of xattr invalidation, return a dict containing the updated xattrs. [ndevos: move chunks to change 12995 and only address the xattrs-dict here] Change-Id: I8733f06a519a9a0f24be1bb4b2c38c9c9dce0ce2 BUG: 1211863 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/12996 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: soumya k <skoduri@redhat.com> Tested-by: soumya k <skoduri@redhat.com>
-rw-r--r--libglusterfs/src/common-utils.c34
-rw-r--r--libglusterfs/src/common-utils.h3
-rw-r--r--libglusterfs/src/upcall-utils.h1
-rw-r--r--rpc/xdr/src/glusterfs3.h44
-rw-r--r--xlators/features/upcall/src/upcall-internal.c23
-rw-r--r--xlators/features/upcall/src/upcall.c188
-rw-r--r--xlators/features/upcall/src/upcall.h10
-rw-r--r--xlators/protocol/client/src/client-callback.c12
-rw-r--r--xlators/protocol/server/src/server.c9
9 files changed, 229 insertions, 95 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 45886dae3ee..a225c957f2e 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -36,6 +36,7 @@
#endif
#include <libgen.h>
+#include "glusterfs-acl.h"
#include "compat-errno.h"
#include "logging.h"
#include "common-utils.h"
@@ -4449,3 +4450,36 @@ gf_zero_fill_stat (struct iatt *buf)
buf->ia_nlink = 0;
buf->ia_ctime = 0;
}
+
+/* This function checks if the input key is a virtual or on disk xattr.
+ * Its not simple to identify a virtual xattr as there is no common
+ * format used to identify virtual xattrs. One way is to list each of the
+ * xattrs in different categories and compare the input against every xattr
+ * in the list, this is very inefficient as there are 100s of xattrs.
+ *
+ * Currently the only consumer of this function is upcall and md-cache,
+ * hence tailoring this function to their needs; in their case its allowed
+ * to consider disk xattrs as virtual xattrs, but not vice versa, i.e.
+ * virtual xattrs should not be considered as on disk xattr. Hence, being
+ * conservative, we consider anything that starts from user.*, security.*,
+ * system.* as on disk xattrs. trusted.* and glusterfs.* cannot be considered
+ * as virtual xattrs as there are some on disk xattrs which start from
+ * glusterfs.* and trusted.*
+ *
+ * Hence, this function could return an on disk xattr as virtual xattr but
+ * never a virtual xattr as on disk xattr.
+ */
+gf_boolean_t
+is_virtual_xattr (const char *k)
+{
+ gf_boolean_t ret = _gf_true;
+
+ if ((strncmp (k, "user.", strlen ("user.")) == 0) ||
+ (strncmp (k, "security.", strlen ("security.")) == 0) ||
+ (strncmp (k, "system.", strlen ("system.")) == 0) ||
+ (GF_POSIX_ACL_REQUEST (k))) {
+ ret = _gf_false;
+ }
+
+ return ret;
+}
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 620468e8b09..09d585ad9c3 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -826,4 +826,7 @@ gf_is_zero_filled_stat (struct iatt *buf);
void
gf_zero_fill_stat (struct iatt *buf);
+gf_boolean_t
+is_virtual_xattr (const char *k);
+
#endif /* _COMMON_UTILS_H */
diff --git a/libglusterfs/src/upcall-utils.h b/libglusterfs/src/upcall-utils.h
index a4eaabf2032..33db4b273a1 100644
--- a/libglusterfs/src/upcall-utils.h
+++ b/libglusterfs/src/upcall-utils.h
@@ -74,6 +74,7 @@ struct gf_upcall_cache_invalidation {
struct iatt stat;
struct iatt p_stat; /* parent dir stat */
struct iatt oldp_stat; /* oldparent dir stat */
+ dict_t *dict; /* For xattrs */
};
struct gf_upcall_recall_lease {
diff --git a/rpc/xdr/src/glusterfs3.h b/rpc/xdr/src/glusterfs3.h
index b1d43f95e87..5e1f516457b 100644
--- a/rpc/xdr/src/glusterfs3.h
+++ b/rpc/xdr/src/glusterfs3.h
@@ -325,23 +325,24 @@ gf_stat_from_iatt (struct gf_iatt *gf_stat, struct iatt *iatt)
gf_stat->ia_ctime_nsec = iatt->ia_ctime_nsec ;
}
-static inline void
-gf_proto_cache_invalidation_from_upcall (gfs3_cbk_cache_invalidation_req *gf_c_req,
+static inline int
+gf_proto_cache_invalidation_from_upcall (xlator_t *this,
+ gfs3_cbk_cache_invalidation_req *gf_c_req,
struct gf_upcall *gf_up_data)
{
struct gf_upcall_cache_invalidation *gf_c_data = NULL;
int is_cache_inval = 0;
int ret = -1;
- GF_VALIDATE_OR_GOTO(THIS->name, gf_c_req, out);
- GF_VALIDATE_OR_GOTO(THIS->name, gf_up_data, out);
+ GF_VALIDATE_OR_GOTO(this->name, gf_c_req, out);
+ GF_VALIDATE_OR_GOTO(this->name, gf_up_data, out);
is_cache_inval = ((gf_up_data->event_type ==
GF_UPCALL_CACHE_INVALIDATION) ? 1 : 0);
- GF_VALIDATE_OR_GOTO(THIS->name, is_cache_inval, out);
+ GF_VALIDATE_OR_GOTO(this->name, is_cache_inval, out);
gf_c_data = (struct gf_upcall_cache_invalidation *)gf_up_data->data;
- GF_VALIDATE_OR_GOTO(THIS->name, gf_c_data, out);
+ GF_VALIDATE_OR_GOTO(this->name, gf_c_data, out);
gf_c_req->gfid = uuid_utoa (gf_up_data->gfid);
gf_c_req->event_type = gf_up_data->event_type;
@@ -351,29 +352,35 @@ gf_proto_cache_invalidation_from_upcall (gfs3_cbk_cache_invalidation_req *gf_c_r
gf_stat_from_iatt (&gf_c_req->parent_stat, &gf_c_data->p_stat);
gf_stat_from_iatt (&gf_c_req->oldparent_stat, &gf_c_data->oldp_stat);
+ ret = 0;
+ GF_PROTOCOL_DICT_SERIALIZE (this, gf_c_data->dict, &(gf_c_req->xdata).xdata_val,
+ (gf_c_req->xdata).xdata_len, ret, out);
+ if (ret > 0)
+ ret = -ret;
out:
- return;
+ return ret;
}
-static inline void
-gf_proto_cache_invalidation_to_upcall (gfs3_cbk_cache_invalidation_req *gf_c_req,
+static inline int
+gf_proto_cache_invalidation_to_upcall (xlator_t *this,
+ gfs3_cbk_cache_invalidation_req *gf_c_req,
struct gf_upcall *gf_up_data)
{
struct gf_upcall_cache_invalidation *gf_c_data = NULL;
int ret = -1;
- GF_VALIDATE_OR_GOTO(THIS->name, gf_c_req, out);
- GF_VALIDATE_OR_GOTO(THIS->name, gf_up_data, out);
+ GF_VALIDATE_OR_GOTO(this->name, gf_c_req, out);
+ GF_VALIDATE_OR_GOTO(this->name, gf_up_data, out);
gf_c_data = (struct gf_upcall_cache_invalidation *)gf_up_data->data;
- GF_VALIDATE_OR_GOTO(THIS->name, gf_c_data, out);
+ GF_VALIDATE_OR_GOTO(this->name, gf_c_data, out);
ret = gf_uuid_parse (gf_c_req->gfid, gf_up_data->gfid);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING, "gf_uuid_parse(%s) failed",
+ gf_log (this->name, GF_LOG_WARNING, "gf_uuid_parse(%s) failed",
gf_c_req->gfid);
gf_up_data->event_type = GF_UPCALL_EVENT_NULL;
- return;
+ goto out;
}
gf_up_data->event_type = gf_c_req->event_type;
@@ -384,7 +391,14 @@ gf_proto_cache_invalidation_to_upcall (gfs3_cbk_cache_invalidation_req *gf_c_req
gf_stat_to_iatt (&gf_c_req->parent_stat, &gf_c_data->p_stat);
gf_stat_to_iatt (&gf_c_req->oldparent_stat, &gf_c_data->oldp_stat);
+ ret = 0;
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, gf_c_data->dict,
+ (gf_c_req->xdata).xdata_val,
+ (gf_c_req->xdata).xdata_len, ret,
+ ret, out);
+ if (ret > 0)
+ ret = -ret;
out:
- return;
+ return ret;
}
#endif /* !_GLUSTERFS3_H */
diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c
index f9005df2ed7..f3c81aff15c 100644
--- a/xlators/features/upcall/src/upcall-internal.c
+++ b/xlators/features/upcall/src/upcall-internal.c
@@ -435,6 +435,16 @@ upcall_reaper_thread_init (xlator_t *this)
return ret;
}
+int
+up_filter_virtual_xattr (dict_t *d, char *k, data_t *v, void *tmp)
+{
+ if (is_virtual_xattr (k) == _gf_true) {
+ dict_del (d, k);
+ }
+
+ return 0;
+}
+
/*
* Given a client, first fetch upcall_entry_t from the inode_ctx client list.
* Later traverse through the client list of that upcall entry. If this client
@@ -448,7 +458,8 @@ upcall_reaper_thread_init (xlator_t *this)
void
upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client,
inode_t *inode, uint32_t flags, struct iatt *stbuf,
- struct iatt *p_stbuf, struct iatt *oldp_stbuf)
+ struct iatt *p_stbuf, struct iatt *oldp_stbuf,
+ dict_t *xattr)
{
upcall_client_t *up_client = NULL;
upcall_client_t *up_client_entry = NULL;
@@ -524,11 +535,12 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client,
* Also if the file is frequently accessed, set
* expire_time_attr to 0.
*/
- upcall_client_cache_invalidate(this,
+ upcall_client_cache_invalidate (this,
up_inode_ctx->gfid,
up_client_entry,
flags, stbuf,
- p_stbuf, oldp_stbuf);
+ p_stbuf, oldp_stbuf,
+ xattr);
}
if (!found) {
@@ -551,7 +563,7 @@ upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid,
upcall_client_t *up_client_entry,
uint32_t flags, struct iatt *stbuf,
struct iatt *p_stbuf,
- struct iatt *oldp_stbuf)
+ struct iatt *oldp_stbuf, dict_t *xattr)
{
struct gf_upcall up_req = {0,};
struct gf_upcall_cache_invalidation ca_req = {0,};
@@ -577,6 +589,7 @@ upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid,
ca_req.p_stat = *p_stbuf;
if (oldp_stbuf)
ca_req.oldp_stat = *oldp_stbuf;
+ ca_req.dict = xattr;
up_req.data = &ca_req;
up_req.event_type = GF_UPCALL_CACHE_INVALIDATION;
@@ -641,7 +654,7 @@ upcall_cache_forget (xlator_t *this, inode_t *inode, upcall_inode_ctx_t *up_inod
up_inode_ctx->gfid,
up_client_entry,
flags, NULL,
- NULL, NULL);
+ NULL, NULL, NULL);
}
}
diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c
index 8c8219f273c..e4cb50cd42b 100644
--- a/xlators/features/upcall/src/upcall.c
+++ b/xlators/features/upcall/src/upcall.c
@@ -47,7 +47,7 @@ up_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (open, frame, op_ret, op_errno, fd, xdata);
@@ -65,7 +65,7 @@ up_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -101,7 +101,7 @@ up_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_WRITE_FLAGS;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- postbuf, NULL, NULL);
+ postbuf, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (writev, frame, op_ret, op_errno,
@@ -121,7 +121,7 @@ up_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -161,7 +161,7 @@ up_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- stbuf, NULL, NULL);
+ stbuf, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (readv, frame, op_ret, op_errno, vector,
@@ -180,7 +180,7 @@ up_readv (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -219,7 +219,7 @@ up_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (lk, frame, op_ret, op_errno, lock, xdata);
@@ -236,7 +236,7 @@ up_lk (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -273,7 +273,7 @@ up_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_WRITE_FLAGS;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- postbuf, NULL, NULL);
+ postbuf, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (truncate, frame, op_ret, op_errno,
@@ -291,7 +291,7 @@ up_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -334,7 +334,7 @@ up_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
*/
flags = UP_ATTR_FLAGS;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- statpost, NULL, NULL);
+ statpost, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (setattr, frame, op_ret, op_errno,
@@ -352,7 +352,7 @@ up_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -393,7 +393,7 @@ up_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = (UP_RENAME_FLAGS | UP_PARENT_DENTRY_FLAGS);
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- stbuf, postnewparent, postoldparent);
+ stbuf, postnewparent, postoldparent, NULL);
out:
UPCALL_STACK_UNWIND (rename, frame, op_ret, op_errno,
@@ -412,7 +412,7 @@ up_rename (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, oldloc->inode);
+ local = upcall_local_init (frame, this, oldloc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -453,7 +453,7 @@ up_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS);
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, postparent, NULL);
+ NULL, postparent, NULL, NULL);
out:
UPCALL_STACK_UNWIND (unlink, frame, op_ret, op_errno,
@@ -471,7 +471,7 @@ up_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -509,7 +509,7 @@ up_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS);
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- stbuf, postparent, NULL);
+ stbuf, postparent, NULL, NULL);
out:
UPCALL_STACK_UNWIND (link, frame, op_ret, op_errno,
@@ -527,7 +527,7 @@ up_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, oldloc->inode);
+ local = upcall_local_init (frame, this, oldloc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -567,7 +567,7 @@ up_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS);
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, postparent, NULL);
+ NULL, postparent, NULL, NULL);
out:
UPCALL_STACK_UNWIND (rmdir, frame, op_ret, op_errno,
@@ -585,7 +585,7 @@ up_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -626,7 +626,7 @@ up_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* invalidate parent's entry too */
flags = UP_TIMES;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- postparent, NULL, NULL);
+ postparent, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (mkdir, frame, op_ret, op_errno,
@@ -644,7 +644,7 @@ up_mkdir (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->parent);
+ local = upcall_local_init (frame, this, loc->parent, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -687,7 +687,7 @@ up_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* However invalidate parent's entry */
flags = UP_TIMES;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- postparent, NULL, NULL);
+ postparent, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (create, frame, op_ret, op_errno, fd,
@@ -706,7 +706,7 @@ up_create (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->parent);
+ local = upcall_local_init (frame, this, loc->parent, NULL);
if (!local) {
op_errno = ENOMEM;
@@ -747,7 +747,7 @@ up_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- stbuf, NULL, NULL);
+ stbuf, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, stbuf,
@@ -765,7 +765,7 @@ up_lookup (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -804,7 +804,7 @@ up_stat_cbk (call_frame_t *frame, void *cookie,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- buf, NULL, NULL);
+ buf, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (stat, frame, op_ret, op_errno, buf,
@@ -821,7 +821,7 @@ up_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -849,7 +849,7 @@ up_fstat (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -877,7 +877,7 @@ up_ftruncate (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -915,7 +915,7 @@ up_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (access, frame, op_ret, op_errno, xdata);
@@ -932,7 +932,7 @@ up_access (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -970,7 +970,7 @@ up_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- stbuf, NULL, NULL);
+ stbuf, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (readlink, frame, op_ret, op_errno, path, stbuf,
@@ -988,7 +988,7 @@ up_readlink (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1030,7 +1030,7 @@ up_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* invalidate parent's entry too */
flags = UP_TIMES;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- postparent, NULL, NULL);
+ postparent, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, buf,
@@ -1048,7 +1048,7 @@ up_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->parent);
+ local = upcall_local_init (frame, this, loc->parent, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1090,7 +1090,7 @@ up_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* invalidate parent's entry too */
flags = UP_TIMES;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- postparent, NULL, NULL);
+ postparent, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (symlink, frame, op_ret, op_errno, inode, buf,
@@ -1109,7 +1109,7 @@ up_symlink (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->parent);
+ local = upcall_local_init (frame, this, loc->parent, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1148,7 +1148,7 @@ up_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (opendir, frame, op_ret, op_errno, fd, xdata);
@@ -1165,7 +1165,7 @@ up_opendir (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1203,7 +1203,7 @@ up_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (statfs, frame, op_ret, op_errno, buf, xdata);
@@ -1220,7 +1220,7 @@ up_statfs (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1258,7 +1258,7 @@ up_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (readdir, frame, op_ret, op_errno, entries, xdata);
@@ -1275,7 +1275,7 @@ up_readdir (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1303,7 +1303,7 @@ up_readdirp (call_frame_t *frame, xlator_t *this,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1331,7 +1331,7 @@ up_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1370,7 +1370,7 @@ up_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_WRITE_FLAGS;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- post, NULL, NULL);
+ post, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (fallocate, frame, op_ret, op_errno, pre,
@@ -1388,7 +1388,7 @@ up_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1427,7 +1427,7 @@ up_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_WRITE_FLAGS;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- post, NULL, NULL);
+ post, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (discard, frame, op_ret, op_errno, pre,
@@ -1445,7 +1445,7 @@ up_discard(call_frame_t *frame, xlator_t *this, fd_t *fd,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1484,7 +1484,7 @@ up_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_WRITE_FLAGS;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- post, NULL, NULL);
+ post, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (zerofill, frame, op_ret, op_errno, pre,
@@ -1502,7 +1502,7 @@ up_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1541,7 +1541,7 @@ up_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (seek, frame, op_ret, op_errno, offset, xdata);
@@ -1559,7 +1559,7 @@ up_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1585,6 +1585,7 @@ up_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
client_t *client = NULL;
uint32_t flags = 0;
upcall_local_t *local = NULL;
+ int ret = 0;
EXIT_IF_UPCALL_OFF (this, out);
@@ -1596,8 +1597,14 @@ up_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_XATTR;
+ /* Remove the virtual xattrs from the dict */
+ ret = dict_foreach (local->xattr, up_filter_virtual_xattr, NULL);
+ if (ret < 0) {
+ op_ret = ret;
+ goto out;
+ }
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, local->xattr);
out:
UPCALL_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata);
@@ -1612,10 +1619,17 @@ up_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
{
int32_t op_errno = -1;
upcall_local_t *local = NULL;
+ dict_t *xattr = NULL;
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ xattr = dict_copy_with_ref (dict, NULL);
+ if (!xattr) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ local = upcall_local_init (frame, this, loc->inode, xattr);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1642,6 +1656,7 @@ up_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
client_t *client = NULL;
uint32_t flags = 0;
upcall_local_t *local = NULL;
+ int ret = 0;
EXIT_IF_UPCALL_OFF (this, out);
@@ -1653,8 +1668,14 @@ up_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_XATTR;
+ /* Remove the virtual xattrs from the dict */
+ ret = dict_foreach (local->xattr, up_filter_virtual_xattr, NULL);
+ if (ret < 0) {
+ op_ret = ret;
+ goto out;
+ }
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, local->xattr);
out:
UPCALL_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, xdata);
@@ -1669,10 +1690,17 @@ up_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
{
int32_t op_errno = -1;
upcall_local_t *local = NULL;
+ dict_t *xattr = NULL;
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ xattr = dict_copy_with_ref (dict, NULL);
+ if (!xattr) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ local = upcall_local_init (frame, this, fd->inode, xattr);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1710,7 +1738,7 @@ up_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_XATTR_RM;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, local->xattr);
out:
UPCALL_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno,
@@ -1718,16 +1746,24 @@ out:
return 0;
}
+
int32_t
up_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
const char *name, dict_t *xdata)
{
int32_t op_errno = -1;
upcall_local_t *local = NULL;
+ dict_t *xattr = NULL;
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ xattr = dict_for_key_value (name, "", 1);
+ if (!xattr) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ local = upcall_local_init (frame, this, fd->inode, xattr);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1745,6 +1781,7 @@ err:
return 0;
}
+
int32_t
up_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
@@ -1763,7 +1800,7 @@ up_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
flags = UP_XATTR_RM;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, local->xattr);
out:
UPCALL_STACK_UNWIND (removexattr, frame, op_ret, op_errno,
@@ -1771,16 +1808,24 @@ out:
return 0;
}
+
int32_t
up_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
const char *name, dict_t *xdata)
{
int32_t op_errno = -1;
upcall_local_t *local = NULL;
+ dict_t *xattr = NULL;
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ xattr = dict_for_key_value (name, "", 1);
+ if (!xattr) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ local = upcall_local_init (frame, this, loc->inode, xattr);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1819,7 +1864,7 @@ up_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno,
@@ -1837,7 +1882,7 @@ up_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, fd->inode);
+ local = upcall_local_init (frame, this, fd->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1875,7 +1920,7 @@ up_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
out:
UPCALL_STACK_UNWIND (getxattr, frame, op_ret, op_errno,
@@ -1892,7 +1937,7 @@ up_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
EXIT_IF_UPCALL_OFF (this, out);
- local = upcall_local_init (frame, this, loc->inode);
+ local = upcall_local_init (frame, this, loc->inode, NULL);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1935,13 +1980,20 @@ upcall_local_wipe (xlator_t *this, upcall_local_t *local)
{
if (local) {
inode_unref (local->inode);
+ if (local->xattr) {
+ /* There will be 2 refs at this point, hence dict_destroy:
+ * 1. taken by dict_copy_with_ref
+ * 2. taken by upcall_local_init ()
+ */
+ dict_destroy (local->xattr);
+ }
loc_wipe (&local->rename_oldloc);
mem_put (local);
}
}
upcall_local_t *
-upcall_local_init (call_frame_t *frame, xlator_t *this, inode_t *inode)
+upcall_local_init (call_frame_t *frame, xlator_t *this, inode_t *inode, dict_t *xattr)
{
upcall_local_t *local = NULL;
@@ -1951,6 +2003,8 @@ upcall_local_init (call_frame_t *frame, xlator_t *this, inode_t *inode)
goto out;
local->inode = inode_ref (inode);
+ if (xattr)
+ local->xattr = dict_ref (xattr);
/* Shall we get inode_ctx and store it here itself? */
local->upcall_inode_ctx = upcall_inode_ctx_get (inode, this);
diff --git a/xlators/features/upcall/src/upcall.h b/xlators/features/upcall/src/upcall.h
index c96cc191ecc..5ad502f4a89 100644
--- a/xlators/features/upcall/src/upcall.h
+++ b/xlators/features/upcall/src/upcall.h
@@ -84,11 +84,13 @@ struct upcall_local {
upcall_inode_ctx_t *upcall_inode_ctx;
inode_t *inode;
loc_t rename_oldloc;
+ dict_t *xattr;
};
typedef struct upcall_local upcall_local_t;
void upcall_local_wipe (xlator_t *this, upcall_local_t *local);
-upcall_local_t *upcall_local_init (call_frame_t *frame, xlator_t *this, inode_t *inode);
+upcall_local_t *upcall_local_init (call_frame_t *frame, xlator_t *this,
+ inode_t *inode, dict_t *xattr);
upcall_client_t *add_upcall_client (call_frame_t *frame, client_t *client,
upcall_inode_ctx_t *up_inode_ctx);
@@ -118,11 +120,13 @@ void upcall_cache_invalidate (call_frame_t *frame, xlator_t *this,
client_t *client, inode_t *inode,
uint32_t flags, struct iatt *stbuf,
struct iatt *p_stbuf,
- struct iatt *oldp_stbuf);
+ struct iatt *oldp_stbuf, dict_t *xattr);
void upcall_client_cache_invalidate (xlator_t *xl, uuid_t gfid,
upcall_client_t *up_client_entry,
uint32_t flags, struct iatt *stbuf,
struct iatt *p_stbuf,
- struct iatt *oldp_stbuf);
+ struct iatt *oldp_stbuf, dict_t *xattr);
+
+int up_filter_virtual_xattr (dict_t *d, char *k, data_t *v, void *tmp);
#endif /* __UPCALL_H__ */
diff --git a/xlators/protocol/client/src/client-callback.c b/xlators/protocol/client/src/client-callback.c
index 4935ef5de7c..bedc8f6ec2b 100644
--- a/xlators/protocol/client/src/client-callback.c
+++ b/xlators/protocol/client/src/client-callback.c
@@ -103,10 +103,13 @@ client_cbk_cache_invalidation (struct rpc_clnt *rpc, void *mydata, void *data)
}
upcall_data.data = &ca_data;
- gf_proto_cache_invalidation_to_upcall (&ca_req, &upcall_data);
+ ret = gf_proto_cache_invalidation_to_upcall (THIS, &ca_req,
+ &upcall_data);
+ if (ret < 0)
+ goto out;
- gf_msg_trace (THIS->name, 0, "Upcall gfid = %s, ret = %d",
- ca_req.gfid, ret);
+ gf_msg_trace (THIS->name, 0, "Cache invalidation cbk recieved for gfid:"
+ " %s, ret = %d", ca_req.gfid, ret);
default_notify (THIS, GF_EVENT_UPCALL, &upcall_data);
@@ -117,6 +120,9 @@ out:
if (ca_req.xdata.xdata_val)
free (ca_req.xdata.xdata_val);
+ if (ca_data.dict)
+ dict_unref (ca_data.dict);
+
return 0;
}
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 99874acae72..0e8b28899bc 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -1200,8 +1200,10 @@ server_process_event_upcall (xlator_t *this, void *data)
switch (upcall_data->event_type) {
case GF_UPCALL_CACHE_INVALIDATION:
- gf_proto_cache_invalidation_from_upcall (&gf_c_req,
- upcall_data);
+ ret = gf_proto_cache_invalidation_from_upcall (this, &gf_c_req,
+ upcall_data);
+ if (ret < 0)
+ goto out;
up_req = &gf_c_req;
cbk_procnum = GF_CBK_CACHE_INVALIDATION;
@@ -1243,6 +1245,9 @@ server_process_event_upcall (xlator_t *this, void *data)
pthread_mutex_unlock (&conf->mutex);
ret = 0;
out:
+ if ((gf_c_req.xdata).xdata_val)
+ GF_FREE ((gf_c_req.xdata).xdata_val);
+
return ret;
}