The Samba-Bugzilla – Attachment 6700 Details for
Bug 8307
brl_close_fnum does not call SMB_VFS_BRL_UNLOCK_WINDOWS on all locks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
git-am fix for 3.6.1
0001-Fix-bug-8307-brl_close_fnum-does-not-call-SMB_VFS_BR.patch (text/plain), 5.40 KB, created by
Jeremy Allison
on 2011-07-16 04:38:12 UTC
(
hide
)
Description:
git-am fix for 3.6.1
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2011-07-16 04:38:12 UTC
Size:
5.40 KB
patch
obsolete
>From 451538c9c9a2ba2a09e4e911f5715ef856627410 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Fri, 15 Jul 2011 21:36:13 -0700 >Subject: [PATCH] Fix bug #8307 - brl_close_fnum does not call SMB_VFS_BRL_UNLOCK_WINDOWS on all locks > >Reported by herb@samba.org. Remove the (premature) optimization >on file close. >--- > source3/locking/brlock.c | 145 +++++++-------------------------------------- > 1 files changed, 23 insertions(+), 122 deletions(-) > >diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c >index c325338..8b8605d 100644 >--- a/source3/locking/brlock.c >+++ b/source3/locking/brlock.c >@@ -1485,137 +1485,38 @@ void brl_close_fnum(struct messaging_context *msg_ctx, > files_struct *fsp = br_lck->fsp; > uint16 tid = fsp->conn->cnum; > int fnum = fsp->fnum; >- unsigned int i, j, dcount=0; >- int num_deleted_windows_locks = 0; >+ unsigned int i; > struct lock_struct *locks = br_lck->lock_data; > struct server_id pid = sconn_server_id(fsp->conn->sconn); >- bool unlock_individually = False; >- bool posix_level2_contention_ended = false; >- >- if(lp_posix_locking(fsp->conn->params)) { >- >- /* Check if there are any Windows locks associated with this dev/ino >- pair that are not this fnum. If so we need to call unlock on each >- one in order to release the system POSIX locks correctly. */ >- >- for (i=0; i < br_lck->num_locks; i++) { >- struct lock_struct *lock = &locks[i]; >- >- if (!procid_equal(&lock->context.pid, &pid)) { >- continue; >+ struct lock_struct *locks_copy; >+ unsigned int num_locks_copy; >+ >+ /* Copy the current lock array. */ >+ if (br_lck->num_locks) { >+ locks_copy = (struct lock_struct *)TALLOC_MEMDUP(br_lck, locks, br_lck->num_locks * sizeof(struct lock_struct)); >+ if (!locks_copy) { >+ smb_panic("brl_close_fnum: talloc failed"); > } >- >- if (lock->lock_type != READ_LOCK && lock->lock_type != WRITE_LOCK) { >- continue; /* Ignore pending. */ >- } >- >- if (lock->context.tid != tid || lock->fnum != fnum) { >- unlock_individually = True; >- break; >- } >- } >- >- if (unlock_individually) { >- struct lock_struct *locks_copy; >- unsigned int num_locks_copy; >- >- /* Copy the current lock array. */ >- if (br_lck->num_locks) { >- locks_copy = (struct lock_struct *)TALLOC_MEMDUP(br_lck, locks, br_lck->num_locks * sizeof(struct lock_struct)); >- if (!locks_copy) { >- smb_panic("brl_close_fnum: talloc failed"); >- } >- } else { >- locks_copy = NULL; >- } >- >- num_locks_copy = br_lck->num_locks; >- >- for (i=0; i < num_locks_copy; i++) { >- struct lock_struct *lock = &locks_copy[i]; >- >- if (lock->context.tid == tid && procid_equal(&lock->context.pid, &pid) && >- (lock->fnum == fnum)) { >- brl_unlock(msg_ctx, >- br_lck, >- lock->context.smblctx, >- pid, >- lock->start, >- lock->size, >- lock->lock_flav); >- } >- } >- return; >- } >+ } else { >+ locks_copy = NULL; > } > >- /* We can bulk delete - any POSIX locks will be removed when the fd closes. */ >+ num_locks_copy = br_lck->num_locks; > >- /* Remove any existing locks for this fnum (or any fnum if they're POSIX). */ >+ for (i=0; i < num_locks_copy; i++) { >+ struct lock_struct *lock = &locks_copy[i]; > >- for (i=0; i < br_lck->num_locks; i++) { >- struct lock_struct *lock = &locks[i]; >- bool del_this_lock = False; >- >- if (lock->context.tid == tid && procid_equal(&lock->context.pid, &pid)) { >- if ((lock->lock_flav == WINDOWS_LOCK) && (lock->fnum == fnum)) { >- del_this_lock = True; >- num_deleted_windows_locks++; >- contend_level2_oplocks_end(br_lck->fsp, >- LEVEL2_CONTEND_WINDOWS_BRL); >- } else if (lock->lock_flav == POSIX_LOCK) { >- del_this_lock = True; >- >- /* Only end level2 contention once for posix */ >- if (!posix_level2_contention_ended) { >- posix_level2_contention_ended = true; >- contend_level2_oplocks_end(br_lck->fsp, >- LEVEL2_CONTEND_POSIX_BRL); >- } >- } >- } >- >- if (del_this_lock) { >- /* Send unlock messages to any pending waiters that overlap. */ >- for (j=0; j < br_lck->num_locks; j++) { >- struct lock_struct *pend_lock = &locks[j]; >- >- /* Ignore our own or non-pending locks. */ >- if (!IS_PENDING_LOCK(pend_lock->lock_type)) { >- continue; >- } >- >- /* Optimisation - don't send to this fnum as we're >- closing it. */ >- if (pend_lock->context.tid == tid && >- procid_equal(&pend_lock->context.pid, &pid) && >- pend_lock->fnum == fnum) { >- continue; >- } >- >- /* We could send specific lock info here... */ >- if (brl_pending_overlap(lock, pend_lock)) { >- messaging_send(msg_ctx, pend_lock->context.pid, >- MSG_SMB_UNLOCK, &data_blob_null); >- } >- } >- >- /* found it - delete it */ >- if (br_lck->num_locks > 1 && i < br_lck->num_locks - 1) { >- memmove(&locks[i], &locks[i+1], >- sizeof(*locks)*((br_lck->num_locks-1) - i)); >- } >- br_lck->num_locks--; >- br_lck->modified = True; >- i--; >- dcount++; >+ if (lock->context.tid == tid && procid_equal(&lock->context.pid, &pid) && >+ (lock->fnum == fnum)) { >+ brl_unlock(msg_ctx, >+ br_lck, >+ lock->context.smblctx, >+ pid, >+ lock->start, >+ lock->size, >+ lock->lock_flav); > } > } >- >- if(lp_posix_locking(fsp->conn->params) && num_deleted_windows_locks) { >- /* Reduce the Windows lock POSIX reference count on this dev/ino pair. */ >- reduce_windows_lock_ref_count(fsp, num_deleted_windows_locks); >- } > } > > /**************************************************************************** >-- >1.7.0.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
vl
:
review+
Actions:
View
Attachments on
bug 8307
: 6700