diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2015-05-16 21:23:48 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-06-02 20:46:56 -0700 |
commit | b7842d178a6019bc2c14ecaf18ae5438a46bda29 (patch) | |
tree | cd683af394db0400325d810d1631f5c3e6e30a00 /xlators | |
parent | e1d9895ba6f7763ba4602094f6516a6ab4a054d4 (diff) |
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 <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/10804
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/shard/src/shard.h | 5 |
1 files changed, 3 insertions, 2 deletions
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)) && \ |