Author: tridge
Date: 2005-10-11 05:01:52 +0000 (Tue, 11 Oct 2005)
New Revision: 10891

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10891

Log:

I noticed that the secrets.db was not being backed up on my system due
to msync/mmap not changing the mtime of the file. This patch ensures
that for successfully completed transactions we update the mtime.

I don't do this on all tdb writes as its too expensive, but doing it
just on transactions is bearable, as those cost quite a lot anyway.


Modified:
   branches/SAMBA_4_0/source/lib/tdb/common/transaction.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/tdb/common/transaction.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/transaction.c      2005-10-11 
04:43:44 UTC (rev 10890)
+++ branches/SAMBA_4_0/source/lib/tdb/common/transaction.c      2005-10-11 
05:01:52 UTC (rev 10891)
@@ -857,6 +857,15 @@
 
        tdb_brlock_len(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1);
 
+       /* on some systems (like Linux 2.6.x) changes via mmap/msync
+          don't change the mtime of the file, this means the file may
+          not be backed up (as tdb rounding to block sizes means that
+          file size changes are quite rare too). The following forces
+          mtime changes when a transaction completes */
+#ifdef HAVE_UTIME
+       utime(tdb->name, NULL);
+#endif
+
        /* use a transaction cancel to free memory and remove the
           transaction locks */
        tdb_transaction_cancel(tdb);

Reply via email to