On Mon, Aug 27, 2012 at 1:01 PM, Sage Weil <sage@xxxxxxxxxxx> wrote: > On Mon, 27 Aug 2012, Noah Watkins wrote: >> I have a bufferlist use case that I can't quite resolve. I'm packing >> up a struct and a blob, but not sure how to seek to the beginning of >> the blob correctly during decode: >> >> 1. Setup bufferlist >> >> /* add header */ >> struct header hdr; >> ::encode(hdr, bl); >> >> /* add payload blob */ >> bl.append(buf, len); > > Instead, do > > bufferlist b; > b.append(buf, len); > ::encode(b, bl); > > that'll include a length in front of it... > > >> 2. Later in decode ... >> >> /* get header */ >> bufferlist::iterator it = in.begin(); >> ::decode(hdr, it); >> >> **problem: Want to get a bufferlist for the payload, which is >> presumably exactly where the iterator now points. How should that >> transformation happen with zero-copy? > > and then > > bufferlist b; > ::decode(b, it); > > will get it back. Does that maintain zero-copy semantics? (It could; I just wasn't aware that we'd special-cased bufferlist decodes enough to do so.) -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html