From c00722ff9d83d131e624f5499da05160d184cfba Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Thu, 25 Feb 2016 18:27:09 +0530 Subject: features/shard: Return ENOTSUP for unsupported fallocate flags Basis: http://lists.gnu.org/archive/html/qemu-devel/2016-02/msg05101.html Change-Id: I5bf80b6e8caed3d7f136fc57e16abfb28869e009 BUG: 1261841 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/13523 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Ravishankar N Reviewed-by: Vijay Bellur --- libglusterfs/src/compat.h | 5 ++++- xlators/features/shard/src/shard.c | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libglusterfs/src/compat.h b/libglusterfs/src/compat.h index 183002e588e..04779bff4dc 100644 --- a/libglusterfs/src/compat.h +++ b/libglusterfs/src/compat.h @@ -57,7 +57,9 @@ #ifndef FALLOC_FL_PUNCH_HOLE #define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ #endif - +#ifndef FALLOC_FL_ZERO_RANGE +#define FALLOC_FL_ZERO_RANGE 0x10 /* zeroes out range */ +#endif #ifndef HAVE_LLISTXATTR @@ -171,6 +173,7 @@ enum { #define F_SETLKW64 F_SETLKW #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ #define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ +#define FALLOC_FL_ZERO_RANGE 0x10 /* zeroes out range */ #ifndef _PATH_UMOUNT #define _PATH_UMOUNT "/sbin/umount" diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 6cf47c53c5b..8e4443535e9 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -4590,9 +4590,17 @@ int shard_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t keep_size, off_t offset, size_t len, dict_t *xdata) { + if ((keep_size != 0) && (keep_size != FALLOC_FL_ZERO_RANGE) && + (keep_size != (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))) + goto out; + shard_common_inode_write_begin (frame, this, GF_FOP_FALLOCATE, fd, NULL, 0, offset, keep_size, len, NULL, xdata); return 0; + +out: + SHARD_STACK_UNWIND (fallocate, frame, -1, ENOTSUP, NULL, NULL, NULL); + return 0; } int -- cgit