s3: Make sure our CLEAR_IF_FIRST optimization works for the notify tdbs
authorVolker Lendecke <vl@samba.org>
Thu, 25 Mar 2010 15:01:54 +0000 (16:01 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 25 Mar 2010 16:34:13 +0000 (17:34 +0100)
The notify tdb files are opened at tconX time, which leads to one fcntl lock
for CLEAR_IF_FIRST detection per smbd. This opens the tdbs in the parent and
holds it, so that tdb_reopen_all correctly catches the CLEAR_IF_FIRST bit.

source3/include/proto.h
source3/smbd/notify_internal.c
source3/smbd/server.c

index c5f88cb3a82de3ad0e5c9bc07c04978e57c7ee35..7395bf2be257391a2391b7fb4719c30bfb835a23 100644 (file)
@@ -6592,6 +6592,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
                                   struct messaging_context *messaging_ctx,
                                   struct event_context *ev,
                                   connection_struct *conn);
+bool notify_internal_parent_init(void);
 NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
                    void (*callback)(void *, const struct notify_event *), 
                    void *private_data);
index f1c1aeef360a1e6b65038798e5b76bb987f03703..6604a2adeff7c564059de3ed415d745e0d1b8846 100644 (file)
@@ -128,6 +128,33 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
        return notify;
 }
 
+bool notify_internal_parent_init(void)
+{
+       struct tdb_wrap *db1, *db2;
+
+       if (lp_clustering()) {
+               return true;
+       }
+
+       db1 = tdb_wrap_open(talloc_autofree_context(), lock_path("notify.tdb"),
+                           0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST,
+                          O_RDWR|O_CREAT, 0644);
+       if (db1 == NULL) {
+               DEBUG(1, ("could not open notify.tdb: %s\n", strerror(errno)));
+               return false;
+       }
+       db2 = tdb_wrap_open(talloc_autofree_context(),
+                           lock_path("notify_onelevel.tdb"),
+                           0, TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0644);
+       if (db2 == NULL) {
+               DEBUG(1, ("could not open notify_onelevel.tdb: %s\n",
+                         strerror(errno)));
+               TALLOC_FREE(db1);
+               return false;
+       }
+       return true;
+}
+
 /*
   lock and fetch the record
 */
index 65528e5720390f3cbe8fe181ca1e357f54e4bb1f..1ceed267daa0864982440754559c5d1ccd12cc63 100644 (file)
@@ -1286,6 +1286,10 @@ extern void build_options(bool screen);
                exit(1);
        }
 
+       if (!notify_internal_parent_init()) {
+               exit(1);
+       }
+
        namecache_enable();
 
        if (!W_ERROR_IS_OK(registry_init_full()))