svn commit: samba r2076 - in branches/SAMBA_3_0/source: include smbd

jra at samba.org jra at samba.org
Wed Aug 25 23:20:47 GMT 2004


Author: jra
Date: 2004-08-25 23:20:47 +0000 (Wed, 25 Aug 2004)
New Revision: 2076

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_3_0/source&rev=2076&nolog=1

Log:
Removed old dir caching code - not being used now we have the
statcache anyway. New dir caching will be done on nanosecond
timestamps.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/include/smb_macros.h
   branches/SAMBA_3_0/source/smbd/dir.c
   branches/SAMBA_3_0/source/smbd/filename.c
   branches/SAMBA_3_0/source/smbd/service.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/smb_macros.h
===================================================================
--- branches/SAMBA_3_0/source/include/smb_macros.h	2004-08-25 23:20:25 UTC (rev 2075)
+++ branches/SAMBA_3_0/source/include/smb_macros.h	2004-08-25 23:20:47 UTC (rev 2076)
@@ -26,7 +26,6 @@
 
 /* Misc bit macros */
 #define BOOLSTR(b) ((b) ? "Yes" : "No")
-#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
 
 /* for readability... */

Modified: branches/SAMBA_3_0/source/smbd/dir.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/dir.c	2004-08-25 23:20:25 UTC (rev 2075)
+++ branches/SAMBA_3_0/source/smbd/dir.c	2004-08-25 23:20:47 UTC (rev 2076)
@@ -986,112 +986,3 @@
   
 	return(dirp->pos);
 }
-
-/*******************************************************************************
- This section manages a global directory cache.
- (It should probably be split into a separate module.  crh)
-********************************************************************************/
-
-typedef struct {
-	ubi_dlNode node;
-	char *path;
-	char *name;
-	char *dname;
-	int snum;
-} dir_cache_entry;
-
-static ubi_dlNewList( dir_cache );
-
-/*****************************************************************************
- Add an entry to the directory cache.
- Input:  path  -
-         name  -
-         dname -
-         snum  -
- Output: None.
-*****************************************************************************/
-
-void DirCacheAdd( const char *path, const char *name, const char *dname, int snum )
-{
-	int pathlen;
-	int namelen;
-	dir_cache_entry  *entry;
-
-	/*
-	 * Allocate the structure & string space in one go so that it can be freed
-	 * in one call to free().
-	 */
-	pathlen = strlen(path) + 1;  /* Bytes required to store path (with nul). */
-	namelen = strlen(name) + 1;  /* Bytes required to store name (with nul). */
-	entry = (dir_cache_entry *)malloc( sizeof( dir_cache_entry )
-					+ pathlen
-					+ namelen
-					+ strlen( dname ) +1 );
-	if( NULL == entry )   /* Not adding to the cache is not fatal,  */
-		return;             /* so just return as if nothing happened. */
-
-	/* Set pointers correctly and load values. */
-	entry->path  = memcpy( (char *)&entry[1], path, strlen(path)+1 );
-	entry->name  = memcpy( &(entry->path[pathlen]), name, strlen(name)+1 );
-	entry->dname = memcpy( &(entry->name[namelen]), dname, strlen(dname)+1 );
-	entry->snum  = snum;
-
-	/* Add the new entry to the linked list. */
-	(void)ubi_dlAddHead( dir_cache, entry );
-	DEBUG( 4, ("Added dir cache entry %s %s -> %s\n", path, name, dname ) );
-
-	/* Free excess cache entries. */
-	while( DIRCACHESIZE < dir_cache->count )
-		safe_free( ubi_dlRemTail( dir_cache ) );
-}
-
-/*****************************************************************************
- Search for an entry to the directory cache.
- Input:  path  -
-         name  -
-         snum  -
- Output: The dname string of the located entry, or NULL if the entry was
-         not found.
-
- Notes:  This uses a linear search, which is is okay because of
-         the small size of the cache.  Use a splay tree or hash
-         for large caches.
-*****************************************************************************/
-
-char *DirCacheCheck( const char *path, const char *name, int snum )
-{
-	dir_cache_entry *entry;
-
-	for( entry = (dir_cache_entry *)ubi_dlFirst( dir_cache );
-			NULL != entry;
-			entry = (dir_cache_entry *)ubi_dlNext( entry ) ) {
-		if( entry->snum == snum
-				&& entry->name && 0 == strcmp( name, entry->name )
-				&& entry->path && 0 == strcmp( path, entry->path ) ) {
-			DEBUG(4, ("Got dir cache hit on %s %s -> %s\n",path,name,entry->dname));
-			return( entry->dname );
-		}
-	}
-
-	return(NULL);
-}
-
-/*****************************************************************************
- Remove all cache entries which have an snum that matches the input.
- Input:  snum  -
- Output: None.
-*****************************************************************************/
-
-void DirCacheFlush(int snum)
-{
-	dir_cache_entry *entry;
-	ubi_dlNodePtr    next;
-
-	for(entry = (dir_cache_entry *)ubi_dlFirst( dir_cache ); 
-	    NULL != entry; )  {
-		next = ubi_dlNext( entry );
-		if( entry->snum == snum )
-			safe_free( ubi_dlRemThis( dir_cache, entry ) );
-		entry = (dir_cache_entry *)next;
-	}
-}

