[SCM] Samba Shared Repository - branch v3-6-test updated
Jeremy Allison
jra at samba.org
Tue Apr 19 15:46:15 MDT 2011
The branch, v3-6-test has been updated
via 9953e69 tdb_backup: avoid transaction on backup file, use lockall
from 77b0bcc Fix Bug #8099 setpwent() actually does endpwent() and vice versa on FreeBSD
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test
- Log -----------------------------------------------------------------
commit 9953e698611defdd6919883a965bdfc12ce51bd5
Author: Simo Sorce <idra at samba.org>
Date: Sat Apr 9 22:21:35 2011 -0400
tdb_backup: avoid transaction on backup file, use lockall
Transactions have the side effect of generating bigger files.
By removing the transaction files get as much as 30% smaller.
Autobuild-User: Simo Sorce <idra at samba.org>
Autobuild-Date: Tue Apr 19 23:34:37 CEST 2011 on sn-devel-104
(cherry picked from commit 1804d9a64662d37f6c7c50bdd7b8edd80f42192b)
-----------------------------------------------------------------------
Summary of changes:
lib/tdb/tools/tdbbackup.c | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/tdb/tools/tdbbackup.c b/lib/tdb/tools/tdbbackup.c
index 6aca8dd..11ecaa0 100644
--- a/lib/tdb/tools/tdbbackup.c
+++ b/lib/tdb/tools/tdbbackup.c
@@ -152,8 +152,9 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
return 1;
}
- if (tdb_transaction_start(tdb_new) != 0) {
- printf("Failed to start transaction on new tdb\n");
+ /* lock the backup tdb so that nobody else can change it */
+ if (tdb_lockall(tdb_new) != 0) {
+ printf("Failed to lock backup tdb\n");
tdb_close(tdb);
tdb_close(tdb_new);
unlink(tmp_name);
@@ -177,12 +178,16 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
/* close the old tdb */
tdb_close(tdb);
- if (tdb_transaction_commit(tdb_new) != 0) {
- fprintf(stderr, "Failed to commit new tdb\n");
- tdb_close(tdb_new);
- unlink(tmp_name);
- free(tmp_name);
- return 1;
+ /* copy done, unlock the backup tdb */
+ tdb_unlockall(tdb_new);
+
+#ifdef HAVE_FDATASYNC
+ if (fdatasync(tdb_fd(tdb_new)) != 0) {
+#else
+ if (fsync(tdb_fd(tdb_new)) != 0) {
+#endif
+ /* not fatal */
+ fprintf(stderr, "failed to fsync backup file\n");
}
/* close the new tdb and re-open read-only */
--
Samba Shared Repository
More information about the samba-cvs
mailing list