[SCM] Samba Shared Repository - branch master updated

Rusty Russell rusty at samba.org
Thu Mar 22 19:54:03 MDT 2012


The branch, master has been updated
       via  4442c0b lib/tdb: fix transaction issue for HAVE_INCOHERENT_MMAP.
       via  c12970c lib/tdb: fix test/run-die-during-transaction when HAVE_INCOHERENT_MMAP.
       via  330e3e1 lib/tdb: fix missing return 0 code.
      from  8718c7b s3:vfs_gpfs: fix some compiler warnings

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4442c0b2c92e4b2e88661e15022228c5f6547112
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Fri Mar 23 10:45:18 2012 +1030

    lib/tdb: fix transaction issue for HAVE_INCOHERENT_MMAP.
    
    We unmap the tdb on expand, the remap.  But when we have INCOHERENT_MMAP
    (ie. OpenBSD) and we're inside a transaction, doing the expand can mean
    we need to read from the database to partially fill a transaction block.
    This fails, because if mmap is incoherent we never allow accessing the
    database via read/write.
    
    The solution is not to unmap and remap until we've actually written the
    padding at the end of the file.
    
    Reported-by: Amitay Isaacs <amitay at gmail.com>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
    
    Autobuild-User: Rusty Russell <rusty at rustcorp.com.au>
    Autobuild-Date: Fri Mar 23 02:53:15 CET 2012 on sn-devel-104

commit c12970cc91cb4da8976801e194e29e33e02b340a
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Fri Mar 23 10:43:48 2012 +1030

    lib/tdb: fix test/run-die-during-transaction when HAVE_INCOHERENT_MMAP.
    
    Since we force mmap on, we don't intercept writes to the db, so we never
    see it in an inconsistent state.  #ifdef over the check that we should have
    recovered it at least once.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 330e3e1b91ecbf99af3b598b324f21b5eff933fd
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Fri Mar 23 10:41:55 2012 +1030

    lib/tdb: fix missing return 0 code.
    
    fde694274e1e5a11d1473695e7ec7a97f95d39e4 made tdb_mmap return an int,
    but didn't put the return 0 on the "internal db" case.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

-----------------------------------------------------------------------

Summary of changes:
 lib/tdb/common/io.c                       |   23 +++++++++++------------
 lib/tdb/test/run-die-during-transaction.c |    5 +++++
 2 files changed, 16 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index 24c2d61..3131f4f 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -244,7 +244,7 @@ static bool should_mmap(const struct tdb_context *tdb)
 int tdb_mmap(struct tdb_context *tdb)
 {
 	if (tdb->flags & TDB_INTERNAL)
-		return;
+		return 0;
 
 #ifdef HAVE_MMAP
 	if (should_mmap(tdb)) {
@@ -381,37 +381,36 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
 
 	size = tdb_expand_adjust(tdb->map_size, size, tdb->page_size);
 
-	if (!(tdb->flags & TDB_INTERNAL))
-		tdb_munmap(tdb);
-
 	/* expand the file itself */
 	if (!(tdb->flags & TDB_INTERNAL)) {
 		if (tdb->methods->tdb_expand_file(tdb, tdb->map_size, size) != 0)
 			goto fail;
 	}
 
-	tdb->map_size += size;
+	/* form a new freelist record */
+	offset = tdb->map_size;
+	memset(&rec,'\0',sizeof(rec));
+	rec.rec_len = size - sizeof(rec);
 
 	if (tdb->flags & TDB_INTERNAL) {
 		char *new_map_ptr = (char *)realloc(tdb->map_ptr,
-						    tdb->map_size);
+						    tdb->map_size + size);
 		if (!new_map_ptr) {
-			tdb->map_size -= size;
 			goto fail;
 		}
 		tdb->map_ptr = new_map_ptr;
+		tdb->map_size += size;
 	} else {
+		/* Explicitly remap: if we're in a transaction, this won't
+		 * happen automatically! */
+		tdb_munmap(tdb);
+		tdb->map_size += size;
 		if (tdb_mmap(tdb) != 0) {
 			goto fail;
 		}
 	}
 
-	/* form a new freelist record */
-	memset(&rec,'\0',sizeof(rec));
-	rec.rec_len = size - sizeof(rec);
-
 	/* link it into the free list */
-	offset = tdb->map_size - size;
 	if (tdb_free(tdb, offset, &rec) == -1)
 		goto fail;
 
diff --git a/lib/tdb/test/run-die-during-transaction.c b/lib/tdb/test/run-die-during-transaction.c
index d6502f4..ae7dafc 100644
--- a/lib/tdb/test/run-die-during-transaction.c
+++ b/lib/tdb/test/run-die-during-transaction.c
@@ -194,7 +194,12 @@ reset:
 		return false;
 	}
 
+#ifdef HAVE_INCOHERENT_MMAP
+	/* This means we always mmap, which makes this test a noop. */
+	ok1(1);
+#else
 	ok1(needed_recovery);
+#endif
 	ok1(locking_errors == 0);
 	ok1(forget_locking() == 0);
 	locking_errors = 0;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list