From 149db390fd89beee1e8a3d946d4224ba2a9b4711 Mon Sep 17 00:00:00 2001 From: Poornima G Date: Fri, 2 Jun 2017 10:05:33 +0530 Subject: upcall: Update the access time in missing cases Issue: In fops like rename, link, unlink etc, the parent dirrs' client access time was not being updated. And in fops like create, link, symlink etc. the new file/dirs' client access time was not updated. Solution: Update the client access time for both parent and new entry. Change-Id: Id9f63583216ae857f6251dca15797ac66fa85430 BUG: 1458127 Signed-off-by: Poornima G Reviewed-on: https://review.gluster.org/17450 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Niels de Vos --- xlators/features/upcall/src/upcall-internal.c | 6 +-- xlators/features/upcall/src/upcall.c | 68 ++++++++++++++++++++------- xlators/features/upcall/src/upcall.h | 1 - 3 files changed, 53 insertions(+), 22 deletions(-) (limited to 'xlators/features') diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c index f290ca11de8..285141d251b 100644 --- a/xlators/features/upcall/src/upcall-internal.c +++ b/xlators/features/upcall/src/upcall-internal.c @@ -541,9 +541,7 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, return; } - up_inode_ctx = ((upcall_local_t *)frame->local)->upcall_inode_ctx; - - if (!up_inode_ctx) + if (inode) up_inode_ctx = upcall_inode_ctx_get (inode, this); if (!up_inode_ctx) { @@ -558,7 +556,7 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, * 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)) { + if (gf_uuid_is_null (up_inode_ctx->gfid) && stbuf) { /* That means inode must have been invalid when this inode_ctx * is created. Copy the gfid value from stbuf instead. */ diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c index 0e9919d41c4..e20a2e87093 100644 --- a/xlators/features/upcall/src/upcall.c +++ b/xlators/features/upcall/src/upcall.c @@ -404,6 +404,18 @@ up_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, upcall_cache_invalidate (frame, this, client, local->inode, flags, stbuf, postnewparent, postoldparent, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, + local->rename_oldloc.parent, flags, + postoldparent, NULL, NULL, NULL); + + if (local->rename_oldloc.parent == local->loc.parent) + goto out; + + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, local->loc.parent, + flags, postnewparent, NULL, NULL, NULL); + out: UPCALL_STACK_UNWIND (rename, frame, op_ret, op_errno, stbuf, preoldparent, postoldparent, @@ -421,7 +433,7 @@ up_rename (call_frame_t *frame, xlator_t *this, EXIT_IF_UPCALL_OFF (this, out); - local = upcall_local_init (frame, this, NULL, NULL, oldloc->inode, NULL); + local = upcall_local_init (frame, this, newloc, NULL, oldloc->inode, NULL); if (!local) { op_errno = ENOMEM; goto err; @@ -464,6 +476,10 @@ up_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, upcall_cache_invalidate (frame, this, client, local->inode, flags, NULL, postparent, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, local->loc.parent, + flags, postparent, NULL, NULL, NULL); + out: UPCALL_STACK_UNWIND (unlink, frame, op_ret, op_errno, preparent, postparent, xdata); @@ -480,7 +496,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, NULL, NULL, loc->inode, NULL); + local = upcall_local_init (frame, this, loc, NULL, loc->inode, NULL); if (!local) { op_errno = ENOMEM; goto err; @@ -520,6 +536,10 @@ up_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, upcall_cache_invalidate (frame, this, client, local->inode, flags, stbuf, postparent, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, local->loc.parent, + flags, postparent, NULL, NULL, NULL); + out: UPCALL_STACK_UNWIND (link, frame, op_ret, op_errno, inode, stbuf, preparent, postparent, xdata); @@ -536,7 +556,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, NULL, NULL, oldloc->inode, NULL); + local = upcall_local_init (frame, this, newloc, NULL, oldloc->inode, NULL); if (!local) { op_errno = ENOMEM; goto err; @@ -578,6 +598,10 @@ up_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, upcall_cache_invalidate (frame, this, client, local->inode, flags, NULL, postparent, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, local->loc.parent, + flags, postparent, NULL, NULL, NULL); + out: UPCALL_STACK_UNWIND (rmdir, frame, op_ret, op_errno, preparent, postparent, xdata); @@ -594,7 +618,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, NULL, NULL, loc->inode, NULL); + local = upcall_local_init (frame, this, loc, NULL, loc->inode, NULL); if (!local) { op_errno = ENOMEM; goto err; @@ -637,6 +661,10 @@ up_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, upcall_cache_invalidate (frame, this, client, local->inode, flags, postparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, local->loc.inode, flags, + stbuf, NULL, NULL, NULL); + out: UPCALL_STACK_UNWIND (mkdir, frame, op_ret, op_errno, inode, stbuf, preparent, postparent, xdata); @@ -653,7 +681,7 @@ up_mkdir (call_frame_t *frame, xlator_t *this, EXIT_IF_UPCALL_OFF (this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->parent, NULL); + local = upcall_local_init (frame, this, loc, NULL, loc->parent, NULL); if (!local) { op_errno = ENOMEM; goto err; @@ -692,12 +720,17 @@ up_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - /* As its a new file create, no need of sending notification */ - /* However invalidate parent's entry */ + /* As its a new file create, no need of sending notification + * However invalidate parent's entry and update that fact that the + * client has accessed the newly created entry */ flags = UP_TIMES; upcall_cache_invalidate (frame, this, client, local->inode, flags, postparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, local->loc.inode, flags, + stbuf, NULL, NULL, NULL); + out: UPCALL_STACK_UNWIND (create, frame, op_ret, op_errno, fd, inode, stbuf, preparent, postparent, xdata); @@ -715,7 +748,7 @@ up_create (call_frame_t *frame, xlator_t *this, EXIT_IF_UPCALL_OFF (this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->parent, NULL); + local = upcall_local_init (frame, this, loc, NULL, loc->parent, NULL); if (!local) { op_errno = ENOMEM; @@ -1041,6 +1074,10 @@ up_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, upcall_cache_invalidate (frame, this, client, local->inode, flags, postparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, local->loc.inode, flags, + buf, NULL, NULL, NULL); + out: UPCALL_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, buf, preparent, postparent, xdata); @@ -1057,7 +1094,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, NULL, NULL, loc->parent, NULL); + local = upcall_local_init (frame, this, loc, NULL, loc->parent, NULL); if (!local) { op_errno = ENOMEM; goto err; @@ -1101,6 +1138,10 @@ up_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, upcall_cache_invalidate (frame, this, client, local->inode, flags, postparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate (frame, this, client, local->loc.inode, flags, + buf, NULL, NULL, NULL); + out: UPCALL_STACK_UNWIND (symlink, frame, op_ret, op_errno, inode, buf, preparent, postparent, xdata); @@ -1118,7 +1159,7 @@ up_symlink (call_frame_t *frame, xlator_t *this, EXIT_IF_UPCALL_OFF (this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->parent, NULL); + local = upcall_local_init (frame, this, loc, NULL, loc->parent, NULL); if (!local) { op_errno = ENOMEM; goto err; @@ -1325,10 +1366,6 @@ up_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, upcall_cache_invalidate (frame, this, client, local->inode, flags, NULL, NULL, NULL, NULL); - /* upcall_cache_invalidate optimises, by not calling inode_ctx_get - * if local->upcall_inode_ctx is set. Hence before processing - * the readdir entries unset this */ - local->upcall_inode_ctx = NULL; list_for_each_entry (entry, &entries->list, list) { if (entry->inode == NULL) { continue; @@ -2258,9 +2295,6 @@ upcall_local_init (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, if (xattr) local->xattr = dict_copy_with_ref (xattr, NULL); - /* Shall we get inode_ctx and store it here itself? */ - local->upcall_inode_ctx = upcall_inode_ctx_get (inode, this); - if (loc) loc_copy (&local->loc, loc); if (fd) diff --git a/xlators/features/upcall/src/upcall.h b/xlators/features/upcall/src/upcall.h index 4554248a708..159193f54e7 100644 --- a/xlators/features/upcall/src/upcall.h +++ b/xlators/features/upcall/src/upcall.h @@ -83,7 +83,6 @@ struct upcall_local { * pointers in 'local' which may get freed * in future by other thread */ - upcall_inode_ctx_t *upcall_inode_ctx; inode_t *inode; loc_t rename_oldloc; loc_t loc; /* required for stat in *xattr_cbk */ -- cgit