Skip to content

Commit dde2b07

Browse files
author
Matt Benjamin
committed
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::clone_nonsharable(currently buffer.cc:690). Signed-off-by: Matt Benjamin <matt@cohortfs.com>
1 parent bf0b888 commit dde2b07

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/msg/Message.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,33 +314,33 @@ class Message : public RefCountedObject {
314314
void set_payload(bufferlist& bl) {
315315
if (byte_throttler)
316316
byte_throttler->put(payload.length());
317-
payload.claim(bl);
317+
payload.claim(bl, false /* !clone_nonsharable */);
318318
if (byte_throttler)
319319
byte_throttler->take(payload.length());
320320
}
321321

322322
void set_middle(bufferlist& bl) {
323323
if (byte_throttler)
324324
byte_throttler->put(payload.length());
325-
middle.claim(bl);
325+
middle.claim(bl, false /* !clone_nonsharable */);
326326
if (byte_throttler)
327327
byte_throttler->take(payload.length());
328328
}
329329
bufferlist& get_middle() { return middle; }
330330

331-
void set_data(const bufferlist &d) {
331+
void set_data(bufferlist &bl) {
332332
if (byte_throttler)
333333
byte_throttler->put(data.length());
334-
data = d;
334+
data.claim(bl, false /* !clone_nonsharable */);
335335
if (byte_throttler)
336336
byte_throttler->take(data.length());
337337
}
338338

339339
bufferlist& get_data() { return data; }
340-
void claim_data(bufferlist& bl, bool strong=true) {
340+
void claim_data(bufferlist& bl, bool clone_nonsharable=true) {
341341
if (byte_throttler)
342342
byte_throttler->put(data.length());
343-
bl.claim(data, strong);
343+
bl.claim(data, clone_nonsharable);
344344
}
345345
off_t get_data_len() { return data.length(); }
346346

src/os/FileJournal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ int FileJournal::prepare_single_write(bufferlist& bl, off64_t& queue_pos, uint64
913913
bufferptr bp = buffer::create_static(pre_pad, zero_buf);
914914
bl.push_back(bp);
915915
}
916-
bl.claim_append(ebl);
916+
bl.claim_append(ebl, false /* !clone_nonsharable */); // potential zero-copy
917917

918918
if (h.post_pad) {
919919
bufferptr bp = buffer::create_static(post_pad, zero_buf);

src/os/FileJournal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class FileJournal : public Journal {
5454
TrackedOpRef tracked_op;
5555
write_item(uint64_t s, bufferlist& b, int al, TrackedOpRef opref) :
5656
seq(s), alignment(al), tracked_op(opref) {
57-
bl.claim(b);
57+
bl.claim(b, false /* !clone_nonsharable */); // potential zero-copy
5858
}
5959
write_item() : seq(0), alignment(0) {}
6060
};

0 commit comments

Comments
 (0)