Include common/likely.h in buffer.h

Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Add safe-sharing to buffer::list and buffer::ptr.

Formerly known as "strong claim," this change introduces a new
is_shareable() property to ceph::buffer::raw objects, which can be
used to prevent unplanned sharing of buffers.

The default value of is_shareable() is true, but derived classes may
override this.  For example, Accelio message buffers may point to
registered or pool-allocated memory which should not be held for
long periods.

Cloning of non-shareable buffers is now the unmarked case, so is
performed automatically in the buffer::list copy constructor.
Low-level operations should allow explicit volatile sharing,
so copying a buffer::list:iterator or a buffer::ptr works as normal.

For explicit sharing of "non-shareable" buffers, a new boolean is added to
the public claim_* methods, and a buffer::list::share method is also
added, to share an entire sequence.

Signed-off-by: Vu Pham <vu@mellanox.com>
Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Restore zero-copy buffers in OSD fast path.

This change restores volatile sharing semantics in the Message
decode path, and also in the OSD write path for FileStore/FileJournal.

This can be verified with a breakpoint set at the clone/COW case in
buffer::ptr::make_shareable(currently buffer.cc:690).

Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Add diagnostic unshareable buffer.

Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Add unittests for safe sharing and make_shareable()

Checks the following assertions:

1. a bufferlist shared with buffer::list::share yields shared
raw memory

2. a bufferlist copied with buffer::list::list(const list&) yields
shared raw memory

3. an unshareable bufferlist (bufferlist with unshareable segments)
copied with buffer::list::list(const list&) yields unshared raw
memory

4. an unshareable bufferlist claimed with CLAIM_ALLOW_NONSHAREABLE
yields shared raw memory

Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Merge pull request #3123 from linuxbox2/wip-claim-3

Wip claim 3

Reviewed-by: Sage Weil <sage@redhat.com>
Reviewed-by: Samuel Just <sjust@redhat.com>