[Samba] PATCH: Performance improvement for parameterised include path names

Jonathan Knight jonathan at cs.keele.ac.uk
Tue Jul 9 08:12:02 GMT 2002

I posted last week regarding a bug in the way that smb was re-reading
our config files every 60 seconds even though the files were not

As a result we had 396 smbd processes trying to read three files at the
same moment with the obvious load average.

The reason that all the smbd's were running at the same moment is
because the smbd's read the config files every 60 seconds exactly.  If
something like "pkill -HUP smbd" as is done by the redhat init script
when told to reload the samba processes then all the smbd's are running
their timers exactly in sync.

I would suggest that as an improvement the initial time before checking
the config files should be randomised as 60 seconds plus a random number
from 0-60 which would keep the smbd's seperate.

The bug that caused the config files to be read in the first place is in
the way that the include parameter is read.  The following lines can be
seen from a debug=6 log output.

[2002/07/08 13:00:51, 6] param/loadparm.c:lp_file_list_changed(2213)
  file /etc/samba/conf/printers/smb.printers.admin.conf ->
/etc/samba/conf/printers/smb.printers.admin.conf  last mod_time: Thu Jun
20 11:49:08 2002
  file /etc/samba/conf/smb.%h.conf -> /etc/samba/conf/smb.bumble.conf 
last mod_time: Thu Jan  1 01:00:00 1970
  file /etc/samba/conf/smb.bumble.conf modified: Wed Jul  3 11:54:26
The obvious mistake is that the smb.%h.conf (or smb.bumble.conf as it
was decoded) has a date stored as zero in the config file structure. 
Obviously "add_to_file_list()" in loadparm.c got the wrong filename when
it tried to find the modification time.

A check on the handle_include() function shows that the %h is not
decoded until after the add_to_file_list() is  called.  The following
patch swaps the order, fixes the bug and makes a massive difference to
the loading on our servers.

Could someone let me know when this patch makes it into a release so I
know when to stop hacking our local copy.

--- samba-2.2.3a/source/param/loadparm-2.2.3a.c	Tue Jul  9 13:50:53 2002
+++ samba-2.2.3a/source/param/loadparm.c	Tue Jul  9 13:52:40 2002
@@ -2454,10 +2454,10 @@
 	pstring fname;
 	pstrcpy(fname, pszParmValue);
-	add_to_file_list(pszParmValue, fname);
+	add_to_file_list(pszParmValue, fname);
 	string_set(ptr, fname);
 	if (file_exist(fname, NULL))

  ______    jonathan at cs.keele.ac.uk    Jonathan Knight,
    /                                  Department of Computer Science
   / _   __ Telephone: +44 1782 583437 University of Keele, Keele,
(_/ (_) / / Fax      : +44 1782 713082 Staffordshire.  ST5 5BG.  U.K.

More information about the samba mailing list