summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix/pvfs_open.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-03-07 23:02:36 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-03-07 23:02:36 +0100
commit87abb775ce9a7610341ff8f06d1c482e72e6fd6d (patch)
tree6d74ffa4dbc967cd0f05a7182ca78f78d54dafdb /source4/ntvfs/posix/pvfs_open.c
parent6a1f56d82a367a2f037e18ed346cf7cce7f377e0 (diff)
parentdb669e1eb13effb08b1111405587c8c6dde95954 (diff)
downloadsamba-87abb775ce9a7610341ff8f06d1c482e72e6fd6d.tar.gz
samba-87abb775ce9a7610341ff8f06d1c482e72e6fd6d.tar.bz2
samba-87abb775ce9a7610341ff8f06d1c482e72e6fd6d.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-gmake3
(This used to be commit ac27a1451dfe5c0c957e93fdc84602c3c1c7deac)
Diffstat (limited to 'source4/ntvfs/posix/pvfs_open.c')
-rw-r--r--source4/ntvfs/posix/pvfs_open.c67
1 files changed, 49 insertions, 18 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index 47b44b9634..2e757e1742 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -290,10 +290,17 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
}
/* see if we are allowed to open at the same time as existing opens */
- status = odb_open_file(lck, f->handle, name->full_name, name->stream_id,
- share_access, access_mask, del_on_close,
- io->generic.in.open_disposition,
- false, false, OPLOCK_NONE, NULL);
+ status = odb_can_open(lck, name->stream_id,
+ share_access, access_mask, del_on_close,
+ io->generic.in.open_disposition, false);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(lck);
+ return status;
+ }
+
+ /* now really mark the file as open */
+ status = odb_open_file(lck, f->handle, name->full_name,
+ false, OPLOCK_NONE, NULL);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(lck);
@@ -344,10 +351,16 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- status = odb_open_file(lck, f->handle, name->full_name, name->stream_id,
- share_access, access_mask, del_on_close,
- io->generic.in.open_disposition,
- false, false, OPLOCK_NONE, NULL);
+ status = odb_can_open(lck, name->stream_id,
+ share_access, access_mask, del_on_close,
+ io->generic.in.open_disposition, false);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto cleanup_delete;
+ }
+
+ status = odb_open_file(lck, f->handle, name->full_name,
+ false, OPLOCK_NONE, NULL);
if (!NT_STATUS_IS_OK(status)) {
goto cleanup_delete;
@@ -663,10 +676,20 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
allow_level_II_oplock = true;
}
- status = odb_open_file(lck, f->handle, name->full_name, name->stream_id,
- share_access, access_mask, del_on_close,
- io->generic.in.open_disposition,
- false, allow_level_II_oplock,
+ status = odb_can_open(lck, name->stream_id,
+ share_access, access_mask, del_on_close,
+ io->generic.in.open_disposition, false);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(lck);
+ /* bad news, we must have hit a race - we don't delete the file
+ here as the most likely scenario is that someone else created
+ the file at the same time */
+ close(fd);
+ return status;
+ }
+
+ status = odb_open_file(lck, f->handle, name->full_name,
+ allow_level_II_oplock,
oplock_level, &oplock_granted);
talloc_free(lck);
if (!NT_STATUS_IS_OK(status)) {
@@ -801,7 +824,7 @@ static void pvfs_odb_retry_callback(void *_r, enum pvfs_wait_notice reason)
/*
setup for a retry of a request that was rejected
- by odb_open_file() or odb_can_open()
+ by odb_can_open()
*/
NTSTATUS pvfs_odb_retry_setup(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req,
@@ -1253,11 +1276,9 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
}
/* see if we are allowed to open at the same time as existing opens */
- status = odb_open_file(lck, f->handle, name->full_name, name->stream_id,
- share_access, access_mask, del_on_close,
- io->generic.in.open_disposition,
- false, allow_level_II_oplock,
- oplock_level, &oplock_granted);
+ status = odb_can_open(lck, name->stream_id,
+ share_access, access_mask, del_on_close,
+ io->generic.in.open_disposition, false);
/*
* on a sharing violation we need to retry when the file is closed by
@@ -1276,6 +1297,16 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
return status;
}
+ /* now really mark the file as open */
+ status = odb_open_file(lck, f->handle, name->full_name,
+ allow_level_II_oplock,
+ oplock_level, &oplock_granted);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(lck);
+ return status;
+ }
+
if (pvfs->flags & PVFS_FLAG_FAKE_OPLOCKS) {
oplock_granted = OPLOCK_BATCH;
} else if (oplock_granted != OPLOCK_NONE) {