svn commit: samba r16931 - in trunk/source: include locking smbd

jra at samba.org jra at samba.org
Tue Jul 11 00:24:31 GMT 2006


Author: jra
Date: 2006-07-11 00:24:29 +0000 (Tue, 11 Jul 2006)
New Revision: 16931

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16931

Log:
Change the underlying lock db to use 32-bit PIDs
not 16. This allows POSIX locks to be more easily
used. Get rid of one more use of a global variable,
global_smbpid. We can get rid of this if we remove
its use in smbd/open.c
Jeremy.

Modified:
   trunk/source/include/locking.h
   trunk/source/locking/brlock.c
   trunk/source/locking/locking.c
   trunk/source/smbd/blocking.c
   trunk/source/smbd/process.c
   trunk/source/smbd/reply.c
   trunk/source/smbd/trans2.c


Changeset:
Modified: trunk/source/include/locking.h
===================================================================
--- trunk/source/include/locking.h	2006-07-10 23:54:00 UTC (rev 16930)
+++ trunk/source/include/locking.h	2006-07-11 00:24:29 UTC (rev 16931)
@@ -33,9 +33,9 @@
    this client */
 
 struct lock_context {
-        uint16 smbpid;
-        uint16 tid;
-        struct process_id pid;
+	uint32 smbpid;
+	uint16 tid;
+	struct process_id pid;
 };
 
 /* The key used in the brlock database. */

