summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2015-11-27 12:09:22 +0530
committerNiels de Vos <ndevos@redhat.com>2015-12-01 02:32:50 -0800
commitffe80877a0eb0eaf2540be95b401623c6d7c722f (patch)
tree706b3d81a1a0b63a11da2b8f1b0d44c0e9223911 /xlators
parentf2c52ae206f309ec636a299a76849c843c8ab83d (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. Change-Id: Ie5eb2f3be18c34cf7ef172e126c9db5ef7a8512b BUG: 1283983 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/12773 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'xlators')
-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 007a8f854bf..81199eb074c 100644
--- a/xlators/features/upcall/src/upcall-internal.c
+++ b/xlators/features/upcall/src/upcall-internal.c
@@ -88,8 +88,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;
@@ -97,7 +96,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);
}
@@ -107,8 +105,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;
@@ -137,11 +134,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;
@@ -165,7 +162,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);
}
@@ -200,6 +197,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);
@@ -458,7 +456,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
@@ -502,16 +500,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;
}
/*
@@ -532,7 +545,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);
@@ -540,12 +553,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;
}
/*
@@ -565,6 +579,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) {
@@ -609,6 +625,8 @@ upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid,
__upcall_cleanup_client_entry (up_client_entry);
}
}
+out:
+ return;
}
/*
@@ -640,7 +658,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 fc04d4d5d51..9b724928010 100644
--- a/xlators/features/upcall/src/upcall.c
+++ b/xlators/features/upcall/src/upcall.c
@@ -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,
- NULL, NULL, NULL);
+ stbuf, NULL, NULL);
out:
UPCALL_STACK_UNWIND (readv, frame, op_ret, op_errno, vector,
@@ -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,
- NULL, NULL, NULL);
+ stbuf, NULL, NULL);
out:
UPCALL_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, stbuf,
@@ -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,
- NULL, NULL, NULL);
+ buf, NULL, NULL);
out:
UPCALL_STACK_UNWIND (stat, frame, op_ret, op_errno, buf,
@@ -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,
- 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 eb1c7df89be..344c9c362eb 100644
--- a/xlators/features/upcall/src/upcall.h
+++ b/xlators/features/upcall/src/upcall.h
@@ -72,6 +72,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;
@@ -89,14 +90,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,