svn commit: samba r15060 - in branches/SAMBA_3_0/source: include
locking
jra at samba.org
jra at samba.org
Wed Apr 12 23:01:00 GMT 2006
Author: jra
Date: 2006-04-12 23:00:58 +0000 (Wed, 12 Apr 2006)
New Revision: 15060
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15060
Log:
The brlock code gets called a lot. Ensure we keep the
key around while we're using it - saves many calls to
locking_key() (now deleted).
Jeremy.
Modified:
branches/SAMBA_3_0/source/include/smb.h
branches/SAMBA_3_0/source/locking/brlock.c
Changeset:
Modified: branches/SAMBA_3_0/source/include/smb.h
===================================================================
--- branches/SAMBA_3_0/source/include/smb.h 2006-04-12 23:00:55 UTC (rev 15059)
+++ branches/SAMBA_3_0/source/include/smb.h 2006-04-12 23:00:58 UTC (rev 15060)
@@ -836,10 +836,18 @@
enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK, UNLOCK_LOCK};
enum brl_flavour {WINDOWS_LOCK = 0, POSIX_LOCK = 1};
+/* The key used in the brlock database. */
+
+struct lock_key {
+ SMB_DEV_T device;
+ SMB_INO_T inode;
+};
+
struct byte_range_lock {
files_struct *fsp;
unsigned int num_locks;
BOOL modified;
+ struct lock_key key;
void *lock_data;
};
Modified: branches/SAMBA_3_0/source/locking/brlock.c
===================================================================
--- branches/SAMBA_3_0/source/locking/brlock.c 2006-04-12 23:00:55 UTC (rev 15059)
+++ branches/SAMBA_3_0/source/locking/brlock.c 2006-04-12 23:00:58 UTC (rev 15060)
@@ -55,13 +55,6 @@
enum brl_flavour lock_flav;
};
-/* The key used in the brlock database. */
-
-struct lock_key {
- SMB_DEV_T device;
- SMB_INO_T inode;
-};
-
/* The open brlock.tdb database. */
static TDB_CONTEXT *tdb;
@@ -87,23 +80,6 @@
}
/****************************************************************************
- Create a locking key - ensuring zero filled for pad purposes.
-****************************************************************************/
-
-static TDB_DATA locking_key(SMB_DEV_T dev, SMB_INO_T inode)
-{
- static struct lock_key key;
- TDB_DATA kbuf;
-
- memset(&key, '\0', sizeof(key));
- key.device = dev;
- key.inode = inode;
- kbuf.dptr = (char *)&key;
- kbuf.dsize = sizeof(key);
- return kbuf;
-}
-
-/****************************************************************************
See if two locking contexts are equal.
****************************************************************************/
@@ -1332,8 +1308,11 @@
{
struct byte_range_lock *br_lck =
talloc_get_type_abort(p, struct byte_range_lock);
- TDB_DATA key = locking_key(br_lck->fsp->dev, br_lck->fsp->inode);
+ TDB_DATA key;
+ key.dptr = (char *)&br_lck->key;
+ key.dsize = sizeof(struct lock_key);
+
if (!br_lck->modified) {
goto done;
}
@@ -1355,8 +1334,8 @@
done:
- SAFE_FREE(br_lck->lock_data);
tdb_chainunlock(tdb, key);
+ SAFE_FREE(br_lck->lock_data);
return 0;
}
@@ -1368,11 +1347,10 @@
struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
files_struct *fsp)
{
- TDB_DATA key = locking_key(fsp->dev, fsp->inode);
+ TDB_DATA key;
TDB_DATA data;
- struct byte_range_lock *br_lck;
+ struct byte_range_lock *br_lck = TALLOC_P(mem_ctx, struct byte_range_lock);
- br_lck = TALLOC_P(mem_ctx, struct byte_range_lock);
if (br_lck == NULL) {
return NULL;
}
@@ -1380,7 +1358,13 @@
br_lck->fsp = fsp;
br_lck->num_locks = 0;
br_lck->modified = False;
+ memset(&br_lck->key, '\0', sizeof(struct lock_key));
+ br_lck->key.device = fsp->dev;
+ br_lck->key.inode = fsp->inode;
+ key.dptr = (char *)&br_lck->key;
+ key.dsize = sizeof(struct lock_key);
+
if (tdb_chainlock(tdb, key) != 0) {
DEBUG(3, ("Could not lock byte range lock entry\n"));
TALLOC_FREE(br_lck);
More information about the samba-cvs
mailing list