From: Loic Dachary Date: Tue, 2 Dec 2014 01:04:14 +0000 (+0100) Subject: common: allow size alignment that is not a power of two X-Git-Tag: v0.87.1~15^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5205d4dacf7ebe2e42d2294bc30cb27f226c8d22;p=ceph.git 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) --- 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); }