Disappearing Mounts

Urban Widmark urban at teststation.com
Tue Jan 9 01:28:23 GMT 2001

On Tue, 9 Jan 2001, Grant wrote:

> It does re-connect if you're just in time before the mount process
> dies. Otherwise it will say network I/O error or something...

Are you sure it reconnects at all then? When it reconnects you get a
message in the kernel log.

> > + What programs do you run on smbfs?
> What do you mean? What other daemons I have running?

No, just asking what you are using smbfs for. Some programs will cause
failures because of a signal related bug. Running strace/gdb on something
that accesses smbfs will cause problems, a crashing mozilla run over smbfs
used to (not sure if that still applies).

If all you are doing is 'cp somefile /mnt/smb/somepath' then it's probably
not related to the program.

Maybe you have found a new and exciting way of crashing things. It may be
a clue to something, that is all.

> > + What (relevant) log messages do you get in your kernel logs?
> I haven't had the errors for a while since I put in the cronjobs.

Right. But before that? If necessary to find them, could you please remove
the workaround?

(wonder if that could be done in some other way, like having smbmount
 do a stat of the mountpoint every minute. No files modified, possibly no 

> > + When it disconnects (stops working?), is the smbmount (mount.smbfs)
> >   program still alive?
> Sometimes it is, damn I wish I could be more specific. Sometimes it is
> but it will stop working. When it does the Input output error, I have
> to umount the mount and then re-mount it again. So it stays mounted
> even though it's not working.

Yes, smbmount doesn't unmount if it crashes. The question is really, did
smbmount crash and then did the reconnect signal come or the other way
around or did smbmount not crash at all. Sometimes is a valid answer, but
please check again. When you get an I/O error, do 'ps -efw | grep smb' and
see if the process is running.

> > + Does it go away if you apply the additional patch vs 2.2.18 posted
> >   earlier in this thread (let me know if you want a copy).
> I'd like this patch please, I could give it a shot. I have the latest
> kernel and latest samba, so I'm 99.9% sure this happens to everybody
> else who trys to mount Microsoft shares onto Linux.


There is also a patch for smbmount that allows it to log things even when
it runs as a daemon. That plus some additional debug logging could be used
later to see what is going on. But try the 2.2.18 patch first.

It does not happen to everybody, if it did it would have been fixed.
It probably happens to everybody that does what you are doing.
(whatever that may be)

-------------- next part --------------
--- linux-2.2.18-orig/fs/smbfs/sock.c	Wed Dec 13 21:27:44 2000
+++ linux/fs/smbfs/sock.c	Tue Jan  2 21:19:03 2001
@@ -30,11 +30,13 @@
 static int
 _recvfrom(struct socket *socket, unsigned char *ubuf, int size,
-	  unsigned flags)
+	  unsigned rflags)
 	struct iovec iov;
 	struct msghdr msg;
 	struct scm_cookie scm;
+	sigset_t old_set;
+	unsigned long flags;
 	msg.msg_name = NULL;
 	msg.msg_namelen = 0;
@@ -43,11 +45,33 @@
 	msg.msg_control = NULL;
 	iov.iov_base = ubuf;
 	iov.iov_len = size;
 	memset(&scm, 0,sizeof(scm));
-	size=socket->ops->recvmsg(socket, &msg, size, flags, &scm);
-	if(size>=0)
-		scm_recv(socket,&msg,&scm,flags);
+	/*
+	 * block all signals to avoid -ERESTARTSYS problem in recvmsg
+	 *
+	 * FIXME: changing the signal mask is done elsewhere too.
+	 * This code removes the ability to SIGKILL a process that has hung in
+	 * recvmsg (does it? I'm guessing ...).
+	 * Use poll/timeout to ensure progress?
+	 */
+	spin_lock_irqsave(&current->sigmask_lock, flags);
+	old_set = current->blocked;
+	siginitsetinv(&current->blocked, 0);
+	recalc_sigpending(current);
+	spin_unlock_irqrestore(&current->sigmask_lock, flags);
+	size = socket->ops->recvmsg(socket, &msg, size, rflags, &scm);
+	if (size >= 0)
+		scm_recv(socket, &msg, &scm, rflags);
+	/* restore old signal mask */
+	spin_lock_irqsave(&current->sigmask_lock, flags);
+	current->blocked = old_set;
+	recalc_sigpending(current);
+	spin_unlock_irqrestore(&current->sigmask_lock, flags);
 	return size;
@@ -529,7 +553,7 @@
 				buf_len = server->packet_size;
 			buf_len = smb_round_length(buf_len);
 			if (buf_len > SMB_MAX_PACKET_SIZE)
-				goto out_no_mem;
+				goto out_too_long;
 			rcv_buf = smb_vmalloc(buf_len);
 			if (!rcv_buf)

More information about the samba mailing list