0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-08 21:18:57 +02:00

ircd::fs: Support pwritev2(2).

This commit is contained in:
Jason Volk 2019-03-13 18:42:16 -07:00
parent 034c2d9030
commit 02435c3672
2 changed files with 28 additions and 7 deletions

View file

@ -710,6 +710,7 @@ AC_CHECK_FUNCS([ \
snprintf \
vsnprintf \
posix_fadvise \
pwritev2 \
])
AC_SEARCH_LIBS(dlinfo, dl, AC_DEFINE(HAVE_DLINFO, 1, [Define if you have dlinfo]))

View file

@ -601,6 +601,7 @@ ircd::fs::read(const fd &fd,
namespace ircd::fs
{
static size_t _write(const fd &, const const_iovec_view &, const write_opts &);
static size_t write(const fd &, const const_iovec_view &, const write_opts &);
}
@ -834,7 +835,7 @@ ircd::fs::write(const fd &fd,
}
#pragma GCC diagnostic pop
/// Lowest-level write() call. This call only conducts a single operation
/// Lowest-level'ish write() call. This call only conducts a single operation
/// (no looping) and can return early with a partial write(). It does have
/// branches for various write_opts. The arguments involve `struct ::iovec`
/// which we do not expose to the ircd.h API; thus this function is internal to
@ -850,15 +851,34 @@ ircd::fs::write(const fd &fd,
return aio::write(fd, iov, opts);
#endif
const auto ret
{
return _write(fd, iov, opts);
}
#ifdef HAVE_PWRITEV2
size_t
ircd::fs::_write(const fd &fd,
const const_iovec_view &iov,
const write_opts &opts)
{
int flags{0};
return
opts.interruptible?
syscall(::pwritev2, fd, iov.data(), iov.size(), opts.offset, flags):
syscall_nointr(::pwritev2, fd, iov.data(), iov.size(), opts.offset, flags);
}
#else
size_t
ircd::fs::_write(const fd &fd,
const const_iovec_view &iov,
const write_opts &opts)
{
return
opts.interruptible?
syscall(::pwritev, fd, iov.data(), iov.size(), opts.offset):
syscall_nointr(::pwritev, fd, iov.data(), iov.size(), opts.offset)
};
return size_t(ret);
syscall_nointr(::pwritev, fd, iov.data(), iov.size(), opts.offset);
}
#endif
///////////////////////////////////////////////////////////////////////////////
//