From ebc8237d8c445af208446c937f31aa311d1efb2c Mon Sep 17 00:00:00 2001 From: SonaArora Date: Wed, 26 Jul 2017 17:43:45 +0530 Subject: read-only : currently read-only doesn't implement fallocate PROBLEM STATEMENT: read-only should block fallocate call if its enabled, else pass to next xlator. Implemented this functionality in read-only. BUG: 1475300 Change-Id: I57c51eb4f1519ba75d7291eba49554e6ed4a25eb Signed-off-by: SonaArora Reviewed-on: https://review.gluster.org/17879 Smoke: Gluster Build System Tested-by: Karthik U S CentOS-regression: Gluster Build System Reviewed-by: Karthik U S Reviewed-by: Ashish Pandey Reviewed-by: Kotresh HR Reviewed-by: Amar Tumballi --- xlators/features/read-only/src/read-only-common.c | 15 +++++++++++++++ xlators/features/read-only/src/read-only-common.h | 4 ++++ xlators/features/read-only/src/read-only.c | 1 + 3 files changed, 20 insertions(+) (limited to 'xlators') diff --git a/xlators/features/read-only/src/read-only-common.c b/xlators/features/read-only/src/read-only-common.c index b4e4289356b..f4851a4be40 100644 --- a/xlators/features/read-only/src/read-only-common.c +++ b/xlators/features/read-only/src/read-only-common.c @@ -196,6 +196,21 @@ ro_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, dict_ return 0; } +int32_t +ro_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata) +{ + if (is_readonly_or_worm_enabled (frame, this)) + STACK_UNWIND_STRICT (fallocate, frame, -1, EROFS, NULL, NULL, + xdata); + else + STACK_WIND_TAIL (frame, FIRST_CHILD (this), + FIRST_CHILD(this)->fops->fallocate, fd, mode, + offset, len, xdata); + return 0; +} + + int ro_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, dev_t rdev, mode_t umask, dict_t *xdata) diff --git a/xlators/features/read-only/src/read-only-common.h b/xlators/features/read-only/src/read-only-common.h index 6d8c38faeb8..ec629bd5660 100644 --- a/xlators/features/read-only/src/read-only-common.h +++ b/xlators/features/read-only/src/read-only-common.h @@ -111,3 +111,7 @@ ro_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, int32_t ro_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, dict_t *xdata); + +int32_t +ro_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata); diff --git a/xlators/features/read-only/src/read-only.c b/xlators/features/read-only/src/read-only.c index 8733a40abce..75d6d104d45 100644 --- a/xlators/features/read-only/src/read-only.c +++ b/xlators/features/read-only/src/read-only.c @@ -115,6 +115,7 @@ struct xlator_fops fops = { .entrylk = ro_entrylk, .fentrylk = ro_fentrylk, .lk = ro_lk, + .fallocate = ro_fallocate, }; struct xlator_cbks cbks = { -- cgit