Changeset: f67ff41e0a54 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f67ff41e0a54
Branch: samloader
Log Message:

merge with default branch


diffs (truncated from 2518 to 300 lines):

diff --git a/buildtools/coverity_model.c b/buildtools/coverity_model.c
--- a/buildtools/coverity_model.c
+++ b/buildtools/coverity_model.c
@@ -124,7 +124,7 @@ GDKmmap(const char *path, int mode, size
 }
 
 gdk_return
-GDKmunmap(void *p, int mode, size_t size)
+GDKmunmap(void *p, size_t size)
 {
        int failed;
        __coverity_free__(p);
@@ -137,7 +137,7 @@ GDKmremap(const char *path, int mode, vo
 {
        void *p = GDKmmap(path, mode, new_size);
        if (p) {
-               (void) GDKmunmap(old_address, mode, old_size);
+               (void) GDKmunmap(old_address, old_size);
        }
        return p;
 }
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -312,7 +312,7 @@ size_t GDKmem_cursize(void);
 gdk_return GDKmergeidx(BAT *b, BAT **a, int n_ar);
 void *GDKmmap(const char *path, int mode, size_t len);
 int GDKms(void);
-gdk_return GDKmunmap(void *addr, int mode, size_t len);
+gdk_return GDKmunmap(void *addr, size_t len);
 int GDKnr_threads;
 void GDKprepareExit(void);
 void GDKprintinfo(void);
@@ -363,7 +363,7 @@ gdk_return HEAP_initialize(Heap *heap, s
 var_t HEAP_malloc(BAT *b, size_t nbytes);
 gdk_return HEAPalloc(Heap *h, size_t nitems, size_t itemsize);
 void HEAPdecref(Heap *h, bool remove);
-gdk_return HEAPextend(Heap *h, size_t size, bool mayshare);
+gdk_return HEAPextend(Heap *h, size_t size);
 void HEAPincref(Heap *h);
 size_t HEAPmemsize(const Heap *h);
 size_t HEAPvmsize(const Heap *h);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1258,7 +1258,6 @@ gdk_export void MT_cond_broadcast(MT_Con
 
 #define MMAP_READ      1024    /* region is readable (default if omitted) */
 #define MMAP_WRITE     2048    /* region may be written into */
-#define MMAP_COPY      4096    /* writable, but changes never reach file */
 
 /* in order to be sure of madvise and msync modes, pass them to mmap()
  * call as well */
@@ -1451,11 +1450,7 @@ typedef enum {
        STORE_INVALID = 0,      /* invalid value, used to indicate error */
        STORE_MEM,              /* load into GDKmalloced memory */
        STORE_MMAP,             /* mmap() into virtual memory */
-       STORE_PRIV,             /* BAT copy of copy-on-write mmap */
-       STORE_CMEM,             /* load into malloc (not GDKmalloc) memory*/
        STORE_NOWN,             /* memory not owned by the BAT */
-       STORE_MMAPABS,          /* mmap() into virtual memory from an
-                                * absolute path (not part of dbfarm) */
 } storage_t;
 
 typedef struct {
@@ -1476,7 +1471,6 @@ typedef struct {
        bool wasempty;          /* heap was empty when last saved/created */
        bool hasfile;           /* .filename exists on disk */
        storage_t storage;      /* storage mode (mmap/malloc). */
-       storage_t newstorage;   /* new desired storage mode at re-allocation. */
        bat parentid;           /* cache id of VIEW parent bat */
 } Heap;
 
@@ -1684,7 +1678,7 @@ mskGetVal(const BAT *b, BUN p)
        return ((uint32_t *) b->theap->base)[p / 32] & (1U << (p % 32));
 }
 
-gdk_export gdk_return HEAPextend(Heap *h, size_t size, bool mayshare)
+gdk_export gdk_return HEAPextend(Heap *h, size_t size)
        __attribute__((__warn_unused_result__));
 gdk_export size_t HEAPvmsize(const Heap *h)
        __attribute__((__pure__));
@@ -3983,7 +3977,7 @@ gdk_export size_t GDK_vm_maxsize; /* max
 
 gdk_export void *GDKmmap(const char *path, int mode, size_t len)
        __attribute__((__warn_unused_result__));
-gdk_export gdk_return GDKmunmap(void *addr, int mode, size_t len);
+gdk_export gdk_return GDKmunmap(void *addr, size_t len);
 
 gdk_export size_t GDKmem_cursize(void);        /* RAM/swapmem that MonetDB has
                                         * claimed from OS */
@@ -4880,15 +4874,14 @@ gdk_export int ma_info(allocator *sa, ch
                          _res);                                        \
                _res;                                                   \
         })
-#define GDKmunmap(p, m, l)                                     \
+#define GDKmunmap(p, l)                                                \
        ({                                                      \
                void *_ptr = (p);                               \
-               int _mode = (m);                                \
                size_t _len = (l);                              \
-               gdk_return _res = GDKmunmap(_ptr, _mode, _len); \
+               gdk_return _res = GDKmunmap(_ptr, _len);        \
                TRC_DEBUG(ALLOC,                                \
-                         "GDKmunmap(%p,0x%x,%zu) -> %u\n",     \
-                         _ptr, (unsigned) _mode, _len, _res);  \
+                         "GDKmunmap(%p,%zu) -> %u\n",          \
+                         _ptr, _len, _res);                    \
                _res;                                           \
        })
 #define malloc(s)                                      \
@@ -5098,14 +5091,14 @@ GDKmmap_debug(const char *path, int mode
 }
 #define GDKmmap(p, m, l)       GDKmmap_debug((p), (m), (l))
 static inline gdk_return
-GDKmunmap_debug(void *ptr, int mode, size_t len)
+GDKmunmap_debug(void *ptr, size_t len)
 {
-       gdk_return res = GDKmunmap(ptr, mode, len);
-       TRC_DEBUG(ALLOC, "GDKmunmap(%p,0x%x%zu) -> %d\n",
-                 ptr, mode, len, (int) res);
+       gdk_return res = GDKmunmap(ptr, len);
+       TRC_DEBUG(ALLOC, "GDKmunmap(%p,%zu) -> %d\n",
+                 ptr, len, (int) res);
        return res;
 }
-#define GDKmunmap(p, m, l)     GDKmunmap_debug((p), (m), (l))
+#define GDKmunmap(p, l)                GDKmunmap_debug((p), (l))
 static inline void *
 malloc_debug(size_t size)
 {
diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -55,7 +55,7 @@ GDKrebuild_segment_tree(oid ncount, oid 
        if (total_size > st->size) {
                total_size = (((total_size) + 1023) & ~1023); /* align to a 
multiple of 1024 bytes */
                st->free = st->size;
-               if (HEAPextend(st, total_size, true) != GDK_SUCCEED)
+               if (HEAPextend(st, total_size) != GDK_SUCCEED)
                        return GDK_FAIL;
                *segment_tree = st->base;
                *levels_offset = (oid*)(st->base + next_tree_size); /* levels 
offset will be next to the segment tree */
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -441,7 +441,7 @@ BATextend(BAT *b, BUN newcap)
        if (b->theap->base) {
                TRC_DEBUG(HEAP, "HEAPgrow in BATextend %s %zu %zu\n",
                          b->theap->filename, b->theap->size, theap_size);
-               rc = HEAPgrow(&b->theap, theap_size, b->batRestricted == 
BAT_READ);
+               rc = HEAPgrow(&b->theap, theap_size);
                if (rc == GDK_SUCCEED)
                        b->batCapacity = newcap;
        } else {
@@ -854,7 +854,7 @@ COLcopy2(BAT *b, int tt, bool writable, 
                                        algo = "share vheap, memcpy heap";
                                }
                        } else {
-                               if (HEAPextend(bn->tvheap, bi.vhfree, true) != 
GDK_SUCCEED)
+                               if (HEAPextend(bn->tvheap, bi.vhfree) != 
GDK_SUCCEED)
                                        goto bunins_failed;
                                memcpy(bn->tvheap->base, bi.vh->base, 
bi.vhfree);
                                bn->tvkey = bi.vkey;
@@ -2211,248 +2211,9 @@ BATtseqbase(BAT *b, oid o)
        }
 }
 
-/*
- * @- Change the BAT access permissions (read, append, write)
- * Regrettably, BAT access-permissions, persistent status and memory
- * map modes, interact in ways that makes one's brain sizzle. This
- * makes BATsetaccess and TMcommit (where a change in BAT persistence
- * mode is made permanent) points in which the memory map status of
- * bats needs to be carefully re-assessed and ensured.
- *
- * Another complication is the fact that during commit, concurrent
- * users may access the heaps, such that the simple solution
- * unmap;re-map is out of the question.
- * Even worse, it is not possible to even rename an open mmap file in
- * Windows. For this purpose, we dropped the old .priv scheme, which
- * relied on file moves. Now, the file that is opened with mmap is
- * always the X file, in case of newstorage=STORE_PRIV, we save in a
- * new file X.new
- *
- * we must consider the following dimensions:
- *
- * persistence:
- *     not simply the current persistence mode but whether the bat *was*
- *     present at the last commit point (BBP status & BBPEXISTING).
- *     The crucial issue is namely whether we must guarantee recovery
- *     to a previous sane state.
- *
- * access:
- *     whether the BAT is BAT_READ or BAT_WRITE. Note that BAT_APPEND
- *     is usually the same as BAT_READ (as our concern are only data pages
- *     that already existed at the last commit).
- *
- * storage:
- *     the current way the heap file X is memory-mapped;
- *     STORE_MMAP uses direct mapping (so dirty pages may be flushed
- *     at any time to disk), STORE_PRIV uses copy-on-write.
- *
- * newstorage:
- *     the current save-regime. STORE_MMAP calls msync() on the heap X,
- *     whereas STORE_PRIV writes the *entire* heap in a file: X.new
- *     If a BAT is loaded from disk, the field newstorage is used
- *     to set storage as well (so before change-access and commit-
- *     persistence mayhem, we always have newstorage=storage).
- *
- * change-access:
- *     what happens if the bat-access mode is changed from
- *     BAT_READ into BAT_WRITE (or vice versa).
- *
- * commit-persistence:
- *     what happens during commit if the bat-persistence mode was
- *     changed (from TRANSIENT into PERSISTENT, or vice versa).
- *
- * this is the scheme:
- *
- *  persistence access    newstorage storage    change-access 
commit-persistence
- *  =========== ========= ========== ========== ============= 
==================
- * 0 transient  BAT_READ  STORE_MMAP STORE_MMAP =>2           =>4
- * 1 transient  BAT_READ  STORE_PRIV STORE_PRIV =>3           =>5
- * 2 transient  BAT_WRITE STORE_MMAP STORE_MMAP =>0           =>6+
- * 3 transient  BAT_WRITE STORE_PRIV STORE_PRIV =>1           =>7
- * 4 persistent BAT_READ  STORE_MMAP STORE_MMAP =>6+          =>0
- * 5 persistent BAT_READ  STORE_PRIV STORE_PRIV =>7           =>1
- * 6 persistent BAT_WRITE STORE_PRIV STORE_MMAP del X.new=>4+ del X.new;=>2+
- * 7 persistent BAT_WRITE STORE_PRIV STORE_PRIV =>5           =>3
- *
- * exception states:
- * a transient  BAT_READ  STORE_PRIV STORE_MMAP =>b           =>c
- * b transient  BAT_WRITE STORE_PRIV STORE_MMAP =>a           =>6
- * c persistent BAT_READ  STORE_PRIV STORE_MMAP =>6           =>a
- *
- * (+) indicates that we must ensure that the heap gets saved in its new mode
- *
- * Note that we now allow a heap with save-regime STORE_PRIV that was
- * actually mapped STORE_MMAP. In effect, the potential corruption of
- * the X file is compensated by writing out full X.new files that take
- * precedence.  When transitioning out of this state towards one with
- * both storage regime and OS as STORE_MMAP we need to move the X.new
- * files into the backup directory. Then msync the X file and (on
- * success) remove the X.new; see backup_new().
- *
- * Exception states are only reachable if the commit fails and those
- * new persistent bats have already been processed (but never become
- * part of a committed state). In that case a transition 2=>6 may end
- * up 2=>b.  Exception states a and c are reachable from b.
- *
- * Errors in HEAPchangeaccess() can be handled atomically inside the
- * routine.  The work on changing mmap modes HEAPcommitpersistence()
- * is done during the BBPsync() for all bats that are newly persistent
- * (BBPNEW). After the TMcommit(), it is done for those bats that are
- * no longer persistent after the commit (BBPDELETED), only if it
- * succeeds.  Such transient bats cannot be processed before the
- * commit, because the commit may fail and then the more unsafe
- * transient mmap modes would be present on a persistent bat.
- *
- * See dirty_bat() in BBPsync() -- gdk_bbp.c and epilogue() in
- * gdk_tm.c.
- *
- * Including the exception states, we have 11 of the 16
- * combinations. As for the 5 avoided states, all four
- * (persistence,access) states with (STORE_MMAP,STORE_PRIV) are
- * omitted (this would amount to an msync() save regime on a
- * copy-on-write heap -- which does not work). The remaining avoided
- * state is the patently unsafe
- * (persistent,BAT_WRITE,STORE_MMAP,STORE_MMAP).
- *
- * Note that after a server restart exception states are gone, as on
- * BAT loads the saved descriptor is inspected again (which will
- * reproduce the state at the last succeeded commit).
- *
- * To avoid exception states, a TMsubcommit protocol would need to be
- * used which is too heavy for BATsetaccess().
- *
- * Note that this code is not about making heaps mmap-ed in the first
- * place.  It is just about determining which flavor of mmap should be
- * used. The MAL user is oblivious of such details.
- */
-
-/* rather than deleting X.new, we comply with the commit protocol and
- * move it to backup storage */
-static gdk_return
-backup_new(Heap *hp, bool lock)
-{
-       int batret, bakret, ret = -1;
-       char batpath[MAXPATH], bakpath[MAXPATH];
-       struct stat st;
-
-       char *bak_filename = NULL;
-       if ((bak_filename = strrchr(hp->filename, DIR_SEP)) != NULL)
-               bak_filename++;
-       else
-               bak_filename = hp->filename;
-       /* check for an existing X.new in BATDIR, BAKDIR and SUBDIR */
-       if (GDKfilepath(batpath, sizeof(batpath), hp->farmid, BATDIR, 
hp->filename, "new") == GDK_SUCCEED &&
-           GDKfilepath(bakpath, sizeof(bakpath), hp->farmid, BAKDIR, 
bak_filename, "new") == GDK_SUCCEED) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to