Samba 2.2.1a eating CPU

Jeremy Allison jra at samba.org
Fri Sep 14 13:47:02 GMT 2001


On Fri, Sep 14, 2001 at 08:30:54AM +0200, Magnus Larsson wrote:
> Hi!
> 
> I had the same problem. But when we disabled oplocks it have worked fine.
> Even if it's just a couple of days ago but before we disabled it we had to
> restart the deamon a couple of time a day.
> 
> //Mvh Magnus Larsson
> 
> Nätverksansvarig / IT-enheten	E-Mail: Magnus.Larsson at hig.se
> Högskolan i Gävle		Tel. 026 -  64 86 01
> Kungsbäcksvägen 47
> 801 76 Gävle
> 
> On Thu, 13 Sep 2001, Shekhar wrote:
> 
> > I had Samba 2.2.0-alpha3 working fine. Now I upgraded it to 2.2.1a. Now file
> > serving is considerably slow. And smbd processes are eating CPU.

This is a bug in 2.2.1a we fixed recently (a few days ago). We're working
on getting 2.2.2 out asap, so in the meantime here is a patch against 2.2.1a
which should fix the problem.

Cheers,

	Jeremy Allison,
	Samba Team.
-------------- next part --------------
--- smbd/process.c	Thu Jul  5 19:02:02 2001
+++ /export/home/jeremy/src/samba2.2/samba/source/smbd/process.c	Fri Sep 14 13:18:19 2001
@@ -207,6 +207,11 @@
 	   signals */
 	if (selrtn == -1 && errno == EINTR) {
 		async_processing(&fds, buffer, buffer_len);
+		/*
+		 * After async processing we must go and do the select again, as
+		 * the state of the flag in fds for the server file descriptor is
+		 * indeterminate - we may have done I/O on it in the oplock processing. JRA.
+		 */
 		goto again;
 	}
 
@@ -223,9 +228,21 @@
 		return False;
 	}
 
-	if (!FD_ISSET(smbd_server_fd(),&fds) || selrtn > 1) {
+	/*
+	 * Ensure we process oplock break messages by preference.
+	 * This is IMPORTANT ! Otherwise we can starve other processes
+	 * sending us an oplock break message. JRA.
+	 */
+
+	if (oplock_message_waiting(&fds)) {
+		DEBUG(10,("receive_message_or_smb: oplock_message is waiting.\n"));
 		async_processing(&fds, buffer, buffer_len);
-		if (!FD_ISSET(smbd_server_fd(),&fds)) goto again;
+		/*
+		 * After async processing we must go and do the select again, as
+		 * the state of the flag in fds for the server file descriptor is
+		 * indeterminate - we may have done I/O on it in the oplock processing. JRA.
+		 */
+		goto again;
 	}
 	
 	return receive_smb(smbd_server_fd(), buffer, 0);
--- smbd/oplock.c	Thu Jul  5 19:02:01 2001
+++ /export/home/jeremy/src/samba2.2/samba/source/smbd/oplock.c	Thu Sep  6 08:32:25 2001
@@ -48,6 +48,20 @@
   return exclusive_oplocks_open;
 }
 
+/****************************************************************************
+ Return True if an oplock message is pending.
+****************************************************************************/
+
+BOOL oplock_message_waiting(fd_set *fds)
+{
+	if (koplocks && koplocks->msg_waiting(fds))
+		return True;
+
+	if (FD_ISSET(oplock_sock, fds))
+		return True;
+
+	return False;
+}
 
 /****************************************************************************
  Read an oplock break message from either the oplock UDP fd or the
--- include/proto.h	Sun Jul  8 13:29:43 2001
+++ /export/home/jeremy/src/samba2.2/samba/source/include/proto.h	Wed Sep 12 12:10:58 2001
@@ -4086,6 +4165,7 @@
 /*The following definitions come from  smbd/oplock.c  */
 
 int32 get_number_of_exclusive_open_oplocks(void);
+BOOL oplock_message_waiting(fd_set *fds);
 BOOL receive_local_message(fd_set *fds, char *buffer, int buffer_len, int timeout);
 BOOL set_file_oplock(files_struct *fsp, int oplock_type);
 void release_file_oplock(files_struct *fsp);


More information about the samba-technical mailing list