]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: allow size alignment that is not a power of two
authorLoic Dachary <ldachary@redhat.com>
Tue, 2 Dec 2014 01:04:14 +0000 (02:04 +0100)
committerLoic Dachary <ldachary@redhat.com>
Thu, 4 Dec 2014 18:05:21 +0000 (19:05 +0100)
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 <loic@dachary.org>
(cherry picked from commit 73ad2d63d479b09037d50246106bbd4075fbce80)

src/include/buffer.h

index 3cd0a7a19a0727447bd6f9d7bf3de16a86a31674..0ce133a29641637eaff13018f0c280cde7e5d0f4 100644 (file)
@@ -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); }