]> 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>
Tue, 2 Dec 2014 20:15:26 +0000 (21:15 +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>
src/include/buffer.h

index 2e19a90e59f24eaeb96fcead2dff81733b1e2bb4..45e0f1dba95b97d52867dc3c68a143b4bfbd75e8 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); }