mdbx: clarify/refine mdbx_flush_iov().

Change-Id: Ib9462efdbf97e42b1e80bf130f8150072102d9ed
This commit is contained in:
Leonid Yuriev 2020-10-18 02:34:55 +03:00
parent f73a8a8680
commit 7001d971e1

View File

@ -7869,14 +7869,14 @@ static int mdbx_flush_iov(MDBX_txn *const txn, struct iovec *iov,
size_t iov_bytes) { size_t iov_bytes) {
MDBX_env *const env = txn->mt_env; MDBX_env *const env = txn->mt_env;
mdbx_assert(env, iov_items > 0); mdbx_assert(env, iov_items > 0);
int rc;
if (likely(iov_items == 1)) { if (likely(iov_items == 1)) {
mdbx_assert(env, iov->iov_len == iov_bytes); mdbx_assert(env, iov->iov_len == iov_bytes);
int rc = mdbx_pwrite(env->me_lazy_fd, iov->iov_base, iov_bytes, iov_off); rc = mdbx_pwrite(env->me_lazy_fd, iov->iov_base, iov_bytes, iov_off);
mdbx_dpage_free(env, (MDBX_page *)iov->iov_base,
bytes2pgno(env, iov_bytes));
return rc;
} else { } else {
int rc = mdbx_pwritev(env->me_lazy_fd, iov, iov_items, iov_off, iov_bytes); rc = mdbx_pwritev(env->me_lazy_fd, iov, iov_items, iov_off, iov_bytes);
}
if (unlikely(rc != MDBX_SUCCESS)) { if (unlikely(rc != MDBX_SUCCESS)) {
mdbx_error("Write error: %s", mdbx_strerror(rc)); mdbx_error("Write error: %s", mdbx_strerror(rc));
txn->mt_flags |= MDBX_TXN_ERROR; txn->mt_flags |= MDBX_TXN_ERROR;
@ -7886,7 +7886,6 @@ static int mdbx_flush_iov(MDBX_txn *const txn, struct iovec *iov,
mdbx_dpage_free(env, (MDBX_page *)iov[i].iov_base, mdbx_dpage_free(env, (MDBX_page *)iov[i].iov_base,
bytes2pgno(env, iov[i].iov_len)); bytes2pgno(env, iov[i].iov_len));
return rc; return rc;
}
} }
/* Flush (some) dirty pages to the map, after clearing their dirty flag. /* Flush (some) dirty pages to the map, after clearing their dirty flag.