diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-22 09:44:40 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-22 07:35:17 +0200 |
commit | 0a34f342c3facace0767ff08f05532c9f161e305 (patch) | |
tree | c227f755f1933e797ac49f74a856c8d60b11539d /lib/ntdb/private.h | |
parent | 66d151d6893657b31c419d422bffeefc506e2319 (diff) | |
download | samba-0a34f342c3facace0767ff08f05532c9f161e305.tar.gz samba-0a34f342c3facace0767ff08f05532c9f161e305.tar.bz2 samba-0a34f342c3facace0767ff08f05532c9f161e305.zip |
ntdb: enhancement to allow direct access to the ntdb map during expansion.
This means keeping the old mmap around when we expand the database.
We could revert to read/write, except for platforms with incoherent
mmap (ie. OpenBSD), where we need to use mmap for all accesses.
Thus we keep a linked list of old maps, and unmap them when the last access
finally goes away.
This is required if we want ntdb_parse_record() callbacks to be able
to expand the database.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/private.h')
-rw-r--r-- | lib/ntdb/private.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/ntdb/private.h b/lib/ntdb/private.h index 90b782d303..5efd2e0d92 100644 --- a/lib/ntdb/private.h +++ b/lib/ntdb/private.h @@ -301,6 +301,14 @@ struct ntdb_access_hdr { bool convert; }; +/* mmaps we are keeping around because they are still direct accessed */ +struct ntdb_old_mmap { + struct ntdb_old_mmap *next; + + void *map_ptr; + ntdb_len_t map_size; +}; + struct ntdb_file { /* How many are sharing us? */ unsigned int refcnt; @@ -314,6 +322,12 @@ struct ntdb_file { /* The file descriptor (-1 for NTDB_INTERNAL). */ int fd; + /* How many are accessing directly? */ + unsigned int direct_count; + + /* Old maps, still direct accessed. */ + struct ntdb_old_mmap *old_mmaps; + /* Lock information */ pid_t locker; struct ntdb_lock allrecord_lock; @@ -429,7 +443,7 @@ void ntdb_io_init(struct ntdb_context *ntdb); void *ntdb_convert(const struct ntdb_context *ntdb, void *buf, ntdb_len_t size); /* Unmap and try to map the ntdb. */ -void ntdb_munmap(struct ntdb_file *file); +enum NTDB_ERROR ntdb_munmap(struct ntdb_context *ntdb); enum NTDB_ERROR ntdb_mmap(struct ntdb_context *ntdb); /* Either alloc a copy, or give direct access. Release frees or noop. */ @@ -576,9 +590,6 @@ struct ntdb_context { enum NTDB_ERROR (*openhook)(int fd, void *data); void *openhook_data; - /* Are we accessing directly? (debugging check). */ - int direct_access; - /* Set if we are in a transaction. */ struct ntdb_transaction *transaction; |