[Pkg-samba-maint] r1797 - in trunk/tdb/debian: . patches

ctrlsoft-guest at alioth.debian.org ctrlsoft-guest at alioth.debian.org
Tue Mar 25 19:50:28 UTC 2008


tags 425716 pending
thanks

Author: ctrlsoft-guest
Date: 2008-03-25 19:50:28 +0000 (Tue, 25 Mar 2008)
New Revision: 1797

Added:
   trunk/tdb/debian/patches/01clear_patches.patch
Modified:
   trunk/tdb/debian/changelog
   trunk/tdb/debian/patches/series
Log:
Add patch to clear patches in existing tdb files.

Modified: trunk/tdb/debian/changelog
===================================================================
--- trunk/tdb/debian/changelog	2008-03-25 19:46:40 UTC (rev 1796)
+++ trunk/tdb/debian/changelog	2008-03-25 19:50:28 UTC (rev 1797)
@@ -1,3 +1,10 @@
+tdb (git20080325-1) unstable; urgency=low
+
+  * Add patch 01clear_spinlocks.patch to allow opening older TDB files again.
+    (Closes: #425716)
+
+ -- Jelmer Vernooij <jelmer at samba.org>  Tue, 25 Mar 2008 20:49:00 +0100
+
 tdb (1.1.1~svn26294-1) unstable; urgency=low
 
   * New upstream snapshot.

Added: trunk/tdb/debian/patches/01clear_patches.patch
===================================================================
--- trunk/tdb/debian/patches/01clear_patches.patch	                        (rev 0)
+++ trunk/tdb/debian/patches/01clear_patches.patch	2008-03-25 19:50:28 UTC (rev 1797)
@@ -0,0 +1,75 @@
+Index: common/open.c
+===================================================================
+--- common/open.c	(revision 24272)
++++ common/open.c	(working copy)
+@@ -141,7 +141,21 @@
+ {
+ }
+ 
++/* Clean up spinlock pointer */
++static int tdb_clear_spinlocks(struct tdb_context *tdb)
++{
++	off_t off = (off_t)((char *)&tdb->header.rwlocks
++							- (char *)&tdb->header);
+ 
++	tdb->header.rwlocks = 0;
++	if (lseek(tdb->fd, off, SEEK_SET) != off
++		|| write(tdb->fd, (void *)&tdb->header.rwlocks,
++				 sizeof(tdb->header.rwlocks)) 
++		!= sizeof(tdb->header.rwlocks))
++		return -1;
++	return 0;
++}
++
+ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
+ 				int open_flags, mode_t mode,
+ 				const struct tdb_logging_context *log_ctx,
+@@ -222,9 +236,12 @@
+ 		goto fail;	/* errno set by tdb_brlock */
+ 	}
+ 
++	if ((tdb_flags & TDB_CLEAR_IF_FIRST) || tdb->header.rwlocks != 0) {
++		locked = (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_WRLCK, F_SETLK, 0, 1) == 0);
++	}
++
+ 	/* we need to zero database if we are the only one with it open */
+-	if ((tdb_flags & TDB_CLEAR_IF_FIRST) &&
+-	    (locked = (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_WRLCK, F_SETLK, 0, 1) == 0))) {
++	if ((tdb_flags & TDB_CLEAR_IF_FIRST) && locked) {
+ 		open_flags |= O_CREAT;
+ 		if (ftruncate(tdb->fd, 0) == -1) {
+ 			TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
+@@ -261,11 +278,6 @@
+ 	if (fstat(tdb->fd, &st) == -1)
+ 		goto fail;
+ 
+-	if (tdb->header.rwlocks != 0) {
+-		TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: spinlocks no longer supported\n"));
+-		goto fail;
+-	}
+-
+ 	/* Is it already in the open list?  If so, fail. */
+ 	if (tdb_already_open(st.st_dev, st.st_ino)) {
+ 		TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: "
+@@ -286,13 +298,21 @@
+ 	tdb->max_dead_records = 0;
+ 	tdb_mmap(tdb);
+ 	if (locked) {
++		/* Clear up spinlocks if there were any remaining */
++		if (tdb->header.rwlocks != 0 && !tdb->read_only)
++			tdb_clear_spinlocks(tdb);
++
+ 		if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_UNLCK, F_SETLK, 0, 1) == -1) {
+ 			TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: "
+ 				 "failed to take ACTIVE_LOCK on %s: %s\n",
+ 				 name, strerror(errno)));
+ 			goto fail;
+ 		}
++	}
+ 
++	if (tdb->header.rwlocks != 0) {
++		TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: spinlocks no longer supported\n"));
++		goto fail;
+ 	}
+ 
+ 	/* We always need to do this if the CLEAR_IF_FIRST flag is set, even if

Modified: trunk/tdb/debian/patches/series
===================================================================
--- trunk/tdb/debian/patches/series	2008-03-25 19:46:40 UTC (rev 1796)
+++ trunk/tdb/debian/patches/series	2008-03-25 19:50:28 UTC (rev 1797)
@@ -0,0 +1 @@
+01clean_spinlocks.patch




More information about the Pkg-samba-maint mailing list