Modified: branches/SAMBA_3_0/source/smbd/filename.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/filename.c	2004-08-25 23:20:25 UTC (rev 2075)
+++ branches/SAMBA_3_0/source/smbd/filename.c	2004-08-25 23:20:47 UTC (rev 2076)
@@ -26,8 +26,7 @@
 
 #include "includes.h"
 
-static BOOL scan_directory(const char *path, char *name,size_t maxlength,
-			   connection_struct *conn,BOOL docache);
+static BOOL scan_directory(connection_struct *conn, const char *path, char *name,size_t maxlength);
 
 /****************************************************************************
  Check if two filenames are equal.
@@ -282,10 +281,7 @@
 			 */
 
 			if (ms_has_wild(start) || 
-			    !scan_directory(dirpath, start, 
-					    sizeof(pstring) - 1 - (start - name), 
-					    conn, 
-					    end?True:False)) {
+			    !scan_directory(conn, dirpath, start, sizeof(pstring) - 1 - (start - name))) {
 				if (end) {
 					/*
 					 * An intermediate part of the name can't be found.
@@ -450,8 +446,7 @@
  If the name looks like a mangled name then try via the mangling functions
 ****************************************************************************/
 
-static BOOL scan_directory(const char *path, char *name, size_t maxlength, 
-			   connection_struct *conn,BOOL docache)
+static BOOL scan_directory(connection_struct *conn, const char *path, char *name, size_t maxlength)
 {
 	void *cur_dir;
 	const char *dname;
@@ -463,11 +458,6 @@
 	if (*path == 0)
 		path = ".";
 
-	if (docache && (dname = DirCacheCheck(path,name,SNUM(conn)))) {
-		safe_strcpy(name, dname, maxlength);	
-		return(True);
-	}      
-
 	/*
 	 * The incoming name can be mangled, and if we de-mangle it
 	 * here it will not compare correctly against the filename (name2)
@@ -505,8 +495,6 @@
 
 		if ((mangled && mangled_equal(name,dname,SNUM(conn))) || fname_equal(name, dname, conn->case_sensitive)) {
 			/* we've found the file, change it's name and return */
-			if (docache)
-				DirCacheAdd(path,name,dname,SNUM(conn));
 			safe_strcpy(name, dname, maxlength);
 			CloseDir(cur_dir);
 			return(True);

Modified: branches/SAMBA_3_0/source/smbd/service.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/service.c	2004-08-25 23:20:25 UTC (rev 2075)
+++ branches/SAMBA_3_0/source/smbd/service.c	2004-08-25 23:20:47 UTC (rev 2076)
@@ -821,8 +821,6 @@
 ****************************************************************************/
 void close_cnum(connection_struct *conn, uint16 vuid)
 {
-	DirCacheFlush(SNUM(conn));
-
 	if (IS_IPC(conn)) {
 		pipe_close_conn(conn);
 	} else {



More information about the samba-cvs mailing list