[linux-cifs-client] Re: Bug in cifsfs POSIX locking client code.

Jeremy Allison jra at samba.org
Wed Jul 12 22:38:46 GMT 2006


On Wed, Jul 12, 2006 at 12:13:53AM -0700, Jeremy Allison wrote:
> Ok, here are a couple of patches for cifsfs.
> 
> The first one ensures you don't select POSIX FCNTL locks
> unless experimental is on - otherwise you select them (and
> the smbd server is in a state where it expects them) and
> then you don't send them if "experimental" isn't turned on.
> 
> The second patch is to add timeout values to the set
> posix fcntl lock call. It sets this in the same way as
> you do for the Windows lockingX call. Unfortunately it
> doesn't seem to make a difference. The client still seems
> to be arbitrarily disconnecting from the server (I'm getting
> 
> read_data: read of 4 returned 0. Error = Success
> receive_smb_raw: length < 0!
> timeout_processing: End of file from client (client has disconnected).
> 
> messages in my logs over loopback which means the client
> is disconnecting and I don't know why).
> 
> I'm guessing the waiting for blocking calls still isn't
> working correctly....
> 
> I'm quite confident of the posix locking code in the server -
> it's passing all of the userspace tests I can throw at it,
> and I think it's quite robust. We need to get cifsfs the
> same for blocking calls I think.

I forgot to add the patches. Doh ! Here they are...

Jeremy.
-------------- next part --------------
--- connect.c.orig	2006-07-11 23:42:59.000000000 -0700
+++ connect.c	2006-07-11 23:45:06.000000000 -0700
@@ -2023,6 +2023,13 @@
 					cifs_sb->mnt_cifs_flags |= 
 						CIFS_MOUNT_POSIX_PATHS;
 				}
+
+				if (experimEnabled & (cap & CIFS_UNIX_FCNTL_CAP)) {
+					cFYI(1,("negotiate posix fcntl locking"));
+				} else {
+					cFYI(1,("posix fcntl locking not supported"));
+					cap &= ~CIFS_UNIX_FCNTL_CAP;
+				}
 					
 				cFYI(1,("Negotiate caps 0x%x",(int)cap));
 
-------------- next part --------------
--- cifssmb.c.orig	2006-07-11 22:23:34.000000000 -0700
+++ cifssmb.c	2006-07-11 22:23:36.000000000 -0700
@@ -1373,6 +1373,7 @@
 	struct cifs_posix_lock *parm_data;
 	int rc = 0;
 	int bytes_returned = 0;
+	int timeout = 0;
 	__u16 params, param_offset, offset, byte_count, count;
 
 	cFYI(1, ("Posix Lock"));
@@ -1413,8 +1414,10 @@
 			(((char *) &pSMB->hdr.Protocol) + offset);
 
 	parm_data->lock_type = cpu_to_le16(lock_type);
-	if(waitFlag)
+	if(waitFlag) {
+		timeout = 3;  /* blocking operation, no timeout */
 		parm_data->lock_flags = 1;
+	}
 	parm_data->pid = cpu_to_le32(current->tgid);
 	parm_data->start = lkoffset;
 	parm_data->length = len;  /* normalize negative numbers */
@@ -1426,7 +1429,7 @@
 	pSMB->hdr.smb_buf_length += byte_count;
 	pSMB->ByteCount = cpu_to_le16(byte_count);
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
-			(struct smb_hdr *) pSMBr, &bytes_returned, 0);
+			(struct smb_hdr *) pSMBr, &bytes_returned, timeout);
 	if (rc) {
 		cFYI(1, ("Send error in Posix Lock = %d", rc));
 	}


More information about the linux-cifs-client mailing list