]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common: rebuild_page_aligned sometimes rebuilds unaligned 773/head
authorLoic Dachary <loic@dachary.org>
Sat, 26 Oct 2013 00:11:43 +0000 (02:11 +0200)
committerLoic Dachary <loic@dachary.org>
Sat, 26 Oct 2013 00:42:31 +0000 (02:42 +0200)
commit66a9fbe2c7ba59b7cd034c17865adce3432cd2cb
treeaa7d947321fe143e35e609f3f6d8a06057f7ca52
parent289b7903407ce1b34f1afe9e0c769093c14d0ba9
common: rebuild_page_aligned sometimes rebuilds unaligned

rebuild_page_aligned relies on rebuild to create memory that is aligned
according to list::is_page_aligned(). However, when the bufferlist only
contains a single ptr and that its size is not list::is_n_page_size(),
rebuild will not create the expected alligned bufferlist.

The allocation of the ptr is moved out of rebuild which is now given the
ptr as an argument. The rebuild_page_aligned function always require an
aligned ptr with buffer::create_page_aligned(_len) for consistency.

The test

    bufferlist bl;
    bufferptr ptr(buffer::create_page_aligned(2));
    ptr.set_offset(1);
    ptr.set_length(1);
    bl.append(ptr);
    EXPECT_FALSE(bl.is_page_aligned());
    bl.rebuild_page_aligned();
    EXPECT_FALSE(bl.is_page_aligned());

demonstrated the problem. It was assumed to be a feature but should have
been identified as a bug. The last ligne is replaced with

    EXPECT_TRUE(bl.is_page_aligned());

Most tests related to is_page_aligned() wrongfully assumed that

    bufferptr ptr(2);

is never page aligned. Most of the time it is not but sometime it is
when the pointer address is by chance on a CEPH_PAGE_SIZE boundary,
which triggered #6614. Non aligned ptr are created as follows instead:

    bufferptr ptr(buffer::create_page_aligned(2));
    ptr.set_offset(1);
    ptr.set_length(1);

http://tracker.ceph.com/issues/6614 fixes: #6614

Signed-off-by: Loic Dachary <loic@dachary.org>
src/common/buffer.cc
src/include/buffer.h
src/test/bufferlist.cc