svn commit: samba r21724 - in branches: SAMBA_3_0/source/include SAMBA_3_0/source/locking SAMBA_3_0_25/source/include SAMBA_3_0_25/source/locking

jra at samba.org jra at samba.org
Tue Mar 6 21:59:52 GMT 2007


Author: jra
Date: 2007-03-06 21:59:51 +0000 (Tue, 06 Mar 2007)
New Revision: 21724

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

Log:
Optimization pointed out by Volker. If we don't
have any outstanding locks or blocking locks then
we don't need to read the lock db. on close.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/include/smb.h
   branches/SAMBA_3_0/source/locking/locking.c
   branches/SAMBA_3_0_25/source/include/smb.h
   branches/SAMBA_3_0_25/source/locking/locking.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/smb.h
===================================================================
--- branches/SAMBA_3_0/source/include/smb.h	2007-03-06 10:40:18 UTC (rev 21723)
+++ branches/SAMBA_3_0/source/include/smb.h	2007-03-06 21:59:51 UTC (rev 21724)
@@ -501,6 +501,7 @@
 	int sent_oplock_break;
 	struct timed_event *oplock_timeout;
 	struct lock_struct last_lock_failure;
+	int current_lock_count; /* Count the number of outstanding locks and pending locks. */
 
 	struct share_mode_entry *pending_break_messages;
 	int num_pending_break_messages;

Modified: branches/SAMBA_3_0/source/locking/locking.c
===================================================================
--- branches/SAMBA_3_0/source/locking/locking.c	2007-03-06 10:40:18 UTC (rev 21723)
+++ branches/SAMBA_3_0/source/locking/locking.c	2007-03-06 21:59:51 UTC (rev 21724)
@@ -222,6 +222,12 @@
 			lock_flav,
 			blocking_lock);
 
+	/* blocking ie. pending, locks also count here,
+	 * as this is an efficiency counter to avoid checking
+	 * the lock db. on close. JRA. */
+
+	fsp->current_lock_count++;
+
 	return br_lck;
 }
 
@@ -268,6 +274,9 @@
 		return NT_STATUS_RANGE_NOT_LOCKED;
 	}
 
+	SMB_ASSERT(fsp->current_lock_count > 0);
+	fsp->current_lock_count--;
+
 	return NT_STATUS_OK;
 }
 
@@ -315,6 +324,9 @@
 		return NT_STATUS_DOS(ERRDOS, ERRcancelviolation);
 	}
 
+	SMB_ASSERT(fsp->current_lock_count > 0);
+	fsp->current_lock_count++;
+
 	return NT_STATUS_OK;
 }
 
@@ -330,6 +342,14 @@
 		return;
 	}
 
+	/* If we have not outstanding locks or pending
+	 * locks then we don't need to look in the lock db.
+	 */
+
+	if (fsp->current_lock_count == 0) {
+		return;
+	}
+
 	br_lck = brl_get_locks(NULL,fsp);
 
 	if (br_lck) {

Modified: branches/SAMBA_3_0_25/source/include/smb.h
===================================================================
--- branches/SAMBA_3_0_25/source/include/smb.h	2007-03-06 10:40:18 UTC (rev 21723)
+++ branches/SAMBA_3_0_25/source/include/smb.h	2007-03-06 21:59:51 UTC (rev 21724)
@@ -506,6 +506,7 @@
 	int sent_oplock_break;
 	struct timed_event *oplock_timeout;
 	struct lock_struct last_lock_failure;
+	int current_lock_count; /* Count the number of outstanding locks and pending locks. */
 
 	struct share_mode_entry *pending_break_messages;
 	int num_pending_break_messages;

Modified: branches/SAMBA_3_0_25/source/locking/locking.c
===================================================================
--- branches/SAMBA_3_0_25/source/locking/locking.c	2007-03-06 10:40:18 UTC (rev 21723)
+++ branches/SAMBA_3_0_25/source/locking/locking.c	2007-03-06 21:59:51 UTC (rev 21724)
@@ -222,6 +222,12 @@
 			lock_flav,
 			blocking_lock);
 
+	/* blocking ie. pending, locks also count here,
+	 * as this is an efficiency counter to avoid checking
+	 * the lock db. on close. JRA. */
+
+	fsp->current_lock_count++;
+
 	return br_lck;
 }
 
@@ -268,6 +274,9 @@
 		return NT_STATUS_RANGE_NOT_LOCKED;
 	}
 
+	SMB_ASSERT(fsp->current_lock_count > 0);
+	fsp->current_lock_count--;
+
 	return NT_STATUS_OK;
 }
 
@@ -315,6 +324,9 @@
 		return NT_STATUS_DOS(ERRDOS, ERRcancelviolation);
 	}
 
+	SMB_ASSERT(fsp->current_lock_count > 0);
+	fsp->current_lock_count++;
+
 	return NT_STATUS_OK;
 }
 
@@ -330,6 +342,14 @@
 		return;
 	}
 
+	/* If we have not outstanding locks or pending
+	 * locks then we don't need to look in the lock db.
+	 */
+
+	if (fsp->current_lock_count == 0) {
+		return;
+	}
+
 	br_lck = brl_get_locks(NULL,fsp);
 
 	if (br_lck) {



More information about the samba-cvs mailing list