|
|
@ -3756,15 +3756,12 @@ mdb_env_write_meta(MDB_txn *txn) |
|
|
|
if (!(flags & (MDB_NOMETASYNC|MDB_NOSYNC))) { |
|
|
|
if (!(flags & (MDB_NOMETASYNC|MDB_NOSYNC))) { |
|
|
|
unsigned meta_size = env->me_psize; |
|
|
|
unsigned meta_size = env->me_psize; |
|
|
|
rc = (env->me_flags & MDB_MAPASYNC) ? MS_ASYNC : MS_SYNC; |
|
|
|
rc = (env->me_flags & MDB_MAPASYNC) ? MS_ASYNC : MS_SYNC; |
|
|
|
ptr = env->me_map; |
|
|
|
ptr = (char *)mp - PAGEHDRSZ; |
|
|
|
if (toggle) { |
|
|
|
|
|
|
|
#ifndef _WIN32 /* POSIX msync() requires ptr = start of OS page */ |
|
|
|
#ifndef _WIN32 /* POSIX msync() requires ptr = start of OS page */ |
|
|
|
if (meta_size < env->me_os_psize) |
|
|
|
r2 = (ptr - env->me_map) & (env->me_os_psize - 1); |
|
|
|
meta_size += meta_size; |
|
|
|
ptr -= r2; |
|
|
|
else |
|
|
|
meta_size += r2; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
ptr += meta_size; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (MDB_MSYNC(ptr, meta_size, rc)) { |
|
|
|
if (MDB_MSYNC(ptr, meta_size, rc)) { |
|
|
|
rc = ErrCode(); |
|
|
|
rc = ErrCode(); |
|
|
|
goto fail; |
|
|
|
goto fail; |
|
|
@ -3772,8 +3769,8 @@ mdb_env_write_meta(MDB_txn *txn) |
|
|
|
} |
|
|
|
} |
|
|
|
goto done; |
|
|
|
goto done; |
|
|
|
} |
|
|
|
} |
|
|
|
metab.mm_txnid = env->me_metas[toggle]->mm_txnid; |
|
|
|
metab.mm_txnid = mp->mm_txnid; |
|
|
|
metab.mm_last_pg = env->me_metas[toggle]->mm_last_pg; |
|
|
|
metab.mm_last_pg = mp->mm_last_pg; |
|
|
|
|
|
|
|
|
|
|
|
meta.mm_mapsize = mapsize; |
|
|
|
meta.mm_mapsize = mapsize; |
|
|
|
meta.mm_dbs[FREE_DBI] = txn->mt_dbs[FREE_DBI]; |
|
|
|
meta.mm_dbs[FREE_DBI] = txn->mt_dbs[FREE_DBI]; |
|
|
@ -3784,9 +3781,7 @@ mdb_env_write_meta(MDB_txn *txn) |
|
|
|
off = offsetof(MDB_meta, mm_mapsize); |
|
|
|
off = offsetof(MDB_meta, mm_mapsize); |
|
|
|
ptr = (char *)&meta + off; |
|
|
|
ptr = (char *)&meta + off; |
|
|
|
len = sizeof(MDB_meta) - off; |
|
|
|
len = sizeof(MDB_meta) - off; |
|
|
|
if (toggle) |
|
|
|
off += (char *)mp - env->me_map; |
|
|
|
off += env->me_psize; |
|
|
|
|
|
|
|
off += PAGEHDRSZ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Write to the SYNC fd */ |
|
|
|
/* Write to the SYNC fd */ |
|
|
|
mfd = (flags & (MDB_NOSYNC|MDB_NOMETASYNC)) ? env->me_fd : env->me_mfd; |
|
|
|
mfd = (flags & (MDB_NOSYNC|MDB_NOMETASYNC)) ? env->me_fd : env->me_mfd; |
|
|
|