diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2015-05-09 23:11:15 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-06-05 09:23:38 -0700 |
commit | d38939e388c819f6c2ba6a6891edc27b6ecf3731 (patch) | |
tree | a19413e20404dfaf2010792cd3451080dec99776 /xlators | |
parent | e2fc345edcf393969c4ff2c6a5b0bead2bf51d5d (diff) |
worm: Let lock, zero xattrop calls succeed
Backport of http://review.gluster.org/10727
Locks can be taken just to inspect the data as well, so allow them.
Xattrops are internal fops so we can allow them as well as longs as
it doesn't change the xattr value, i.e. All-zero xattrop.
BUG: 1225320
Change-Id: I9e72806e0605ab2938348a87935966909f1a721f
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/11046
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/read-only/src/read-only-common.c | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/xlators/features/read-only/src/read-only-common.c b/xlators/features/read-only/src/read-only-common.c index 39937d106c5..24e99036b3c 100644 --- a/xlators/features/read-only/src/read-only-common.c +++ b/xlators/features/read-only/src/read-only-common.c @@ -30,11 +30,29 @@ is_readonly_or_worm_enabled (xlator_t *this) return readonly_or_worm_enabled; } +static int +_check_key_is_zero_filled (dict_t *d, char *k, data_t *v, + void *tmp) +{ + if (mem_0filled ((const char *)v->data, v->len)) { + /* -1 means, no more iterations, treat as 'break' */ + return -1; + } + return 0; +} + int32_t ro_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { - if (is_readonly_or_worm_enabled (this)) + gf_boolean_t allzero = _gf_false; + int ret = 0; + + ret = dict_foreach (dict, _check_key_is_zero_filled, NULL); + if (ret == 0) + allzero = _gf_true; + + if (is_readonly_or_worm_enabled (this) && !allzero) STACK_UNWIND_STRICT (xattrop, frame, -1, EROFS, NULL, xdata); else STACK_WIND_TAIL (frame, FIRST_CHILD (this), @@ -47,7 +65,14 @@ int32_t ro_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { - if (is_readonly_or_worm_enabled (this)) + gf_boolean_t allzero = _gf_false; + int ret = 0; + + ret = dict_foreach (dict, _check_key_is_zero_filled, NULL); + if (ret == 0) + allzero = _gf_true; + + if (is_readonly_or_worm_enabled (this) && !allzero) STACK_UNWIND_STRICT (fxattrop, frame, -1, EROFS, NULL, xdata); else STACK_WIND_TAIL (frame, FIRST_CHILD (this), @@ -62,12 +87,9 @@ ro_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) { - if (is_readonly_or_worm_enabled (this)) - STACK_UNWIND_STRICT (entrylk, frame, -1, EROFS, xdata); - else - STACK_WIND_TAIL (frame, FIRST_CHILD (this), - FIRST_CHILD(this)->fops->entrylk, - volume, loc, basename, cmd, type, xdata); + STACK_WIND_TAIL (frame, FIRST_CHILD (this), + FIRST_CHILD(this)->fops->entrylk, + volume, loc, basename, cmd, type, xdata); return 0; } @@ -77,12 +99,9 @@ ro_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) { - if (is_readonly_or_worm_enabled (this)) - STACK_UNWIND_STRICT (fentrylk, frame, -1, EROFS, xdata); - else - STACK_WIND_TAIL (frame, FIRST_CHILD (this), - FIRST_CHILD(this)->fops->fentrylk, - volume, fd, basename, cmd, type, xdata); + STACK_WIND_TAIL (frame, FIRST_CHILD (this), + FIRST_CHILD(this)->fops->fentrylk, + volume, fd, basename, cmd, type, xdata); return 0; } @@ -91,12 +110,9 @@ int32_t ro_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { - if (is_readonly_or_worm_enabled (this)) - STACK_UNWIND_STRICT (inodelk, frame, -1, EROFS, xdata); - else - STACK_WIND_TAIL (frame, FIRST_CHILD (this), - FIRST_CHILD(this)->fops->inodelk, - volume, loc, cmd, lock, xdata); + STACK_WIND_TAIL (frame, FIRST_CHILD (this), + FIRST_CHILD(this)->fops->inodelk, + volume, loc, cmd, lock, xdata); return 0; } @@ -105,12 +121,9 @@ int32_t ro_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { - if (is_readonly_or_worm_enabled (this)) - STACK_UNWIND_STRICT (finodelk, frame, -1, EROFS, xdata); - else - STACK_WIND_TAIL (frame, FIRST_CHILD (this), - FIRST_CHILD(this)->fops->finodelk, - volume, fd, cmd, lock, xdata); + STACK_WIND_TAIL (frame, FIRST_CHILD (this), + FIRST_CHILD(this)->fops->finodelk, + volume, fd, cmd, lock, xdata); return 0; } @@ -119,12 +132,9 @@ int32_t ro_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int cmd, struct gf_flock *flock, dict_t *xdata) { - if (is_readonly_or_worm_enabled (this)) - STACK_UNWIND_STRICT (lk, frame, -1, EROFS, NULL, xdata); - else - STACK_WIND_TAIL (frame, FIRST_CHILD (this), - FIRST_CHILD(this)->fops->lk, fd, cmd, flock, - xdata); + STACK_WIND_TAIL (frame, FIRST_CHILD (this), + FIRST_CHILD(this)->fops->lk, fd, cmd, flock, + xdata); return 0; } |