diff options
author | Raghavendra Bhat <raghavendra@redhat.com> | 2015-06-27 13:17:32 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2015-08-11 21:17:39 -0700 |
commit | 7b44b6c16fb538e5f15a255182de4dee781994a0 (patch) | |
tree | 19207dfd0469c37a43f1ac9e50d31febbcabcbe8 /xlators/features/bit-rot/src/stub/bit-rot-stub.h | |
parent | 8d7a4f6b0aa8e63e1a0802e22bcebe96e4e7490f (diff) |
features/bit-rot-stub: fail the fop if inode context get fails
In stub, for fops like readv, writev etc, if the the object is bad, then the fop
is denied. But for checking if the object is bad inode context should be
checked. Now, if the inode context is not there, then the fop is allowed to
continue. This patch fixes it and the fop is unwound with an error, if the inode
context is not found.
Change-Id: I5ea4d4fc1a91387f7f9d13ca8cb43c88429f02b0
BUG: 1243391
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/11449
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/bit-rot/src/stub/bit-rot-stub.h')
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.h | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h index c8442068e6b..9362c129303 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h @@ -385,32 +385,32 @@ br_stub_remove_vxattrs (dict_t *xattr) } } -#define BR_STUB_HANDLE_BAD_OBJECT(this, inode, op_ret, op_errno, label) \ - do { \ - if (br_stub_is_bad_object (this, inode)) { \ - gf_msg (this->name, GF_LOG_ERROR, 0, \ - BRS_MSG_BAD_OBJECT_ACCESS, \ - "%s is a bad object. Returning", \ - uuid_utoa (inode->gfid)); \ - op_ret = -1; \ - op_errno = EIO; \ - goto label; \ - } \ - } while (0) - -static inline gf_boolean_t +/** + * This function returns the below values for different situations + * 0 => as per the inode context object is not bad + * -1 => Failed to get the inode context itself + * -2 => As per the inode context object is bad + * Both -ve values means the fop which called this function is failed + * and error is returned upwards. + * In future if needed or more errors have to be handled, then those + * errors can be made into enums. + */ +static inline int br_stub_is_bad_object (xlator_t *this, inode_t *inode) { - gf_boolean_t bad_object = _gf_false; + int bad_object = 0; + gf_boolean_t tmp = _gf_false; uint64_t ctx_addr = 0; br_stub_inode_ctx_t *ctx = NULL; int32_t ret = -1; ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_SET_CONTEXT_FAILED, + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the inode context for the inode %s", uuid_utoa (inode->gfid)); + bad_object = -1; goto out; } @@ -418,7 +418,9 @@ br_stub_is_bad_object (xlator_t *this, inode_t *inode) LOCK (&inode->lock); { - bad_object = __br_stub_is_bad_object (ctx); + tmp = __br_stub_is_bad_object (ctx); + if (tmp) + bad_object = -2; } UNLOCK (&inode->lock); @@ -454,12 +456,16 @@ out: return ret; } +/** + * There is a possibility that dict_set might fail. The o/p of dict_set is + * given to the caller and the caller has to decide what to do. + */ static inline int32_t br_stub_mark_xdata_bad_object (xlator_t *this, inode_t *inode, dict_t *xdata) { int32_t ret = 0; - if (br_stub_is_bad_object (this, inode)) + if (br_stub_is_bad_object (this, inode) == -2) ret = dict_set_int32 (xdata, GLUSTERFS_BAD_INODE, 1); return ret; |