From 73ad2d63d479b09037d50246106bbd4075fbce80 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 --- 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 2e19a90e59f24..45e0f1dba95b9 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.39.5