load goes up with 3.0.7

Heinrich Mislik Heinrich.Mislik at univie.ac.at
Tue Oct 12 16:33:10 GMT 2004


Hi,

after installing 3.0.7 the load was considerably higher then before. 
I think one reason is the use of realpath in reduce_name. realpath 
needs getwd for a relative path, which can be expensive, when it 
encounters large directories. Attached is a patch, that always passes 
absolut pathes to realpath. It does so by calling vfs_GetWd and 
prepending the result. vfs_GetWd does caching and is much faster then 
calling getwd every time. 

I did some testing and found that it works, but don't dare to put it 
into production. Can someone who has more insight comment on this?

Thanks

Heinrich Mislik

-- 
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140

-------------- next part --------------
*** vfs.c.orig	Sun Sep 12 05:47:16 2004
--- vfs.c	Tue Oct 12 16:55:38 2004
***************
*** 830,842 ****
  	size_t con_path_len = strlen(conn->connectpath);
  	char *p = NULL;
  	int saved_errno = errno;
! 
  	DEBUG(3,("reduce_name [%s] [%s]\n", fname, conn->connectpath));
  
  #ifdef REALPATH_TAKES_NULL
! 	resolved_name = SMB_VFS_REALPATH(conn,fname,NULL);
  #else
! 	resolved_name = SMB_VFS_REALPATH(conn,fname,resolved_name_buf);
  #endif
  
  	if (!resolved_name) {
--- 830,847 ----
  	size_t con_path_len = strlen(conn->connectpath);
  	char *p = NULL;
  	int saved_errno = errno;
!     pstring full_name;
  	DEBUG(3,("reduce_name [%s] [%s]\n", fname, conn->connectpath));
  
+     if(*fname == '/')
+         pstrcpy(full_name,fname);
+     else
+         pstrcat(pstrcat(vfs_GetWd(conn,full_name),"/"),fname);
+ 
  #ifdef REALPATH_TAKES_NULL
! 	resolved_name = SMB_VFS_REALPATH(conn,full_name,NULL);
  #else
! 	resolved_name = SMB_VFS_REALPATH(conn,full_name,resolved_name_buf);
  #endif
  
  	if (!resolved_name) {
***************
*** 860,870 ****
  					fstrcpy(last_component, tmp_fname);
  					pstrcpy(tmp_fname, ".");
  				}
  
  #ifdef REALPATH_TAKES_NULL
! 				resolved_name = SMB_VFS_REALPATH(conn,tmp_fname,NULL);
  #else
! 				resolved_name = SMB_VFS_REALPATH(conn,tmp_fname,resolved_name_buf);
  #endif
  				if (!resolved_name) {
  					DEBUG(3,("reduce_name: couldn't get realpath for %s\n", fname));
--- 865,879 ----
  					fstrcpy(last_component, tmp_fname);
  					pstrcpy(tmp_fname, ".");
  				}
+                 if(*tmp_fname == '/')
+                     pstrcpy(full_name,tmp_fname);
+                 else
+                     pstrcat(pstrcat(vfs_GetWd(conn,full_name),"/"),tmp_fname);
  
  #ifdef REALPATH_TAKES_NULL
! 				resolved_name = SMB_VFS_REALPATH(conn,full_name,NULL);
  #else
! 				resolved_name = SMB_VFS_REALPATH(conn,full_name,resolved_name_buf);
  #endif
  				if (!resolved_name) {
  					DEBUG(3,("reduce_name: couldn't get realpath for %s\n", fname));
***************
*** 936,942 ****
          }
  #endif
  
! 	DEBUG(3,("reduce_name: %s reduced to %s\n", fname, p));
  	if (free_resolved_name)
  		SAFE_FREE(resolved_name);
  	errno = saved_errno;
--- 945,951 ----
          }
  #endif
  
! 	DEBUG(3,("reduce_name: %s reduced to %s\n", fname, resolved_name));
  	if (free_resolved_name)
  		SAFE_FREE(resolved_name);
  	errno = saved_errno;


More information about the samba-technical mailing list