From b0b4b6de362f0edfa51a1bf500a37020ace795ee Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Thu, 3 Mar 2016 18:49:28 +0800 Subject: [PATCH] os/bluestore/BlueStore: Fix bug when calc offset & end whether locate in the a extent. Suppose: bluestore_overlay_max_length == bluestore_min_alloc_size The orignal code which calc content of written whether locate in a extent: (offset / min_alloc_size) == (offset + length) /min_alloc_size This will make the case which offset=0 & length =min_alloc_size locate in the different extent. In fact, this content is in the same extent. Change end = offset + length - 1 make work. Fixes: #14954 Signed-off-by: Jianpeng Ma --- src/os/bluestore/BlueStore.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 96a10f423bdfd..aa37a46a53632 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5059,7 +5059,7 @@ int BlueStore::_do_allocate( bool shared_head = false; bool shared_tail = false; uint64_t orig_end = orig_offset + orig_length; - if (orig_offset / min_alloc_size == orig_end / min_alloc_size) { + if (orig_offset / min_alloc_size == (orig_end - 1)/ min_alloc_size) { // we fall within the same block offset = orig_offset - orig_offset % min_alloc_size; length = 0; -- 2.39.5