Modified: trunk/source/locking/brlock.c
===================================================================
--- trunk/source/locking/brlock.c	2006-07-10 23:54:00 UTC (rev 16930)
+++ trunk/source/locking/brlock.c	2006-07-11 00:24:29 UTC (rev 16931)
@@ -676,7 +676,7 @@
 ****************************************************************************/
 
 NTSTATUS brl_lock(struct byte_range_lock *br_lck,
-		uint16 smbpid,
+		uint32 smbpid,
 		struct process_id pid,
 		br_off start,
 		br_off size, 
@@ -1012,7 +1012,7 @@
 ****************************************************************************/
 
 BOOL brl_unlock(struct byte_range_lock *br_lck,
-		uint16 smbpid,
+		uint32 smbpid,
 		struct process_id pid,
 		br_off start,
 		br_off size,
@@ -1042,7 +1042,7 @@
 ****************************************************************************/
 
 BOOL brl_locktest(struct byte_range_lock *br_lck,
-		uint16 smbpid,
+		uint32 smbpid,
 		struct process_id pid,
 		br_off start,
 		br_off size, 
@@ -1100,7 +1100,7 @@
 ****************************************************************************/
 
 NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
-		uint16 *psmbpid,
+		uint32 *psmbpid,
 		struct process_id pid,
 		br_off *pstart,
 		br_off *psize, 
@@ -1169,7 +1169,7 @@
 ****************************************************************************/
 
 BOOL brl_remove_pending_lock(struct byte_range_lock *br_lck,
-		uint16 smbpid,
+		uint32 smbpid,
 		struct process_id pid,
 		br_off start,
 		br_off size,

Modified: trunk/source/locking/locking.c
===================================================================
--- trunk/source/locking/locking.c	2006-07-10 23:54:00 UTC (rev 16930)
+++ trunk/source/locking/locking.c	2006-07-11 00:24:29 UTC (rev 16931)
@@ -37,7 +37,6 @@
 */
 
 #include "includes.h"
-uint16 global_smbpid;
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_LOCKING
@@ -74,6 +73,7 @@
 ****************************************************************************/
 
 BOOL is_locked(files_struct *fsp,
+		uint32 smbpid,
 		SMB_BIG_UINT count,
 		SMB_BIG_UINT offset, 
 		enum brl_type lock_type)
@@ -105,7 +105,7 @@
 				return False;
 			}
 			ret = !brl_locktest(br_lck,
-					global_smbpid,
+					smbpid,
 					procid_self(),
 					offset,
 					count,
@@ -119,7 +119,7 @@
 			return False;
 		}
 		ret = !brl_locktest(br_lck,
-				global_smbpid,
+				smbpid,
 				procid_self(),
 				offset,
 				count,
@@ -141,7 +141,7 @@
 ****************************************************************************/
 
 NTSTATUS query_lock(files_struct *fsp,
-			uint16 *psmbpid,
+			uint32 *psmbpid,
 			SMB_BIG_UINT *pcount,
 			SMB_BIG_UINT *poffset,
 			enum brl_type *plock_type,
@@ -180,7 +180,7 @@
 ****************************************************************************/
 
 NTSTATUS do_lock(files_struct *fsp,
-			uint16 lock_pid,
+			uint32 lock_pid,
 			SMB_BIG_UINT count,
 			SMB_BIG_UINT offset,
 			enum brl_type lock_type,
@@ -230,7 +230,7 @@
 ****************************************************************************/
 
 NTSTATUS do_lock_spin(files_struct *fsp,
-			uint16 lock_pid,
+			uint32 lock_pid,
 			SMB_BIG_UINT count,
 			SMB_BIG_UINT offset,
 			enum brl_type lock_type,
@@ -286,7 +286,7 @@
 ****************************************************************************/
 
 NTSTATUS do_unlock(files_struct *fsp,
-			uint16 lock_pid,
+			uint32 lock_pid,
 			SMB_BIG_UINT count,
 			SMB_BIG_UINT offset,
 			enum brl_flavour lock_flav)

Modified: trunk/source/smbd/blocking.c
===================================================================
--- trunk/source/smbd/blocking.c	2006-07-10 23:54:00 UTC (rev 16930)
+++ trunk/source/smbd/blocking.c	2006-07-11 00:24:29 UTC (rev 16931)
@@ -34,7 +34,7 @@
 	int lock_num;
 	SMB_BIG_UINT offset;
 	SMB_BIG_UINT count;
-	uint16 lock_pid;
+	uint32 lock_pid;
 	enum brl_flavour lock_flav;
 	enum brl_type lock_type;
 	char *inbuf;
@@ -74,7 +74,7 @@
 		files_struct *fsp,
 		int lock_timeout,
 		int lock_num,
-		uint16 lock_pid,
+		uint32 lock_pid,
 		enum brl_type lock_type,
 		enum brl_flavour lock_flav,
 		SMB_BIG_UINT offset, SMB_BIG_UINT count)
@@ -236,7 +236,7 @@
 	files_struct *fsp = blr->fsp;
 	uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
 	SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT) 0;
-	uint16 lock_pid;
+	uint32 lock_pid;
 	unsigned char locktype = CVAL(inbuf,smb_vwv3);
 	BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
 	char *data;
@@ -344,7 +344,7 @@
 	data = smb_buf(outbuf) + 3;
  
 	status = do_lock_spin(fsp,
-				SVAL(inbuf,smb_pid),
+				(uint32)SVAL(inbuf,smb_pid),
 				(SMB_BIG_UINT)numtoread,
 				startpos,
 				READ_LOCK,
@@ -417,7 +417,7 @@
 
 	errno = 0;
 	status = do_lock_spin(fsp,
-				SVAL(inbuf,smb_pid),
+				(uint32)SVAL(inbuf,smb_pid),
 				count,
 				offset,
 				WRITE_LOCK,
@@ -471,7 +471,7 @@
 	uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
 	uint16 num_locks = SVAL(inbuf,smb_vwv7);
 	SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT)0;
-	uint16 lock_pid;
+	uint32 lock_pid;
 	BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
 	char *data;
 	BOOL my_lock_ctx = False;

Modified: trunk/source/smbd/process.c
===================================================================
--- trunk/source/smbd/process.c	2006-07-10 23:54:00 UTC (rev 16930)
+++ trunk/source/smbd/process.c	2006-07-11 00:24:29 UTC (rev 16931)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 
-extern uint16 global_smbpid;
+uint16 global_smbpid;
 extern int keepalive;
 extern struct auth_context *negprot_global_auth_context;
 extern int smb_echo_count;

Modified: trunk/source/smbd/reply.c
===================================================================
--- trunk/source/smbd/reply.c	2006-07-10 23:54:00 UTC (rev 16930)
+++ trunk/source/smbd/reply.c	2006-07-11 00:24:29 UTC (rev 16931)
@@ -2325,7 +2325,7 @@
 	/* ensure we don't overrun the packet size */
 	maxcount = MIN(65535,maxcount);
 
-	if (!is_locked(fsp,(SMB_BIG_UINT)maxcount,(SMB_BIG_UINT)startpos, READ_LOCK)) {
+	if (!is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)maxcount,(SMB_BIG_UINT)startpos, READ_LOCK)) {
 		SMB_STRUCT_STAT st;
 		SMB_OFF_T size = 0;
   
@@ -2397,7 +2397,7 @@
 	 */
 	
 	status = do_lock_spin(fsp,
-				SVAL(inbuf,smb_pid), 
+				(uint32)SVAL(inbuf,smb_pid), 
 				(SMB_BIG_UINT)numtoread,
 				(SMB_BIG_UINT)startpos,
 				WRITE_LOCK,
@@ -2504,7 +2504,7 @@
 
 	data = smb_buf(outbuf) + 3;
   
-	if (is_locked(fsp,(SMB_BIG_UINT)numtoread,(SMB_BIG_UINT)startpos, READ_LOCK)) {
+	if (is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)numtoread,(SMB_BIG_UINT)startpos, READ_LOCK)) {
 		END_PROFILE(SMBread);
 		return ERROR_DOS(ERRDOS,ERRlock);
 	}
@@ -2711,7 +2711,7 @@
 
 	}
 
-	if (is_locked(fsp,(SMB_BIG_UINT)smb_maxcnt,(SMB_BIG_UINT)startpos, READ_LOCK)) {
+	if (is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)smb_maxcnt,(SMB_BIG_UINT)startpos, READ_LOCK)) {
 		END_PROFILE(SMBreadX);
 		return ERROR_DOS(ERRDOS,ERRlock);
 	}
@@ -2774,7 +2774,7 @@
 	SCVAL(inbuf,smb_com,SMBwritec);
 	SCVAL(outbuf,smb_com,SMBwritec);
 
-	if (is_locked(fsp,(SMB_BIG_UINT)tcount,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+	if (is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)tcount,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
 		END_PROFILE(SMBwritebraw);
 		return(ERROR_DOS(ERRDOS,ERRlock));
 	}
@@ -2895,7 +2895,7 @@
 	startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2);
 	data = smb_buf(inbuf) + 3;
   
-	if (numtowrite && is_locked(fsp,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+	if (numtowrite && is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
 		END_PROFILE(SMBwriteunlock);
 		return ERROR_DOS(ERRDOS,ERRlock);
 	}
@@ -2918,7 +2918,7 @@
 
 	if (numtowrite) {
 		status = do_unlock(fsp,
-				SVAL(inbuf,smb_pid),
+				(uint32)SVAL(inbuf,smb_pid),
 				(SMB_BIG_UINT)numtowrite, 
 				(SMB_BIG_UINT)startpos,
 				WINDOWS_LOCK);
@@ -2972,7 +2972,7 @@
 	startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2);
 	data = smb_buf(inbuf) + 3;
   
-	if (is_locked(fsp,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+	if (is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
 		END_PROFILE(SMBwrite);
 		return ERROR_DOS(ERRDOS,ERRlock);
 	}
@@ -3087,7 +3087,7 @@
 #endif /* LARGE_SMB_OFF_T */
 	}
 
-	if (is_locked(fsp,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+	if (is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
 		END_PROFILE(SMBwriteX);
 		return ERROR_DOS(ERRDOS,ERRlock);
 	}
@@ -3362,7 +3362,7 @@
 	mtime = srv_make_unix_date3(inbuf+smb_vwv4);
 	data = smb_buf(inbuf) + 1;
   
-	if (numtowrite && is_locked(fsp,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+	if (numtowrite && is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
 		END_PROFILE(SMBwriteclose);
 		return ERROR_DOS(ERRDOS,ERRlock);
 	}
@@ -3433,7 +3433,7 @@
 		 fsp->fh->fd, fsp->fnum, (double)offset, (double)count));
 
 	status = do_lock_spin(fsp,
-				SVAL(inbuf,smb_pid),
+				(uint32)SVAL(inbuf,smb_pid),
 				count,
 				offset,
 				WRITE_LOCK,
@@ -3488,7 +3488,7 @@
 	offset = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv3);
 	
 	status = do_unlock(fsp,
-			SVAL(inbuf,smb_pid),
+			(uint32)SVAL(inbuf,smb_pid),
 			count,
 			offset,
 			WINDOWS_LOCK);
@@ -5079,12 +5079,12 @@
  Get a lock pid, dealing with large count requests.
 ****************************************************************************/
 
-uint16 get_lock_pid( char *data, int data_offset, BOOL large_file_format)
+uint32 get_lock_pid( char *data, int data_offset, BOOL large_file_format)
 {
 	if(!large_file_format)
-		return SVAL(data,SMB_LPID_OFFSET(data_offset));
+		return (uint32)SVAL(data,SMB_LPID_OFFSET(data_offset));
 	else
-		return SVAL(data,SMB_LARGE_LPID_OFFSET(data_offset));
+		return (uint32)SVAL(data,SMB_LARGE_LPID_OFFSET(data_offset));
 }
 
 /****************************************************************************
@@ -5221,7 +5221,7 @@
 	uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
 	uint16 num_locks = SVAL(inbuf,smb_vwv7);
 	SMB_BIG_UINT count = 0, offset = 0;
-	uint16 lock_pid;
+	uint32 lock_pid;
 	int32 lock_timeout = IVAL(inbuf,smb_vwv4);
 	int i;
 	char *data;
@@ -5517,7 +5517,7 @@
 	tcount = maxcount;
 	total_read = 0;
 
-	if (is_locked(fsp,(SMB_BIG_UINT)maxcount,(SMB_BIG_UINT)startpos, READ_LOCK)) {
+	if (is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)maxcount,(SMB_BIG_UINT)startpos, READ_LOCK)) {
 		END_PROFILE(SMBreadBmpx);
 		return ERROR_DOS(ERRDOS,ERRlock);
 	}
@@ -5649,7 +5649,7 @@
 		not an SMBwritebmpx - set this up now so we don't forget */
 	SCVAL(outbuf,smb_com,SMBwritec);
 
-	if (is_locked(fsp,(SMB_BIG_UINT)tcount,(SMB_BIG_UINT)startpos,WRITE_LOCK)) {
+	if (is_locked(fsp,(uint32)SVAL(inbuf,smb_pid),(SMB_BIG_UINT)tcount,(SMB_BIG_UINT)startpos,WRITE_LOCK)) {
 		END_PROFILE(SMBwriteBmpx);
 		return(ERROR_DOS(ERRDOS,ERRlock));
 	}

Modified: trunk/source/smbd/trans2.c
===================================================================
--- trunk/source/smbd/trans2.c	2006-07-10 23:54:00 UTC (rev 16930)
+++ trunk/source/smbd/trans2.c	2006-07-11 00:24:29 UTC (rev 16931)
@@ -3566,7 +3566,7 @@
 			NTSTATUS status = NT_STATUS_INVALID_LEVEL;
 			SMB_BIG_UINT count;
 			SMB_BIG_UINT offset;
-			uint16 lock_pid;
+			uint32 lock_pid;
 			enum brl_type lock_type;
 
 			if (total_data != POSIX_LOCK_DATA_SIZE) {
@@ -3587,7 +3587,7 @@
 					return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 			}
 
-			lock_pid = (uint16)IVAL(pdata, POSIX_LOCK_PID_OFFSET);
+			lock_pid = IVAL(pdata, POSIX_LOCK_PID_OFFSET);
 #if defined(HAVE_LONGLONG)
 			offset = (((SMB_BIG_UINT) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) |
 					((SMB_BIG_UINT) IVAL(pdata,POSIX_LOCK_START_OFFSET));
@@ -4511,7 +4511,7 @@
 		{
 			SMB_BIG_UINT count;
 			SMB_BIG_UINT offset;
-			uint16 lock_pid;
+			uint32 lock_pid;
 			BOOL lock_blocking;
 			enum brl_type lock_type;
 			BOOL my_lock_ctx;
@@ -4550,7 +4550,7 @@
 				return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 			}
 
-			lock_pid = (uint16)IVAL(pdata, POSIX_LOCK_PID_OFFSET);
+			lock_pid = IVAL(pdata, POSIX_LOCK_PID_OFFSET);
 #if defined(HAVE_LONGLONG)
 			offset = (((SMB_BIG_UINT) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) |
 					((SMB_BIG_UINT) IVAL(pdata,POSIX_LOCK_START_OFFSET));



More information about the samba-cvs mailing list