diff options
author | Stefan Metzmacher <metze@samba.org> | 2008-03-07 17:50:17 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-03-07 19:15:27 +0100 |
commit | 75a412a46975754e75679f5d072e6ce688fee894 (patch) | |
tree | 9b1560fac05a780ca2fb6af491a49e85476b22a2 | |
parent | 6c27daeeca9c2649896b70fba78c3c401159defe (diff) | |
download | samba-75a412a46975754e75679f5d072e6ce688fee894.tar.gz samba-75a412a46975754e75679f5d072e6ce688fee894.tar.bz2 samba-75a412a46975754e75679f5d072e6ce688fee894.zip |
pvfs_open: always call odb_can_open() before odb_open_file()
odb_open_file() will later change to not redo the logic of
odb_can_open().
metze
(This used to be commit b09a1461ac595be1b6530221b7df5211084884cc)
-rw-r--r-- | source4/ntvfs/posix/pvfs_open.c | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index 47b44b9634..1ed517c719 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -290,6 +290,15 @@ 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_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, name->stream_id, share_access, access_mask, del_on_close, io->generic.in.open_disposition, @@ -344,6 +353,14 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs, return NT_STATUS_INTERNAL_DB_CORRUPTION; } + 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, name->stream_id, share_access, access_mask, del_on_close, io->generic.in.open_disposition, @@ -663,6 +680,18 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs, allow_level_II_oplock = true; } + 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, name->stream_id, share_access, access_mask, del_on_close, io->generic.in.open_disposition, @@ -801,7 +830,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 +1282,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 +1303,18 @@ 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, name->stream_id, + share_access, access_mask, del_on_close, + io->generic.in.open_disposition, + false, 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) { |