svn commit: samba r20883 - in branches: SAMBA_3_0/source/include SAMBA_3_0/source/libsmb SAMBA_3_0/source/locking SAMBA_3_0/source/smbd SAMBA_3_0_24/source/include SAMBA_3_0_24/source/libsmb SAMBA_3_0_24/source/locking SAMBA_3_0_24/source/smbd

Jeremy Allison jra at samba.org
Fri Jan 19 01:43:37 GMT 2007


On Thu, Jan 18, 2007 at 04:18:27PM -0800, Jeremy Allison wrote:
> On Thu, Jan 18, 2007 at 11:55:22PM +0100, Volker Lendecke wrote:
> > On Thu, Jan 18, 2007 at 02:26:50PM -0800, Jeremy Allison wrote:
> > > > Congratulations! Coding Samba can be rewarding sometimes! :-)
> > > 
> > > Indeed. I'm sure you understand how smug I'm feeling at
> > > the moment :-) :-).
> > 
> > Oh yes, I do.
> 
> Here's a version that passes the Samba4 BASE-DELETE
> test completely, but it's (a) too expensive to live,
> and (b) racy, as it only blows the statcache in it's
> own process (it really should send a message to all
> smbd's to remove this name from their statcaches).
> 
> But fun to do :-).

And here's the version that does everything right :-).
Should pass all tests for delete on close, including
the hard one....

Now - I wonder what cost this has in production ? :-).

Jeremy.

PS. I know I'm polishing the underside of the table,
I just can't help myself :-) :-).
-------------- next part --------------
Index: smbd/close.c
===================================================================
--- smbd/close.c	(revision 20883)
+++ smbd/close.c	(working copy)
@@ -431,6 +431,7 @@
 			become_user(fsp->conn, fsp->vuid);
 			became_user = True;
 		}
+		send_stat_cache_delete_message(fsp->fsp_name);
 		set_delete_on_close_lck(lck, True, &current_user.ut);
 		if (became_user) {
 			unbecome_user();
Index: smbd/statcache.c
===================================================================
--- smbd/statcache.c	(revision 20880)
+++ smbd/statcache.c	(working copy)
@@ -285,6 +285,38 @@
 	}
 }
 
+/***************************************************************************
+ Tell all smbd's to delete an entry.
+**************************************************************************/
+
+void send_stat_cache_delete_message(const char *name)
+{
+	message_send_all(conn_tdb_ctx(),
+			MSG_SMB_STAT_CACHE_DELETE,
+			name,
+			strlen(name)+1,
+			True,
+			NULL);
+}
+
+/***************************************************************************
+ Delete an entry.
+**************************************************************************/
+
+void stat_cache_delete(const char *name)
+{
+	char *lname = strdup_upper(name);
+
+	if (!lname) {
+		return;
+	}
+	DEBUG(10,("stat_cache_delete: deleting name [%s] -> %s\n",
+			lname, name ));
+
+	tdb_delete_bystring(tdb_stat_cache, lname);
+	SAFE_FREE(lname);
+}
+
 /***************************************************************
  Compute a hash value based on a string key value.
  The function returns the bucket index number for the hashed key.
Index: smbd/server.c
===================================================================
--- smbd/server.c	(revision 20880)
+++ smbd/server.c	(working copy)
@@ -73,6 +73,18 @@
 }
 
 
+/*******************************************************************
+ Delete a statcache entry.
+ ********************************************************************/
+
+static void smb_stat_cache_delete(int msg_type, struct process_id src,
+			     void *buf, size_t len)
+{
+	const char *name = (const char *)buf;
+	DEBUG(10,("smb_stat_cache_delete: delete name %s\n", name));
+	stat_cache_delete(name);
+}
+
 /****************************************************************************
  Terminate signal.
 ****************************************************************************/
@@ -412,6 +424,7 @@
         message_register(MSG_SHUTDOWN, msg_exit_server);
         message_register(MSG_SMB_FILE_RENAME, msg_file_was_renamed);
 	message_register(MSG_SMB_CONF_UPDATED, smb_conf_updated); 
+	message_register(MSG_SMB_STAT_CACHE_DELETE, smb_stat_cache_delete);
 
 #ifdef DEVELOPER
 	message_register(MSG_SMB_INJECT_FAULT, msg_inject_fault); 
Index: smbd/filename.c
===================================================================
--- smbd/filename.c	(revision 20880)
+++ smbd/filename.c	(working copy)
@@ -462,6 +462,10 @@
 			}
 		} /* end else */
 
+		if (VALID_STAT(st) && get_delete_on_close_flag(st.st_dev, st.st_ino)) {
+			return NT_STATUS_DELETE_PENDING;
+		}
+
 		/* 
 		 * Add to the dirpath that we have resolved so far.
 		 */
Index: lib/dummysmbd.c
===================================================================
--- lib/dummysmbd.c	(revision 20880)
+++ lib/dummysmbd.c	(working copy)
@@ -53,3 +53,7 @@
 {
 	return NULL;
 }
+
+void send_stat_cache_delete_message(const char *name)
+{
+}
Index: include/messages.h
===================================================================
--- include/messages.h	(revision 20880)
+++ include/messages.h	(working copy)
@@ -71,6 +71,7 @@
 #define MSG_SMB_FILE_RENAME  3011
 #define MSG_SMB_INJECT_FAULT 3012
 #define MSG_SMB_BLOCKING_LOCK_CANCEL 3013
+#define MSG_SMB_STAT_CACHE_DELETE 3014
 
 /* winbind messages */
 #define MSG_WINBIND_FINISHED     4001
Index: locking/locking.c
===================================================================
--- locking/locking.c	(revision 20883)
+++ locking/locking.c	(working copy)
@@ -1281,6 +1281,10 @@
 
 	set_delete_on_close_lck(lck, delete_on_close, tok);
 
+	if (fsp->is_directory) {
+		send_stat_cache_delete_message(fsp->fsp_name);
+	}
+
 	TALLOC_FREE(lck);
 	return True;
 }


More information about the samba-technical mailing list