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.91~166^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=73ad2d63d479b09037d50246106bbd4075fbce80;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 --- diff --git a/src/include/buffer.h b/src/include/buffer.h index 2e19a90e59f2..45e0f1dba95b 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); }