]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: add prepare_iov() method
authorSage Weil <sage@redhat.com>
Thu, 16 Apr 2015 00:01:59 +0000 (17:01 -0700)
committerSage Weil <sage@redhat.com>
Wed, 19 Aug 2015 21:03:55 +0000 (17:03 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/buffer.cc
src/include/buffer.h

index 06537f5eca1e011a9d52a08f9738981f2da6a86f..c96d6fac78aeca86d73bf386ff1b4945013807d1 100644 (file)
@@ -1825,6 +1825,18 @@ int buffer::list::write_fd(int fd) const
   return 0;
 }
 
+void buffer::list::prepare_iov(std::vector<iovec> *piov) const
+{
+  piov->resize(_buffers.size());
+  unsigned n = 0;
+  for (std::list<buffer::ptr>::const_iterator p = _buffers.begin();
+       p != _buffers.end();
+       ++p, ++n) {
+    (*piov)[n].iov_base = (void *)p->c_str();
+    (*piov)[n].iov_len = p->length();
+  }
+}
+
 int buffer::list::write_fd_zero_copy(int fd) const
 {
   if (!can_zero_copy())
index 62a50d2d2a5666f234cb710080a8abed3b49c5c3..845bf338708dab78841dd50a416488db8e2a504a 100644 (file)
@@ -23,6 +23,7 @@
 #endif
 
 #include <stdio.h>
+#include <sys/uio.h>
 
 #if defined(__linux__) // For malloc(2).
 #include <malloc.h>
@@ -39,6 +40,7 @@
 #include <iosfwd>
 #include <iomanip>
 #include <list>
+#include <vector>
 #include <string>
 #include <exception>
 
@@ -490,6 +492,7 @@ public:
     int write_file(const char *fn, int mode=0644);
     int write_fd(int fd) const;
     int write_fd_zero_copy(int fd) const;
+    void prepare_iov(std::vector<iovec> *piov) const;
     uint32_t crc32c(uint32_t crc) const;
        void invalidate_crc();
   };