From 5205d4dacf7ebe2e42d2294bc30cb27f226c8d22 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 2 Dec 2014 02:04:14 +0100 Subject: [PATCH] common: allow size alignment that is not a power of two Do not assume the alignment is a power of two in the is_n_align_sized() predicate. When used in the context of erasure code it is common for chunks to not be powers of two. Signed-off-by: Loic Dachary (cherry picked from commit 73ad2d63d479b09037d50246106bbd4075fbce80) --- src/include/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/buffer.h b/src/include/buffer.h index 3cd0a7a19a07..0ce133a29641 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -184,7 +184,7 @@ public: bool is_page_aligned() const { return is_aligned(CEPH_PAGE_SIZE); } bool is_n_align_sized(unsigned align) const { - return (length() & (align-1)) == 0; + return (length() % align) == 0; } bool is_n_page_sized() const { return is_n_align_sized(CEPH_PAGE_SIZE); } -- 2.47.3