[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Tue Nov 27 19:14:02 MST 2012
The branch, master has been updated
via 00e2d83 s3: Open gencache_notrans with TDB_NOSYNC
via ee5db0e s3: Avoid some transaction_commit on gencache.tdb
via 5f0f50c docs: Add some binaries to the "SEE ALSO" section
via 4a1b16f docs: Fix version in man smb.conf.
from 5f2edd1 s3: Fix bug 9428 -- inotify detection broken
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 00e2d83fa4f1e9a336c2030a3f07066caee85083
Author: Volker Lendecke <vl at samba.org>
Date: Tue Nov 20 10:02:07 2012 +0100
s3: Open gencache_notrans with TDB_NOSYNC
We are doing CLEAR_IF_FIRST here, and we are doing the transactions only to
protect gencache_stabilize against concurrent writers. tdb's transaction.c
says:
- if TDB_NOSYNC is passed to flags in tdb_open then transactions are
still available, but no fsync/msync calls are made. This means we
are still proof against a process dying during transaction commit,
but not against machine reboot.
For gencache_notrans.tdb this is exactly what we want and avoids some expensive
disk syncs.
Reviewed by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Nov 28 03:13:56 CET 2012 on sn-devel-104
commit ee5db0efa517fcf119d0318376030c01fb8f2f38
Author: Volker Lendecke <vl at samba.org>
Date: Tue Nov 20 09:50:57 2012 +0100
s3: Avoid some transaction_commit on gencache.tdb
Commits are expensive, and in some scenarios we are overwriting existing values
again and again.
Reviewed by: Jeremy Allison <jra at samba.org>
commit 5f0f50c542450b7ede855f8e538ec90450cd10ab
Author: Karolin Seeger <kseeger at samba.org>
Date: Tue Nov 27 11:46:38 2012 +0100
docs: Add some binaries to the "SEE ALSO" section
of man smb.conf.
Karolin
Reviewed by: Jeremy Allison <jra at samba.org>
commit 4a1b16fe57c31ae8125475137088215426997749
Author: Karolin Seeger <kseeger at samba.org>
Date: Tue Nov 27 11:29:26 2012 +0100
docs: Fix version in man smb.conf.
Karolin
Reviewed by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
docs-xml/manpages/smb.conf.5.xml | 5 +-
source3/lib/gencache.c | 115 +++++++++++++++++++++++++++++++++++++-
2 files changed, 118 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/docs-xml/manpages/smb.conf.5.xml b/docs-xml/manpages/smb.conf.5.xml
index a73382f..71b097b 100644
--- a/docs-xml/manpages/smb.conf.5.xml
+++ b/docs-xml/manpages/smb.conf.5.xml
@@ -792,7 +792,7 @@ chmod 1770 /usr/local/samba/lib/usershares
<refsect1>
<title>VERSION</title>
- <para>This man page is correct for version 3 of the Samba suite.</para>
+ <para>This man page is correct for version 4 of the Samba suite.</para>
</refsect1>
<refsect1>
@@ -803,6 +803,9 @@ chmod 1770 /usr/local/samba/lib/usershares
<manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>swat</refentrytitle>
<manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>smbd</refentrytitle>
<manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>nmbd</refentrytitle>
+ <manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>winbindd</refentrytitle>
+ <manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>samba</refentrytitle>
+ <manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>samba-tool</refentrytitle>
<manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>smbclient</refentrytitle>
<manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>nmblookup</refentrytitle>
<manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>testparm</refentrytitle>
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 95b4811..0b24c0c 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -106,7 +106,10 @@ again:
DEBUG(5, ("Opening cache file at %s\n", cache_fname));
- cache_notrans = tdb_open_log(cache_fname, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
+ cache_notrans = tdb_open_log(cache_fname, 0,
+ TDB_CLEAR_IF_FIRST|
+ TDB_INCOMPATIBLE_HASH|
+ TDB_NOSYNC,
open_flags, 0644);
if (cache_notrans == NULL) {
DEBUG(5, ("Opening %s failed: %s\n", cache_fname,
@@ -127,6 +130,110 @@ static TDB_DATA last_stabilize_key(void)
return result;
}
+struct gencache_have_val_state {
+ time_t new_timeout;
+ const DATA_BLOB *data;
+ bool gotit;
+};
+
+static void gencache_have_val_parser(time_t old_timeout, DATA_BLOB data,
+ void *private_data)
+{
+ struct gencache_have_val_state *state =
+ (struct gencache_have_val_state *)private_data;
+ time_t now = time(NULL);
+ int cache_time_left, new_time_left, additional_time;
+
+ /*
+ * Excuse the many variables, but these time calculations are
+ * confusing to me. We do not want to write to gencache with a
+ * possibly expensive transaction if we are about to write the same
+ * value, just extending the remaining timeout by less than 10%.
+ */
+
+ cache_time_left = old_timeout - now;
+ if (cache_time_left <= 0) {
+ /*
+ * timed out, write new value
+ */
+ return;
+ }
+
+ new_time_left = state->new_timeout - now;
+ if (new_time_left <= 0) {
+ /*
+ * Huh -- no new timeout?? Write it.
+ */
+ return;
+ }
+
+ if (new_time_left < cache_time_left) {
+ /*
+ * Someone wants to shorten the timeout. Let it happen.
+ */
+ return;
+ }
+
+ /*
+ * By how much does the new timeout extend the remaining cache time?
+ */
+ additional_time = new_time_left - cache_time_left;
+
+ if (additional_time * 10 < 0) {
+ /*
+ * Integer overflow. We extend by so much that we have to write it.
+ */
+ return;
+ }
+
+ /*
+ * The comparison below is essentially equivalent to
+ *
+ * new_time_left > cache_time_left * 1.10
+ *
+ * but without floating point calculations.
+ */
+
+ if (additional_time * 10 > cache_time_left) {
+ /*
+ * We extend the cache timeout by more than 10%. Do it.
+ */
+ return;
+ }
+
+ /*
+ * Now the more expensive data compare.
+ */
+ if (data_blob_cmp(state->data, &data) != 0) {
+ /*
+ * Write a new value. Certainly do it.
+ */
+ return;
+ }
+
+ /*
+ * Extending the timeout by less than 10% for the same cache value is
+ * not worth the trouble writing a value into gencache under a
+ * possibly expensive transaction.
+ */
+ state->gotit = true;
+}
+
+static bool gencache_have_val(const char *keystr, const DATA_BLOB *data,
+ time_t timeout)
+{
+ struct gencache_have_val_state state;
+
+ state.new_timeout = timeout;
+ state.data = data;
+ state.gotit = false;
+
+ if (!gencache_parse(keystr, gencache_have_val_parser, &state)) {
+ return false;
+ }
+ return state.gotit;
+}
+
/**
* Set an entry in the cache file. If there's no such
* one, then add it.
@@ -160,6 +267,12 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob,
if (!gencache_init()) return False;
+ if (gencache_have_val(keystr, blob, timeout)) {
+ DEBUG(10, ("Did not store value for %s, we already got it\n",
+ keystr));
+ return true;
+ }
+
val = talloc_asprintf(talloc_tos(), CACHE_DATA_FMT, (int)timeout);
if (val == NULL) {
return False;
--
Samba Shared Repository
More information about the samba-cvs
mailing list