|
|
@ -995,6 +995,9 @@ typedef struct MDB_ntxn { |
|
|
|
#define MDB_COMMIT_PAGES IOV_MAX |
|
|
|
#define MDB_COMMIT_PAGES IOV_MAX |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* max bytes to write in one call */ |
|
|
|
|
|
|
|
#define MAX_WRITE (0x80000000U >> (sizeof(ssize_t) == 4)) |
|
|
|
|
|
|
|
|
|
|
|
static int mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp); |
|
|
|
static int mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp); |
|
|
|
static int mdb_page_new(MDB_cursor *mc, uint32_t flags, int num, MDB_page **mp); |
|
|
|
static int mdb_page_new(MDB_cursor *mc, uint32_t flags, int num, MDB_page **mp); |
|
|
|
static int mdb_page_touch(MDB_cursor *mc); |
|
|
|
static int mdb_page_touch(MDB_cursor *mc); |
|
|
@ -2260,23 +2263,27 @@ mdb_page_flush(MDB_txn *txn) |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
/* Write up to MDB_COMMIT_PAGES dirty pages at a time. */ |
|
|
|
/* Write up to MDB_COMMIT_PAGES dirty pages at a time. */ |
|
|
|
if (pos != next_pos || n == MDB_COMMIT_PAGES) { |
|
|
|
if (pos!=next_pos || n==MDB_COMMIT_PAGES || wsize+size>MAX_WRITE) { |
|
|
|
if (n) { |
|
|
|
if (n) { |
|
|
|
/* Write previous page(s) */ |
|
|
|
/* Write previous page(s) */ |
|
|
|
#ifdef HAVE_PWRITEV |
|
|
|
#ifdef MDB_USE_PWRITEV |
|
|
|
wres = pwritev(env->me_fd, iov, n, wpos); |
|
|
|
wres = pwritev(env->me_fd, iov, n, wpos); |
|
|
|
#else |
|
|
|
#else |
|
|
|
if (lseek(env->me_fd, wpos, SEEK_SET) < 0) { |
|
|
|
if (n == 1) { |
|
|
|
rc = ErrCode(); |
|
|
|
wres = pwrite(env->me_fd, iov[0].iov_base, wsize, wpos); |
|
|
|
DPRINTF("lseek: %s", strerror(rc)); |
|
|
|
} else { |
|
|
|
return rc; |
|
|
|
if (lseek(env->me_fd, wpos, SEEK_SET) < 0) { |
|
|
|
|
|
|
|
rc = ErrCode(); |
|
|
|
|
|
|
|
DPRINTF("lseek: %s", strerror(rc)); |
|
|
|
|
|
|
|
return rc; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
wres = writev(env->me_fd, iov, n); |
|
|
|
} |
|
|
|
} |
|
|
|
wres = writev(env->me_fd, iov, n); |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (wres != wsize) { |
|
|
|
if (wres != wsize) { |
|
|
|
if (wres < 0) { |
|
|
|
if (wres < 0) { |
|
|
|
rc = ErrCode(); |
|
|
|
rc = ErrCode(); |
|
|
|
DPRINTF("writev: %s", strerror(rc)); |
|
|
|
DPRINTF("Write error: %s", strerror(rc)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
rc = EIO; /* TODO: Use which error code? */ |
|
|
|
rc = EIO; /* TODO: Use which error code? */ |
|
|
|
DPUTS("short write, filesystem full?"); |
|
|
|
DPUTS("short write, filesystem full?"); |
|
|
@ -2685,6 +2692,8 @@ mdb_env_write_meta(MDB_txn *txn) |
|
|
|
meta.mm_last_pg = metab.mm_last_pg; |
|
|
|
meta.mm_last_pg = metab.mm_last_pg; |
|
|
|
meta.mm_txnid = metab.mm_txnid; |
|
|
|
meta.mm_txnid = metab.mm_txnid; |
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
memset(&ov, 0, sizeof(ov)); |
|
|
|
|
|
|
|
ov.Offset = off; |
|
|
|
WriteFile(env->me_fd, ptr, len, NULL, &ov); |
|
|
|
WriteFile(env->me_fd, ptr, len, NULL, &ov); |
|
|
|
#else |
|
|
|
#else |
|
|
|
r2 = pwrite(env->me_fd, ptr, len, off); |
|
|
|
r2 = pwrite(env->me_fd, ptr, len, off); |
|
|
@ -3615,7 +3624,6 @@ mdb_env_copyfd(MDB_env *env, HANDLE fd) |
|
|
|
|
|
|
|
|
|
|
|
ptr = env->me_map + wsize; |
|
|
|
ptr = env->me_map + wsize; |
|
|
|
wsize = txn->mt_next_pgno * env->me_psize - wsize; |
|
|
|
wsize = txn->mt_next_pgno * env->me_psize - wsize; |
|
|
|
#define MAX_WRITE 2147483648U |
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
while (wsize > 0) { |
|
|
|
while (wsize > 0) { |
|
|
|
DWORD len, w2; |
|
|
|
DWORD len, w2; |
|
|
@ -3638,7 +3646,7 @@ mdb_env_copyfd(MDB_env *env, HANDLE fd) |
|
|
|
else |
|
|
|
else |
|
|
|
w2 = wsize; |
|
|
|
w2 = wsize; |
|
|
|
wres = write(fd, ptr, w2); |
|
|
|
wres = write(fd, ptr, w2); |
|
|
|
rc = wres == (ssize_t)w2 ? MDB_SUCCESS : rc < 0 ? ErrCode() : EIO; |
|
|
|
rc = wres == (ssize_t)w2 ? MDB_SUCCESS : wres < 0 ? ErrCode() : EIO; |
|
|
|
if (rc) break; |
|
|
|
if (rc) break; |
|
|
|
wsize -= wres; |
|
|
|
wsize -= wres; |
|
|
|
ptr += wres; |
|
|
|
ptr += wres; |
|
|
|