diff options
author | Venky Shankar <vshankar@redhat.com> | 2015-12-30 14:56:12 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2016-01-10 04:43:28 -0800 |
commit | d5d6918ce7dc9f54496da435af546611dfbe7d5c (patch) | |
tree | 7815947be4e597ecf4fa1a3baf4bfbde29ef2e42 /xlators/features/bit-rot/src/stub | |
parent | 1cdea236601ebe872d432ff9ee63833dfac0d5cb (diff) |
features/bitrot: add check for corrupted object in f{stat}
Check for corrupted objects is done bt bitrot stub component
for data operations and such fops are denied processing by
returning EIO. These checks were not done for operations such
as get/set extended attribute, stat and the likes - IOW, stub
only blocked pure data operations.
However, its necessary to have these checks for certain other
fops, most importantly stat (and fstat). This is due to the
fact that clients could possibly get stale stat information
(such as size, {a,c,m}time) resulting in incorrect operation
of the application that rely on these fields. Note that, the
data that replication would take care of fetching good (and
correct) data, but the staleness of stat information could
lead to data inconsistencies (e.g., rebalance, tier).
Change-Id: I5a22780373b182a13f8d2c4ca6b7d9aa0ffbfca3
BUG: 1296399
Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-on: http://review.gluster.org/13120
Reviewed-by: Kotresh HR <khiremat@redhat.com>
Reviewed-by: mohammed rafi kc <rkavunga@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/bit-rot/src/stub')
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.c | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c index 94e694686f6..9c0f622fd94 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c @@ -2787,53 +2787,51 @@ br_stub_lookup (call_frame_t *frame, /** {{{ */ -/* fstat() */ -int br_stub_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *buf, - dict_t *xdata) +/* stat */ +int +br_stub_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { + int32_t ret = 0; + int32_t op_ret = -1; + int32_t op_errno = EINVAL; - int ret = 0; - br_stub_local_t *local = NULL; - inode_t *inode = NULL; + if (!IA_ISREG (loc->inode->ia_type)) + goto wind; - local = frame->local; - frame->local = NULL; - inode = local->u.context.inode; + ret = br_stub_check_bad_object (this, loc->inode, &op_ret, &op_errno); + if (ret) + goto unwind; - ret = br_stub_mark_xdata_bad_object (this, inode, xdata); - if (ret) { - op_ret = -1; - op_errno = EIO; - } + wind: + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->stat, loc, xdata); + return 0; - br_stub_cleanup_local(local); - br_stub_dealloc_local(local); - STACK_UNWIND_STRICT (fstat, frame, op_ret, op_errno, buf, xdata); +unwind: + STACK_UNWIND_STRICT (stat, frame, op_ret, op_errno, NULL, NULL); return 0; } +/* fstat */ int br_stub_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { - br_stub_local_t *local = NULL; - int32_t op_ret = -1; - int32_t op_errno = EINVAL; + int32_t ret = 0; + int32_t op_ret = -1; + int32_t op_errno = EINVAL; - local = br_stub_alloc_local (this); - if (!local) { - op_ret = -1; - op_errno = ENOMEM; - goto unwind; - } + if (!IA_ISREG (fd->inode->ia_type)) + goto wind; - br_stub_fill_local (local, NULL, fd, fd->inode, fd->inode->gfid, - BR_STUB_NO_VERSIONING, 0); - frame->local = local; + ret = br_stub_check_bad_object (this, fd->inode, &op_ret, &op_errno); + if (ret) + goto unwind; - STACK_WIND (frame, br_stub_fstat_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fstat, fd, xdata); + wind: + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fstat, fd, xdata); return 0; + unwind: STACK_UNWIND_STRICT (fstat, frame, op_ret, op_errno, NULL, NULL); return 0; @@ -3117,6 +3115,7 @@ unblock: struct xlator_fops fops = { .lookup = br_stub_lookup, + .stat = br_stub_stat, .fstat = br_stub_fstat, .open = br_stub_open, .create = br_stub_create, |