MCPcopy Create free account
hub / github.com/ceph/ceph / do_writev

Function do_writev

src/common/buffer.cc:1878–1915  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1876}
1877
1878static int do_writev(int fd, struct iovec *vec, uint64_t offset, unsigned veclen, unsigned bytes)
1879{
1880 while (bytes > 0) {
1881 ssize_t r = 0;
1882#ifdef HAVE_PWRITEV
1883 r = ::pwritev(fd, vec, veclen, offset);
1884#else
1885 r = ::lseek64(fd, offset, SEEK_SET);
1886 if (r != offset) {
1887 return -errno;
1888 }
1889 r = ::writev(fd, vec, veclen);
1890#endif
1891 if (r < 0) {
1892 if (errno == EINTR)
1893 continue;
1894 return -errno;
1895 }
1896
1897 bytes -= r;
1898 offset += r;
1899 if (bytes == 0) break;
1900
1901 while (r > 0) {
1902 if (vec[0].iov_len <= (size_t)r) {
1903 // drain this whole item
1904 r -= vec[0].iov_len;
1905 ++vec;
1906 --veclen;
1907 } else {
1908 vec[0].iov_base = (char *)vec[0].iov_base + r;
1909 vec[0].iov_len -= r;
1910 break;
1911 }
1912 }
1913 }
1914 return 0;
1915}
1916
1917#ifndef _WIN32
1918int buffer::list::write_fd(int fd) const

Callers 1

write_fdMethod · 0.70

Calls 1

writevFunction · 0.85

Tested by

no test coverage detected