From b7842d178a6019bc2c14ecaf18ae5438a46bda29 Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Sat, 16 May 2015 21:23:48 +0530 Subject: features/shard: Fix incorrect parameter to get_lowest_block() Due to get_lowest_block() being a macro, what needs to be passed to it is the evaluation of the expression (local->offset - 1), without which its substitution can cause junk values to be assigned to local->first_block. This patch also fixes calls to get_highest_block() where if offset and size are both equal to zero, it could return negative values. Change-Id: I3ae918a0a3251ffd9ce8d2294bc5f9b681447627 BUG: 1200082 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/10804 Reviewed-by: Pranith Kumar Karampuri Tested-by: Gluster Build System Tested-by: NetBSD Build System --- xlators/features/shard/src/shard.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h index 6bdbcbb9b6e..a90162bf9be 100644 --- a/xlators/features/shard/src/shard.h +++ b/xlators/features/shard/src/shard.h @@ -23,8 +23,9 @@ #define SHARD_ROOT_GFID "be318638-e8a0-4c6d-977d-7a937aa84806" #define SHARD_INODE_LRU_LIMIT 4096 -#define get_lowest_block(off, shard_size) (off / shard_size) -#define get_highest_block(off, len, shard_size) ((off+len-1) / shard_size) +#define get_lowest_block(off, shard_size) ((off) / (shard_size)) +#define get_highest_block(off, len, shard_size) \ + (((((off)+(len)) == 0)?0:((off)+(len)-1)) / (shard_size)) #define SHARD_ENTRY_FOP_CHECK(loc, op_errno, label) do { \ if ((loc->name && !strcmp (GF_SHARD_DIR, loc->name)) && \ -- cgit