summaryrefslogtreecommitdiffstats
path: root/xlators/features/upcall/src/upcall-internal.c
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2015-11-27 12:09:22 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2015-12-03 14:52:37 -0800
commit45c2a17ce96d4802ddd2b36a5131b64caa8b1a3c (patch)
tree4f9c2f9b634d9ee7f9e7f7b5189a0f713dc8caa3 /xlators/features/upcall/src/upcall-internal.c
parent49a40cb3b9a776b6c69a57e557a6fb80f7ac3a40 (diff)
Upcall: Read gfid from iatt in case of invalid inode
When any file/dir is looked upon for the first time, inode created shall be invalid till it gets linked to the inode table. In such cases, read the gfid from the iatt structure returned as part of such fops for UPCALL processing. This is backport of the below patch - http://review.gluster.org/12773 Change-Id: Ie5eb2f3be18c34cf7ef172e126c9db5ef7a8512b BUG: 1287079 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/12773 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/12839 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/upcall/src/upcall-internal.c')
-rw-r--r--xlators/features/upcall/src/upcall-internal.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c
index cd4abb6bbbc..a783c62785b 100644
--- a/xlators/features/upcall/src/upcall-internal.c
+++ b/xlators/features/upcall/src/upcall-internal.c
@@ -93,8 +93,7 @@ get_cache_invalidation_timeout(xlator_t *this) {
* Allocate and add a new client entry to the given upcall entry
*/
upcall_client_t*
-add_upcall_client (call_frame_t *frame, uuid_t gfid,
- client_t *client,
+add_upcall_client (call_frame_t *frame, client_t *client,
upcall_inode_ctx_t *up_inode_ctx)
{
upcall_client_t *up_client_entry = NULL;
@@ -102,7 +101,6 @@ add_upcall_client (call_frame_t *frame, uuid_t gfid,
pthread_mutex_lock (&up_inode_ctx->client_list_lock);
{
up_client_entry = __add_upcall_client (frame,
- gfid,
client,
up_inode_ctx);
}
@@ -112,8 +110,7 @@ add_upcall_client (call_frame_t *frame, uuid_t gfid,
}
upcall_client_t*
-__add_upcall_client (call_frame_t *frame, uuid_t gfid,
- client_t *client,
+__add_upcall_client (call_frame_t *frame, client_t *client,
upcall_inode_ctx_t *up_inode_ctx)
{
upcall_client_t *up_client_entry = NULL;
@@ -142,11 +139,11 @@ __add_upcall_client (call_frame_t *frame, uuid_t gfid,
}
/*
- * Given gfid and client->uid, retrieve the corresponding upcall client entry.
+ * Given client->uid, retrieve the corresponding upcall client entry.
* If none found, create a new entry.
*/
upcall_client_t*
-__get_upcall_client (call_frame_t *frame, uuid_t gfid, client_t *client,
+__get_upcall_client (call_frame_t *frame, client_t *client,
upcall_inode_ctx_t *up_inode_ctx)
{
upcall_client_t *up_client_entry = NULL;
@@ -170,7 +167,7 @@ __get_upcall_client (call_frame_t *frame, uuid_t gfid, client_t *client,
}
if (!found_client) { /* create one */
- up_client_entry = __add_upcall_client (frame, gfid, client,
+ up_client_entry = __add_upcall_client (frame, client,
up_inode_ctx);
}
@@ -205,6 +202,7 @@ __upcall_inode_ctx_set (inode_t *inode, xlator_t *this)
INIT_LIST_HEAD (&inode_ctx->inode_ctx_list);
INIT_LIST_HEAD (&inode_ctx->client_list);
inode_ctx->destroy = 0;
+ gf_uuid_copy (inode_ctx->gfid, inode->gfid);
ctx = (long) inode_ctx;
ret = __inode_ctx_set (inode, this, &ctx);
@@ -463,7 +461,7 @@ upcall_reaper_thread_init (xlator_t *this)
}
/*
- * Given a gfid, client, first fetch upcall_entry_t based on gfid.
+ * 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
* is not present in the list, create one client entry with this client info.
* Also check if there are other clients which need to be notified of this
@@ -507,16 +505,31 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client,
return;
}
+ /* In case of LOOKUP, if first time, inode created shall be
+ * invalid till it gets linked to inode table. Read gfid from
+ * the stat returned in such cases.
+ */
+ if (gf_uuid_is_null (up_inode_ctx->gfid)) {
+ /* That means inode must have been invalid when this inode_ctx
+ * is created. Copy the gfid value from stbuf instead.
+ */
+ gf_uuid_copy (up_inode_ctx->gfid, stbuf->ia_gfid);
+ }
+
+ GF_VALIDATE_OR_GOTO ("upcall_cache_invalidate",
+ !(gf_uuid_is_null (up_inode_ctx->gfid)), out);
pthread_mutex_lock (&up_inode_ctx->client_list_lock);
{
list_for_each_entry_safe (up_client_entry, tmp,
&up_inode_ctx->client_list,
client_list) {
+ /* Do not send UPCALL event if same client. */
if (!strcmp(client->client_uid,
up_client_entry->client_uid)) {
up_client_entry->access_time = time(NULL);
found = _gf_true;
+ continue;
}
/*
@@ -537,7 +550,7 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client,
* expire_time_attr to 0.
*/
upcall_client_cache_invalidate(this,
- inode->gfid,
+ up_inode_ctx->gfid,
up_client_entry,
flags, stbuf,
p_stbuf, oldp_stbuf);
@@ -545,12 +558,13 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client,
if (!found) {
up_client_entry = __add_upcall_client (frame,
- inode->gfid,
client,
up_inode_ctx);
}
}
pthread_mutex_unlock (&up_inode_ctx->client_list_lock);
+out:
+ return;
}
/*
@@ -570,6 +584,8 @@ upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid,
int ret = -1;
time_t t_expired = time(NULL) - up_client_entry->access_time;
+ GF_VALIDATE_OR_GOTO ("upcall_client_cache_invalidate",
+ !(gf_uuid_is_null (gfid)), out);
timeout = get_cache_invalidation_timeout(this);
if (t_expired < timeout) {
@@ -614,6 +630,8 @@ upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid,
"Cache invalidation notification NOT sent to %s",
up_client_entry->client_uid);
}
+out:
+ return;
}
/*
@@ -645,7 +663,7 @@ upcall_cache_forget (xlator_t *this, inode_t *inode, upcall_inode_ctx_t *up_inod
up_client_entry->access_time = time(NULL);
upcall_client_cache_invalidate(this,
- inode->gfid,
+ up_inode_ctx->gfid,
up_client_entry,
flags, NULL,
NULL, NULL);