Skip to content

Commit

Permalink
Fix __db.00* file to get the maximum size in advance
Browse files Browse the repository at this point in the history
According to the following rules of mmap, fix __db.00* file to get the maximum
size in advance so that __db.00* file is not expanded.

From mmap(2) manpage:
  The effect of changing the size of the underlying file of a mapping on the
  pages that correspond to added or removed regions of the file is unspecified.

From mmap in IEEE Std 1003.1-2017:
  If the size of the mapped file changes after the call to mmap() as a result of
  some other operation on the mapped file, the effect of references to portions
  of the mapped region that correspond to added or removed portions of the file
  is unspecified.
  • Loading branch information
miztake committed Sep 2, 2021
1 parent dfac2f3 commit 45446f3
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions db-18.1.40/src/os/os_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,7 @@ __os_attach(env, infop, rp)
if (rp->max < rp->size)
rp->max = rp->size;
if (ret == 0 && F_ISSET(infop, REGION_CREATE)) {
#ifdef HAVE_MLOCK
/*
* When locking the region in memory extend it fully so that it
* can all be mlock()'d now, and not later when paging could
* interfere with the application. [#21379]
*/
if (F_ISSET(env, ENV_LOCKDOWN))
rp->size = rp->max;
#endif
rp->size = rp->max;
if (F_ISSET(dbenv, DB_ENV_REGION_INIT))
ret = __db_file_write(env, infop->fhp,
rp->size / MEGABYTE, rp->size % MEGABYTE, 0x00);
Expand Down

0 comments on commit 45446f3

Please sign in to comment.