summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-05-15 12:22:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:07:00 -0500
commit5e6d1ea2618851ef99522a806f36916127e5294a (patch)
tree4671b44c2bca74104a132ff432a4e355cb3a2d1a /source4/ntvfs/posix
parentbe0bd9fa336464e7c1fa2ab7cc5cd34075d595ce (diff)
downloadsamba-5e6d1ea2618851ef99522a806f36916127e5294a.tar.gz
samba-5e6d1ea2618851ef99522a806f36916127e5294a.tar.bz2
samba-5e6d1ea2618851ef99522a806f36916127e5294a.zip
r15614: the byte range locking error handling caches the last failed lock
per file handle and not per tree connect metze (This used to be commit 5d825261c0b8341f0a7f0f6d96d83807352566f4)
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_lock.c33
-rw-r--r--source4/ntvfs/posix/pvfs_open.c47
-rw-r--r--source4/ntvfs/posix/vfs_posix.h6
3 files changed, 44 insertions, 42 deletions
diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c
index 0558fd52ea..99b694665d 100644
--- a/source4/ntvfs/posix/pvfs_lock.c
+++ b/source4/ntvfs/posix/pvfs_lock.c
@@ -41,8 +41,7 @@ NTSTATUS pvfs_check_lock(struct pvfs_state *pvfs,
}
return brl_locktest(pvfs->brl_context,
- &f->handle->brl_locking_key,
- f->fnum,
+ f->brl_handle,
smbpid,
offset, count, rw);
}
@@ -73,9 +72,8 @@ static void pvfs_lock_async_failed(struct pvfs_state *pvfs,
/* undo the locks we just did */
for (i=i-1;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--;
@@ -120,13 +118,17 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
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,
+ f->brl_handle,
req->smbpid,
- f->fnum,
locks[pending->pending_lock].offset,
locks[pending->pending_lock].count,
- rw, NULL);
+ rw, pending);
}
if (NT_STATUS_IS_OK(status)) {
f->lock_count++;
@@ -138,7 +140,7 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
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)));
}
@@ -171,9 +173,8 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
}
status = brl_lock(pvfs->brl_context,
- &f->handle->brl_locking_key,
+ f->brl_handle,
req->smbpid,
- f->fnum,
locks[i].offset,
locks[i].count,
rw, pending);
@@ -216,7 +217,7 @@ void pvfs_lock_close(struct pvfs_state *pvfs, struct pvfs_file *f)
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;
}
@@ -338,9 +339,8 @@ NTSTATUS pvfs_lock(struct ntvfs_module_context *ntvfs,
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)) {
@@ -357,9 +357,8 @@ NTSTATUS pvfs_lock(struct ntvfs_module_context *ntvfs,
}
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);
@@ -381,9 +380,8 @@ NTSTATUS pvfs_lock(struct ntvfs_module_context *ntvfs,
/* undo the locks we just did */
for (i=i-1;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--;
@@ -395,4 +393,3 @@ NTSTATUS pvfs_lock(struct ntvfs_module_context *ntvfs,
return NT_STATUS_OK;
}
-
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index 9570fa08d9..3bbf840154 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -277,13 +277,13 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
f->share_access = io->generic.in.share_access;
f->impersonation = io->generic.in.impersonation;
f->access_mask = access_mask;
+ f->brl_handle = NULL;
f->notify_buffer = NULL;
f->handle->pvfs = pvfs;
f->handle->name = talloc_steal(f->handle, name);
f->handle->fd = -1;
f->handle->odb_locking_key = data_blob(NULL, 0);
- f->handle->brl_locking_key = data_blob(NULL, 0);
f->handle->create_options = io->generic.in.create_options;
f->handle->seek_offset = 0;
f->handle->position = 0;
@@ -526,32 +526,37 @@ static int pvfs_fnum_destructor(void *p)
account of file streams (each stream is a separate byte range
locking space)
*/
-static NTSTATUS pvfs_brl_locking_key(struct pvfs_filename *name,
- TALLOC_CTX *mem_ctx, DATA_BLOB *key)
+static NTSTATUS pvfs_brl_locking_handle(TALLOC_CTX *mem_ctx,
+ struct pvfs_filename *name,
+ uint16_t fnum,
+ struct brl_handle **_h)
{
- DATA_BLOB odb_key;
+ DATA_BLOB odb_key, key;
NTSTATUS status;
+ struct brl_handle *h;
+
status = pvfs_locking_key(name, mem_ctx, &odb_key);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
+ NT_STATUS_NOT_OK_RETURN(status);
+
if (name->stream_name == NULL) {
- *key = odb_key;
- return NT_STATUS_OK;
- }
- *key = data_blob_talloc(mem_ctx, NULL,
- odb_key.length + strlen(name->stream_name) + 1);
- if (key->data == NULL) {
- return NT_STATUS_NO_MEMORY;
+ key = odb_key;
+ } else {
+ key = data_blob_talloc(mem_ctx, NULL,
+ odb_key.length + strlen(name->stream_name) + 1);
+ NT_STATUS_HAVE_NO_MEMORY(key.data);
+ memcpy(key.data, odb_key.data, odb_key.length);
+ memcpy(key.data + odb_key.length,
+ name->stream_name, strlen(name->stream_name) + 1);
+ data_blob_free(&odb_key);
}
- memcpy(key->data, odb_key.data, odb_key.length);
- memcpy(key->data + odb_key.length,
- name->stream_name, strlen(name->stream_name)+1);
- data_blob_free(&odb_key);
+
+ h = brl_create_handle(mem_ctx, &key, fnum);
+ NT_STATUS_HAVE_NO_MEMORY(h);
+
+ *_h = h;
return NT_STATUS_OK;
}
-
/*
create a new file
*/
@@ -665,7 +670,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
goto cleanup_delete;
}
- status = pvfs_brl_locking_key(name, f->handle, &f->handle->brl_locking_key);
+ status = pvfs_brl_locking_handle(f, name, fnum, &f->brl_handle);
if (!NT_STATUS_IS_OK(status)) {
goto cleanup_delete;
}
@@ -1168,7 +1173,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
return status;
}
- status = pvfs_brl_locking_key(name, f->handle, &f->handle->brl_locking_key);
+ status = pvfs_brl_locking_handle(f, name, f->fnum, &f->brl_handle);
if (!NT_STATUS_IS_OK(status)) {
idr_remove(pvfs->files.idtree, f->fnum);
return status;
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index 335cfdf4e0..39481c03b1 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -134,9 +134,6 @@ struct pvfs_file_handle {
/* a unique file key to be used for open file locking */
DATA_BLOB odb_locking_key;
- /* a unique file key to be used for byte range locking */
- DATA_BLOB brl_locking_key;
-
uint32_t create_options;
/* this is set by the mode_information level. What does it do? */
@@ -178,6 +175,9 @@ struct pvfs_file {
/* a list of pending locks - used for locking cancel operations */
struct pvfs_pending_lock *pending_list;
+ /* a file handle to be used for byte range locking */
+ struct brl_handle *brl_handle;
+
/* a count of active locks - used to avoid calling brl_close on
file close */
uint64_t lock_count;