]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common/buffer: adjust align before calling posix_memalign()
authorIlya Dryomov <idryomov@gmail.com>
Tue, 4 May 2021 13:50:05 +0000 (15:50 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 9 May 2021 10:10:55 +0000 (12:10 +0200)
commit459b4d71333cb357a87db18222e916eb344c3693
tree75d222748e1c9d996cbf8954b576308f95e6a05b
parenta3ea99688fef1ae7c339a32fa44b59f3191230b2
common/buffer: adjust align before calling posix_memalign()

posix_memalign() requires alignment argument to be a multiple of
sizeof(void *).  Since it is an implementation detail of buffer,
it needs to be adjusted there -- buffer consumers have no way of
knowing that passing e.g. align == 4 is incorrect.

One place already does the adjustment, but only for align == 0.
The other just asserts.  Fix both and remove the "power of two"
assertion.  Let posix_memalign() return EINVAL and handle that
by throwing buffer::bad_alloc, as expected by the consumers.

Fixes: https://tracker.ceph.com/issues/50646
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit aa31ddf0e70b3b8ef8012e09cb3158f3db4dea1b)
src/common/buffer.cc