diff options
Diffstat (limited to 'xlators/features/upcall')
-rw-r--r-- | xlators/features/upcall/src/upcall-cache-invalidation.h | 3 | ||||
-rw-r--r-- | xlators/features/upcall/src/upcall-internal.c | 71 | ||||
-rw-r--r-- | xlators/features/upcall/src/upcall-messages.h | 1 | ||||
-rw-r--r-- | xlators/features/upcall/src/upcall.c | 153 | ||||
-rw-r--r-- | xlators/features/upcall/src/upcall.h | 32 |
5 files changed, 123 insertions, 137 deletions
diff --git a/xlators/features/upcall/src/upcall-cache-invalidation.h b/xlators/features/upcall/src/upcall-cache-invalidation.h index c39962b68c4..edb8285827f 100644 --- a/xlators/features/upcall/src/upcall-cache-invalidation.h +++ b/xlators/features/upcall/src/upcall-cache-invalidation.h @@ -33,6 +33,7 @@ delete the cache entry */ #define UP_FORGET 0x00000100 /* inode_forget on server side - invalidate the cache entry */ +#define UP_PARENT_TIMES 0x00000200 /* update parent dir times */ /* for fops - open, read, lk, */ #define UP_UPDATE_CLIENT (UP_ATIME) @@ -48,7 +49,7 @@ /* to invalidate parent directory entries for fops -rename, unlink, * rmdir, mkdir, create */ -#define UP_PARENT_DENTRY_FLAGS (UP_TIMES) +#define UP_PARENT_DENTRY_FLAGS (UP_PARENT_TIMES) /* for fop - unlink, link, rmdir, mkdir */ #define UP_NLINK_FLAGS (UP_NLINK | UP_TIMES) diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c index 19d19289624..b128ab3bdc9 100644 --- a/xlators/features/upcall/src/upcall-internal.c +++ b/xlators/features/upcall/src/upcall-internal.c @@ -294,7 +294,7 @@ upcall_cleanup_expired_clients (xlator_t *this, goto out; } gf_log (THIS->name, GF_LOG_TRACE, - "Cleaned up client_entry(%s) of", + "Cleaned up client_entry(%s)", up_client->client_uid); } } @@ -450,24 +450,6 @@ upcall_reaper_thread_init (xlator_t *this) return ret; } -void -upcall_cache_invalidate_dir (call_frame_t *frame, xlator_t *this, - client_t *client, inode_t *inode, uint32_t flags) -{ - dentry_t *dentry; - dentry_t *dentry_tmp; - - if (!is_cache_invalidation_enabled(this)) - return; - - list_for_each_entry_safe (dentry, dentry_tmp, - &inode->dentry_list, - inode_list) { - upcall_cache_invalidate (frame, this, client, - dentry->inode, flags); - } -} - /* * Given a gfid, client, first fetch upcall_entry_t based on gfid. * Later traverse through the client list of that upcall entry. If this client @@ -480,7 +462,8 @@ upcall_cache_invalidate_dir (call_frame_t *frame, xlator_t *this, */ void upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, - inode_t *inode, uint32_t flags) + inode_t *inode, uint32_t flags, struct iatt *stbuf, + struct iatt *p_stbuf, struct iatt *oldp_stbuf) { upcall_client_t *up_client = NULL; upcall_client_t *up_client_entry = NULL; @@ -536,7 +519,8 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, upcall_client_cache_invalidate(this, inode->gfid, up_client_entry, - flags); + flags, stbuf, + p_stbuf, oldp_stbuf); } if (!found) { @@ -556,28 +540,50 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, void upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid, upcall_client_t *up_client_entry, - uint32_t flags) + uint32_t flags, struct iatt *stbuf, + struct iatt *p_stbuf, + struct iatt *oldp_stbuf) { - notify_event_data_t n_event_data; - time_t timeout = 0; + struct gf_upcall up_req = {0,}; + struct gf_upcall_cache_invalidation ca_req = {0,}; + time_t timeout = 0; + int ret = -1; time_t t_expired = time(NULL) - up_client_entry->access_time; timeout = get_cache_invalidation_timeout(this); if (t_expired < timeout) { /* Send notify call */ - gf_uuid_copy(n_event_data.gfid, gfid); - n_event_data.client_entry = up_client_entry; - n_event_data.event_type = GF_UPCALL_CACHE_INVALIDATION; - n_event_data.invalidate_flags = flags; - - /* Need to send inode flags */ - this->notify (this, GF_EVENT_UPCALL, &n_event_data); + up_req.client_uid = up_client_entry->client_uid; + gf_uuid_copy (up_req.gfid, gfid); + + ca_req.flags = flags; + ca_req.expire_time_attr = + up_client_entry->expire_time_attr; + if (stbuf) + ca_req.stat = *stbuf; + if (p_stbuf) + ca_req.p_stat = *p_stbuf; + if (oldp_stbuf) + ca_req.oldp_stat = *oldp_stbuf; + + up_req.data = &ca_req; + up_req.event_type = GF_UPCALL_CACHE_INVALIDATION; gf_log (THIS->name, GF_LOG_TRACE, "Cache invalidation notification sent to %s", up_client_entry->client_uid); + /* Need to send inode flags */ + ret = this->notify (this, GF_EVENT_UPCALL, &up_req); + + /* + * notify may fail as the client could have been + * dis(re)connected. Cleanup the client entry. + */ + if (ret < 0) + __upcall_cleanup_client_entry (up_client_entry); + } else { gf_log (THIS->name, GF_LOG_TRACE, "Cache invalidation notification NOT sent to %s", @@ -621,7 +627,8 @@ upcall_cache_forget (xlator_t *this, inode_t *inode, upcall_inode_ctx_t *up_inod upcall_client_cache_invalidate(this, inode->gfid, up_client_entry, - flags); + flags, NULL, + NULL, NULL); } } diff --git a/xlators/features/upcall/src/upcall-messages.h b/xlators/features/upcall/src/upcall-messages.h index 7b004d678c3..5472b4a5cbd 100644 --- a/xlators/features/upcall/src/upcall-messages.h +++ b/xlators/features/upcall/src/upcall-messages.h @@ -57,6 +57,7 @@ */ #define UPCALL_MSG_NO_MEMORY (GLFS_COMP_BASE_UPCALL + 1) #define UPCALL_MSG_INTERNAL_ERROR (GLFS_COMP_BASE_UPCALL + 2) +#define UPCALL_MSG_NOTIFY_FAILED (GLFS_COMP_BASE_UPCALL + 3) #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c index c68c0258fb8..5f6c29e1b79 100644 --- a/xlators/features/upcall/src/upcall.c +++ b/xlators/features/upcall/src/upcall.c @@ -51,7 +51,8 @@ up_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (open, frame, op_ret, op_errno, fd, xdata); @@ -105,7 +106,8 @@ up_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + postbuf, NULL, NULL); out: UPCALL_STACK_UNWIND (writev, frame, op_ret, op_errno, @@ -166,7 +168,8 @@ up_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (readv, frame, op_ret, op_errno, vector, @@ -224,7 +227,8 @@ up_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (lk, frame, op_ret, op_errno, lock, xdata); @@ -278,7 +282,8 @@ up_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + postbuf, NULL, NULL); out: UPCALL_STACK_UNWIND (truncate, frame, op_ret, op_errno, @@ -339,7 +344,8 @@ up_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, * Bug1200271. */ flags = UP_ATTR_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + statpost, NULL, NULL); out: UPCALL_STACK_UNWIND (setattr, frame, op_ret, op_errno, @@ -397,17 +403,9 @@ up_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((op_ret < 0) || !local) { goto out; } - flags = UP_RENAME_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); - - /* Need to invalidate old and new parent entries as well */ - flags = UP_PARENT_DENTRY_FLAGS; - upcall_cache_invalidate_dir (frame, this, client, local->inode, flags); - - /* notify oldparent as well */ - flags = UP_PARENT_DENTRY_FLAGS; - upcall_cache_invalidate_dir (frame, this, client, - local->rename_oldloc.inode, flags); + flags = (UP_RENAME_FLAGS | UP_PARENT_DENTRY_FLAGS); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + stbuf, postnewparent, postoldparent); out: UPCALL_STACK_UNWIND (rename, frame, op_ret, op_errno, @@ -466,12 +464,9 @@ up_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((op_ret < 0) || !local) { goto out; } - flags = UP_NLINK_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); - - flags = UP_PARENT_DENTRY_FLAGS; - /* invalidate parent's entry too */ - upcall_cache_invalidate_dir (frame, this, client, local->inode, flags); + flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, postparent, NULL); out: UPCALL_STACK_UNWIND (unlink, frame, op_ret, op_errno, @@ -526,10 +521,10 @@ up_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((op_ret < 0) || !local) { goto out; } - flags = UP_NLINK_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + stbuf, postparent, NULL); - /* do we need to update parent as well?? */ out: UPCALL_STACK_UNWIND (link, frame, op_ret, op_errno, inode, stbuf, preparent, postparent, xdata); @@ -584,12 +579,10 @@ up_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((op_ret < 0) || !local) { goto out; } - flags = UP_NLINK_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); - /* invalidate parent's entry too */ - flags = UP_PARENT_DENTRY_FLAGS; - upcall_cache_invalidate_dir (frame, this, client, local->inode, flags); + flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, postparent, NULL); out: UPCALL_STACK_UNWIND (rmdir, frame, op_ret, op_errno, @@ -648,7 +641,8 @@ up_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* invalidate parent's entry too */ flags = UP_PARENT_DENTRY_FLAGS; - upcall_cache_invalidate_dir (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + stbuf, postparent, NULL); out: UPCALL_STACK_UNWIND (mkdir, frame, op_ret, op_errno, @@ -709,7 +703,8 @@ up_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* As its a new file create, no need of sending notification */ /* However invalidate parent's entry */ flags = UP_PARENT_DENTRY_FLAGS; - upcall_cache_invalidate_dir (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + stbuf, postparent, NULL); out: UPCALL_STACK_UNWIND (create, frame, op_ret, op_errno, fd, @@ -769,7 +764,8 @@ up_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, stbuf, @@ -826,7 +822,8 @@ up_stat_cbk (call_frame_t *frame, void *cookie, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (stat, frame, op_ret, op_errno, buf, @@ -939,7 +936,8 @@ up_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (access, frame, op_ret, op_errno, xdata); @@ -994,7 +992,8 @@ up_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (readlink, frame, op_ret, op_errno, path, stbuf, @@ -1054,7 +1053,8 @@ up_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* invalidate parent's entry too */ flags = UP_PARENT_DENTRY_FLAGS; - upcall_cache_invalidate_dir (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + buf, postparent, NULL); out: UPCALL_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, buf, @@ -1114,7 +1114,8 @@ up_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* invalidate parent's entry too */ flags = UP_PARENT_DENTRY_FLAGS; - upcall_cache_invalidate_dir (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + buf, postparent, NULL); out: UPCALL_STACK_UNWIND (symlink, frame, op_ret, op_errno, inode, buf, @@ -1172,7 +1173,8 @@ up_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (opendir, frame, op_ret, op_errno, fd, xdata); @@ -1227,7 +1229,8 @@ up_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (statfs, frame, op_ret, op_errno, buf, xdata); @@ -1282,7 +1285,8 @@ up_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + NULL, NULL, NULL); out: UPCALL_STACK_UNWIND (readdir, frame, op_ret, op_errno, entries, xdata); @@ -1396,7 +1400,8 @@ up_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + post, NULL, NULL); out: UPCALL_STACK_UNWIND (fallocate, frame, op_ret, op_errno, pre, @@ -1453,7 +1458,8 @@ up_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + post, NULL, NULL); out: UPCALL_STACK_UNWIND (discard, frame, op_ret, op_errno, pre, @@ -1510,7 +1516,8 @@ up_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, goto out; } flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags); + upcall_cache_invalidate (frame, this, client, local->inode, flags, + post, NULL, NULL); out: UPCALL_STACK_UNWIND (zerofill, frame, op_ret, op_errno, pre, @@ -1725,10 +1732,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) { int ret = -1; int32_t val = 0; - notify_event_data_t *notify_event = NULL; - struct gf_upcall up_req = {0,}; - upcall_client_t *up_client_entry = NULL; - struct gf_upcall_cache_invalidation ca_req = {0,}; + struct gf_upcall *up_req = NULL; switch (event) { case GF_EVENT_UPCALL: @@ -1736,41 +1740,20 @@ notify (xlator_t *this, int32_t event, void *data, ...) gf_log (this->name, GF_LOG_DEBUG, "Upcall Notify event = %d", event); - notify_event = (notify_event_data_t *) data; - up_client_entry = notify_event->client_entry; + up_req = (struct gf_upcall *) data; - if (!up_client_entry) { - goto out; - } + GF_VALIDATE_OR_GOTO(this->name, up_req, out); + + ret = default_notify (this, event, up_req); - up_req.client_uid = up_client_entry->client_uid; - - gf_uuid_copy (up_req.gfid, notify_event->gfid); - gf_log (this->name, GF_LOG_DEBUG, - "Sending notify to the client- %s, gfid - %s", - up_client_entry->client_uid, up_req.gfid); - - switch (notify_event->event_type) { - case GF_UPCALL_CACHE_INVALIDATION: - ca_req.flags = notify_event->invalidate_flags; - ca_req.expire_time_attr = - up_client_entry->expire_time_attr; - up_req.data = &ca_req; - break; - default: + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + UPCALL_MSG_NOTIFY_FAILED, + "Failed to notify cache invalidation" + " to client(%s)", + up_req->client_uid); goto out; } - - up_req.event_type = notify_event->event_type; - - ret = default_notify (this, event, &up_req); - - /* - * notify may fail as the client could have been - * dis(re)connected. Cleanup the client entry. - */ - if (ret < 0) - __upcall_cleanup_client_entry (up_client_entry); } break; default: @@ -1784,7 +1767,15 @@ out: } struct xlator_fops fops = { - /* fops which do not trigger upcall + /* fops which change only "ATIME" do not result + * in any cache invalidation. Hence upcall + * notifications are not sent in this case. + * But however, we need to store/update the + * client info in the upcall state to be able + * to notify them incase of any changes done + * to the data. + * + * Below such fops do not trigger upcall * notifications but will add/update * clients info in the upcall inode ctx.*/ .lookup = up_lookup, diff --git a/xlators/features/upcall/src/upcall.h b/xlators/features/upcall/src/upcall.h index 41895786382..295ddc26167 100644 --- a/xlators/features/upcall/src/upcall.h +++ b/xlators/features/upcall/src/upcall.h @@ -16,15 +16,11 @@ #endif #include "compat-errno.h" -#include "stack.h" -#include "call-stub.h" #include "upcall-mem-types.h" #include "client_t.h" -#include "rpcsvc.h" -#include "lkowner.h" -#include "locking.h" #include "upcall-messages.h" #include "upcall-cache-invalidation.h" +#include "upcall-utils.h" #define EXIT_IF_UPCALL_OFF(this, label) do { \ if (!is_upcall_enabled(this)) \ @@ -84,18 +80,6 @@ struct _upcall_inode_ctx_t { }; typedef struct _upcall_inode_ctx_t upcall_inode_ctx_t; -struct _notify_event_data { - uuid_t gfid; - upcall_client_t *client_entry; - gf_upcall_event_t event_type; - uint32_t invalidate_flags; - /* any extra data needed, like inode flags - * to be invalidated incase of cache invalidation, - * may be fd for lease recalls */ - void *extra; -}; -typedef struct _notify_event_data notify_event_data_t; - struct upcall_local { /* XXX: need to check if we can store * pointers in 'local' which may get freed @@ -137,13 +121,15 @@ int upcall_reaper_thread_init (xlator_t *this); gf_boolean_t is_upcall_enabled(xlator_t *this); /* Cache invalidation specific */ -void upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, - inode_t *inode, uint32_t flags); +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); void upcall_client_cache_invalidate (xlator_t *xl, uuid_t gfid, upcall_client_t *up_client_entry, - uint32_t flags); -void upcall_cache_invalidate_dir (call_frame_t *frame, xlator_t *this, - client_t *client, inode_t *inode, - uint32_t flags); + uint32_t flags, struct iatt *stbuf, + struct iatt *p_stbuf, + struct iatt *oldp_stbuf); #endif /* __UPCALL_H__ */ |