From 143714d96eff50501b1a5a3debf794cae9f91005 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 23 Aug 2017 18:18:24 +0200 Subject: arbiter: return ENOSYS for 'non readable' FOPs AFR marks the arbiter as 'non readable'. This has been introduced with commit 8ab87137 (afr: do not set arbiter as a readable subvol in inode context). arbiter_readv() should not get called anymore, so it could be removed. However, it is a good defensive approach to have all the inode read FOPs that can not be handled by the arbiter to return ENOSYS. > Reviewed-on: https://review.gluster.org/18103 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System (cherry picked from commit b1352d0974328b367afa7360e9523585efb7178d) Change-Id: I6ea41680832859bd6790dc8d7440ee98d38205fc BUG: 1489511 Signed-off-by: Niels de Vos Signed-off-by: Ravishankar N Reviewed-on: https://review.gluster.org/18227 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- xlators/features/arbiter/src/arbiter.c | 45 ++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/xlators/features/arbiter/src/arbiter.c b/xlators/features/arbiter/src/arbiter.c index 0e555c84274..cf0841653b7 100644 --- a/xlators/features/arbiter/src/arbiter.c +++ b/xlators/features/arbiter/src/arbiter.c @@ -88,15 +88,6 @@ arbiter_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) return 0; } -int32_t -arbiter_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset, uint32_t flags, dict_t *xdata) -{ - STACK_UNWIND_STRICT (readv, frame, -1, ENOTCONN, NULL, 0, NULL, NULL, - NULL); - return 0; -} - int32_t arbiter_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, dict_t *xdata) @@ -270,6 +261,23 @@ unwind: return 0; } +static int32_t +arbiter_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t offset, uint32_t flags, dict_t *xdata) +{ + STACK_UNWIND_STRICT (readv, frame, -1, ENOSYS, NULL, 0, NULL, NULL, + NULL); + return 0; +} + +static int32_t +arbiter_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + gf_seek_what_t what, dict_t *xdata) +{ + STACK_UNWIND_STRICT (seek, frame, -1, ENOSYS, 0, xdata); + return 0; +} + int32_t mem_acct_init (xlator_t *this) { @@ -328,13 +336,30 @@ fini (xlator_t *this) struct xlator_fops fops = { .lookup = arbiter_lookup, - .readv = arbiter_readv, + + /* Return success for these inode write FOPS without winding it down to + * posix; this is needed for AFR write transaction logic to work.*/ .truncate = arbiter_truncate, .writev = arbiter_writev, .ftruncate = arbiter_ftruncate, .fallocate = arbiter_fallocate, .discard = arbiter_discard, .zerofill = arbiter_zerofill, + + /* AFR is not expected to wind these inode read FOPS initiated by the + * application to the arbiter brick. But in case a bug causes them + * to be called, we return ENOSYS. */ + .readv = arbiter_readv, + .seek = arbiter_seek, + + /* The following inode read FOPS initiated by the application are not + * wound by AFR either but internal logic like shd, glfsheal and + * client side healing in AFR will send them for selfheal/ inode refresh + * operations etc.,so we need to wind them down to posix: + * + * (f)stat, readdir(p), readlink, (f)getxattr.*/ + + /* All other FOPs not listed here are safe to be wound down to posix.*/ }; struct xlator_cbks cbks = { -- cgit