summaryrefslogtreecommitdiffstats
path: root/xlators/features/shard
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2015-05-16 21:23:48 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-06-03 18:59:35 -0700
commitebeab96411947ca73c946422aef8af9bcd88ff05 (patch)
treed366a17411c585051febc7a7a38ed784342e863f /xlators/features/shard
parent140b4fdefa21c00af3e6015fed86c632683ab01f (diff)
features/shard: Fix incorrect parameter to get_lowest_block()
Backport of: http://review.gluster.org/10804 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: I8f1bc54b536587d6af3a5c193434d06dccbf76dc BUG: 1227572 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/11051 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/features/shard')
-rw-r--r--xlators/features/shard/src/shard.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h
index 52228149ff9..59514b3d3df 100644
--- a/xlators/features/shard/src/shard.h
+++ b/xlators/features/shard/src/shard.h
@@ -28,8 +28,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)) && \