summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/upcall/src/upcall-internal.c42
-rw-r--r--xlators/features/upcall/src/upcall.c8
-rw-r--r--xlators/features/upcall/src/upcall.h10
3 files changed, 38 insertions, 22 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);
diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c
index ceeb99c82c7..bc098873f5d 100644
--- a/xlators/features/upcall/src/upcall.c
+++ b/xlators/features/upcall/src/upcall.c
@@ -169,7 +169,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,
- NULL, NULL, NULL);
+ stbuf, NULL, NULL);
out:
UPCALL_STACK_UNWIND (readv, frame, op_ret, op_errno, vector,
@@ -765,7 +765,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,
- NULL, NULL, NULL);
+ stbuf, NULL, NULL);
out:
UPCALL_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, stbuf,
@@ -823,7 +823,7 @@ up_stat_cbk (call_frame_t *frame, void *cookie,
}
flags = UP_UPDATE_CLIENT;
upcall_cache_invalidate (frame, this, client, local->inode, flags,
- NULL, NULL, NULL);
+ buf, NULL, NULL);
out:
UPCALL_STACK_UNWIND (stat, frame, op_ret, op_errno, buf,
@@ -993,7 +993,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,
- NULL, NULL, NULL);
+ stbuf, NULL, NULL);
out:
UPCALL_STACK_UNWIND (readlink, frame, op_ret, op_errno, path, stbuf,
diff --git a/xlators/features/upcall/src/upcall.h b/xlators/features/upcall/src/upcall.h
index 295ddc26167..5b151b8d2a7 100644
--- a/xlators/features/upcall/src/upcall.h
+++ b/xlators/features/upcall/src/upcall.h
@@ -77,6 +77,7 @@ struct _upcall_inode_ctx_t {
pthread_mutex_t client_list_lock; /* mutex for clients list
of this upcall entry */
int destroy;
+ uuid_t gfid; /* gfid of the entry */
};
typedef struct _upcall_inode_ctx_t upcall_inode_ctx_t;
@@ -94,14 +95,11 @@ 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_client_t *add_upcall_client (call_frame_t *frame, uuid_t gfid,
- client_t *client,
+upcall_client_t *add_upcall_client (call_frame_t *frame, client_t *client,
upcall_inode_ctx_t *up_inode_ctx);
-upcall_client_t *__add_upcall_client (call_frame_t *frame, uuid_t gfid,
- client_t *client,
+upcall_client_t *__add_upcall_client (call_frame_t *frame, client_t *client,
upcall_inode_ctx_t *up_inode_ctx);
-upcall_client_t *__get_upcall_client (call_frame_t *frame, uuid_t gfid,
- client_t *client,
+upcall_client_t *__get_upcall_client (call_frame_t *frame, client_t *client,
upcall_inode_ctx_t *up_inode_ctx);
int __upcall_cleanup_client_entry (upcall_client_t *up_client);
int upcall_cleanup_expired_clients (xlator_t *this,