This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "vfs_posix.h"
#include "system/time.h"
-#include "dlinklist.h"
+#include "lib/util/dlinklist.h"
#include "messaging/messaging.h"
}
return brl_locktest(pvfs->brl_context,
- &f->handle->brl_locking_key,
- f->fnum,
+ f->brl_handle,
smbpid,
offset, count, rw);
}
int i,
NTSTATUS status)
{
+ /* in SMB2 mode we also try to unlock failing lock */
+ if (req->ctx->protocol != PROTOCOL_SMB2) {
+ i--;
+ }
+
/* undo the locks we just did */
- for (i=i-1;i>=0;i--) {
+ for (;i>=0;i--) {
brl_unlock(pvfs->brl_context,
- &f->handle->brl_locking_key,
+ f->brl_handle,
locks[i].pid,
- f->fnum,
locks[i].offset,
locks[i].count);
f->lock_count--;
/*
called when we receive a pending lock notification. It means that
- either our lock timed out or somoene else has unlocked a overlapping
+ either our lock timed out or someone else has unlocked a overlapping
range, so we should try the lock again. Note that on timeout we
do retry the lock, giving it a last chance.
*/
if (reason == PVFS_WAIT_CANCEL) {
status = NT_STATUS_FILE_LOCK_CONFLICT;
} else {
+ /*
+ * here it's important to pass the pending pointer
+ * because with this we'll get the correct error code
+ * FILE_LOCK_CONFLICT in the error case
+ */
status = brl_lock(pvfs->brl_context,
- &f->handle->brl_locking_key,
- req->smbpid,
- f->fnum,
+ f->brl_handle,
+ locks[pending->pending_lock].pid,
locks[pending->pending_lock].offset,
locks[pending->pending_lock].count,
- rw, NULL);
+ rw, pending);
}
if (NT_STATUS_IS_OK(status)) {
f->lock_count++;
if (NT_STATUS_IS_OK(status) || timed_out) {
NTSTATUS status2;
status2 = brl_remove_pending(pvfs->brl_context,
- &f->handle->brl_locking_key, pending);
+ f->brl_handle, pending);
if (!NT_STATUS_IS_OK(status2)) {
DEBUG(0,("pvfs_lock: failed to remove pending lock - %s\n", nt_errstr(status2)));
}
}
status = brl_lock(pvfs->brl_context,
- &f->handle->brl_locking_key,
- req->smbpid,
- f->fnum,
+ f->brl_handle,
+ locks[i].pid,
locks[i].offset,
locks[i].count,
rw, pending);
if (f->lock_count || f->pending_list) {
DEBUG(5,("pvfs_lock: removing %.0f locks on close\n",
(double)f->lock_count));
- brl_close(f->pvfs->brl_context, &f->handle->brl_locking_key, f->fnum);
+ brl_close(f->pvfs->brl_context, f->brl_handle);
f->lock_count = 0;
}
/* check if the lock request matches exactly - you can only cancel with exact matches */
if (p->lck->lockx.in.ulock_cnt == lck->lockx.in.ulock_cnt &&
p->lck->lockx.in.lock_cnt == lck->lockx.in.lock_cnt &&
- p->lck->lockx.in.file.fnum == lck->lockx.in.file.fnum &&
+ p->lck->lockx.in.file.ntvfs== lck->lockx.in.file.ntvfs &&
p->lck->lockx.in.mode == (lck->lockx.in.mode & ~LOCKING_ANDX_CANCEL_LOCK)) {
int i;
/* an exact match! we can cancel it, which is equivalent
to triggering the timeout early */
- pvfs_pending_lock_continue(p ,True);
+ pvfs_pending_lock_continue(p, PVFS_WAIT_TIMEOUT);
return NT_STATUS_OK;
}
}
return ntvfs_map_lock(ntvfs, req, lck);
}
- f = pvfs_find_fd(pvfs, req, lck->lockx.in.file.fnum);
+ f = pvfs_find_fd(pvfs, req, lck->lockx.in.file.ntvfs);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
for (i=0;i<lck->lockx.in.ulock_cnt;i++) {
status = brl_unlock(pvfs->brl_context,
- &f->handle->brl_locking_key,
+ f->brl_handle,
locks[i].pid,
- f->fnum,
locks[i].offset,
locks[i].count);
if (!NT_STATUS_IS_OK(status)) {
}
status = brl_lock(pvfs->brl_context,
- &f->handle->brl_locking_key,
+ f->brl_handle,
locks[i].pid,
- f->fnum,
locks[i].offset,
locks[i].count,
rw, pending);
DLIST_ADD(f->pending_list, pending);
return NT_STATUS_OK;
}
+ /* in SMB2 mode we also try to unlock failing lock */
+ if (req->ctx->protocol != PROTOCOL_SMB2) {
+ i--;
+ }
/* undo the locks we just did */
- for (i=i-1;i>=0;i--) {
+ for (;i>=0;i--) {
brl_unlock(pvfs->brl_context,
- &f->handle->brl_locking_key,
+ f->brl_handle,
locks[i].pid,
- f->fnum,
locks[i].offset,
locks[i].count);
f->lock_count--;
return NT_STATUS_OK;
}
-