From bf69fa4727f2b4432d7d54312bc0177cbcf44936 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 16 Apr 2019 14:19:47 +0530 Subject: cluster/ec: fix fd reopen Currently EC tries to reopen fd's that have been opened while a brick was down. This is done as part of regular write operations, just after having acquired the locks, and it's sent as a sub-fop of the main write fop. There were two problems: 1. The reopen was attempted on all UP bricks, even if a previous lock didn't succeed. This is incorrect because most probably the open will fail. 2. If reopen is sent and fails, the error is propagated to the main operation, causing it to fail when it shouldn't. To fix this, we only attempt reopens on bricks where the current fop owns a lock, and we prevent any error to be propagated to the main fop. To implement this behaviour an argument used to indicate the minimum number of required answers has overloaded to also include some flags. To make the change consistent, it has been necessary to rename the argument, which means that a lot of files have been changed. However there are no functional changes. This change has also uncovered a problem in discard code, which didn't correctely process requests of small sizes because no real discard fop was being processed, only a write of 0's on some region. In this case some fields of the fop remained uninitialized or with incorrect values. To fix this, a new function has been created to simulate success on a fop and it's used in the discard case. Thanks to Pranith for providing a test script that has also detected an issue in this patch. This patch includes a small modification of this script to force data to be written into bricks before stopping them. Backport of: > Change-Id: If272343873369186c2fb8f43c1d9c52c3ea304ec > BUG: bz#1699866 > Signed-off-by: Xavi Hernandez Change-Id: If272343873369186c2fb8f43c1d9c52c3ea304ec Fixes: bz#1699917 Signed-off-by: Xavi Hernandez --- xlators/cluster/ec/src/ec-locks.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'xlators/cluster/ec/src/ec-locks.c') diff --git a/xlators/cluster/ec/src/ec-locks.c b/xlators/cluster/ec/src/ec-locks.c index f978af0ac67..ffcac074c4d 100644 --- a/xlators/cluster/ec/src/ec-locks.c +++ b/xlators/cluster/ec/src/ec-locks.c @@ -275,7 +275,7 @@ ec_manager_entrylk(ec_fop_data_t *fop, int32_t state) void ec_entrylk(call_frame_t *frame, xlator_t *this, uintptr_t target, - int32_t minimum, fop_entrylk_cbk_t func, void *data, + uint32_t fop_flags, fop_entrylk_cbk_t func, void *data, const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) { @@ -288,9 +288,9 @@ ec_entrylk(call_frame_t *frame, xlator_t *this, uintptr_t target, GF_VALIDATE_OR_GOTO(this->name, frame, out); GF_VALIDATE_OR_GOTO(this->name, this->private, out); - fop = ec_fop_data_allocate(frame, this, GF_FOP_ENTRYLK, 0, target, minimum, - ec_wind_entrylk, ec_manager_entrylk, callback, - data); + fop = ec_fop_data_allocate(frame, this, GF_FOP_ENTRYLK, 0, target, + fop_flags, ec_wind_entrylk, ec_manager_entrylk, + callback, data); if (fop == NULL) { goto out; } @@ -403,7 +403,7 @@ ec_wind_fentrylk(ec_t *ec, ec_fop_data_t *fop, int32_t idx) void ec_fentrylk(call_frame_t *frame, xlator_t *this, uintptr_t target, - int32_t minimum, fop_fentrylk_cbk_t func, void *data, + uint32_t fop_flags, fop_fentrylk_cbk_t func, void *data, const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) { @@ -416,9 +416,9 @@ ec_fentrylk(call_frame_t *frame, xlator_t *this, uintptr_t target, GF_VALIDATE_OR_GOTO(this->name, frame, out); GF_VALIDATE_OR_GOTO(this->name, this->private, out); - fop = ec_fop_data_allocate(frame, this, GF_FOP_FENTRYLK, 0, target, minimum, - ec_wind_fentrylk, ec_manager_entrylk, callback, - data); + fop = ec_fop_data_allocate(frame, this, GF_FOP_FENTRYLK, 0, target, + fop_flags, ec_wind_fentrylk, ec_manager_entrylk, + callback, data); if (fop == NULL) { goto out; } @@ -650,7 +650,7 @@ ec_manager_inodelk(ec_fop_data_t *fop, int32_t state) void ec_inodelk(call_frame_t *frame, xlator_t *this, gf_lkowner_t *owner, - uintptr_t target, int32_t minimum, fop_inodelk_cbk_t func, + uintptr_t target, uint32_t fop_flags, fop_inodelk_cbk_t func, void *data, const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *flock, dict_t *xdata) { @@ -664,9 +664,9 @@ ec_inodelk(call_frame_t *frame, xlator_t *this, gf_lkowner_t *owner, GF_VALIDATE_OR_GOTO(this->name, frame, out); GF_VALIDATE_OR_GOTO(this->name, this->private, out); - fop = ec_fop_data_allocate(frame, this, GF_FOP_INODELK, 0, target, minimum, - ec_wind_inodelk, ec_manager_inodelk, callback, - data); + fop = ec_fop_data_allocate(frame, this, GF_FOP_INODELK, 0, target, + fop_flags, ec_wind_inodelk, ec_manager_inodelk, + callback, data); if (fop == NULL) { goto out; } @@ -782,7 +782,7 @@ ec_wind_finodelk(ec_t *ec, ec_fop_data_t *fop, int32_t idx) void ec_finodelk(call_frame_t *frame, xlator_t *this, gf_lkowner_t *owner, - uintptr_t target, int32_t minimum, fop_finodelk_cbk_t func, + uintptr_t target, uint32_t fop_flags, fop_finodelk_cbk_t func, void *data, const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata) { @@ -796,9 +796,9 @@ ec_finodelk(call_frame_t *frame, xlator_t *this, gf_lkowner_t *owner, GF_VALIDATE_OR_GOTO(this->name, frame, out); GF_VALIDATE_OR_GOTO(this->name, this->private, out); - fop = ec_fop_data_allocate(frame, this, GF_FOP_FINODELK, 0, target, minimum, - ec_wind_finodelk, ec_manager_inodelk, callback, - data); + fop = ec_fop_data_allocate(frame, this, GF_FOP_FINODELK, 0, target, + fop_flags, ec_wind_finodelk, ec_manager_inodelk, + callback, data); if (fop == NULL) { goto out; } @@ -1032,7 +1032,7 @@ ec_manager_lk(ec_fop_data_t *fop, int32_t state) } void -ec_lk(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, +ec_lk(call_frame_t *frame, xlator_t *this, uintptr_t target, uint32_t fop_flags, fop_lk_cbk_t func, void *data, fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata) { @@ -1045,7 +1045,7 @@ ec_lk(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, GF_VALIDATE_OR_GOTO(this->name, frame, out); GF_VALIDATE_OR_GOTO(this->name, this->private, out); - fop = ec_fop_data_allocate(frame, this, GF_FOP_LK, 0, target, minimum, + fop = ec_fop_data_allocate(frame, this, GF_FOP_LK, 0, target, fop_flags, ec_wind_lk, ec_manager_lk, callback, data); if (fop == NULL) { goto out; -- cgit