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 00:18:27 GMT 2007


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 :-).

Jeremy.
-------------- next part --------------
Index: smbd/close.c
===================================================================
--- smbd/close.c	(revision 20883)
+++ smbd/close.c	(working copy)
@@ -184,6 +184,7 @@
 			become_user(conn, fsp->vuid);
 			became_user = True;
 		}
+		stat_cache_delete(fsp->fsp_name);
 		set_delete_on_close_lck(lck, True, &current_user.ut);
 		if (became_user) {
 			unbecome_user();
@@ -431,6 +432,7 @@
 			become_user(fsp->conn, fsp->vuid);
 			became_user = True;
 		}
+		stat_cache_delete(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,20 @@
 	}
 }
 
+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/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: locking/locking.c
===================================================================
--- locking/locking.c	(revision 20883)
+++ locking/locking.c	(working copy)
@@ -1281,6 +1281,8 @@
 
 	set_delete_on_close_lck(lck, delete_on_close, tok);
 
+	stat_cache_delete(fsp->fsp_name);
+
 	TALLOC_FREE(lck);
 	return True;
 }


More information about the samba-technical mailing list