diff options
author | Volker Lendecke <vl@samba.org> | 2013-09-26 16:15:31 -0700 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2013-10-23 11:58:56 +0200 |
commit | 20669d4a75386eef4fdcea07fb99812c4e09de13 (patch) | |
tree | 403e4ca912e16316e21f6467cc3e02886d03f4d8 /source3/smbd/open.c | |
parent | ccc808e0d72be5933ae2449ee8ee56262e631b72 (diff) | |
download | samba-20669d4a75386eef4fdcea07fb99812c4e09de13.tar.gz samba-20669d4a75386eef4fdcea07fb99812c4e09de13.tar.bz2 samba-20669d4a75386eef4fdcea07fb99812c4e09de13.zip |
smbd: Fix raw.batch.exclusive[59]
The level we have to break to depend on the breakers create_disposition:
If we overwrite, we have to break to none.
This patch overloads the "op_type" field in the break message we send
across to the smbd holding the oplock with the oplock level we want to
break to. Because it depends on the create_disposition in the breaking
open, only the breaker can make that decision. We might want to use
a different mechanism for this in the future, but for now using the
op_type field seems acceptable to me.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r-- | source3/smbd/open.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index a9147f80b8..494145397d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1168,7 +1168,8 @@ static NTSTATUS open_mode_check(connection_struct *conn, */ static NTSTATUS send_break_message(struct messaging_context *msg_ctx, - const struct share_mode_entry *exclusive) + const struct share_mode_entry *exclusive, + uint16_t break_to) { NTSTATUS status; char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE]; @@ -1179,6 +1180,9 @@ static NTSTATUS send_break_message(struct messaging_context *msg_ctx, /* Create the message. */ share_mode_entry_to_message(msg, exclusive); + /* Overload entry->op_type */ + SSVAL(msg,OP_BREAK_MSG_OP_TYPE_OFFSET, break_to); + status = messaging_send_buf(msg_ctx, exclusive->pid, MSG_SMB_BREAK_REQUEST, (uint8 *)msg, sizeof(msg)); @@ -1292,12 +1296,14 @@ static bool validate_oplock_types(struct share_mode_lock *lck) static bool delay_for_oplock(files_struct *fsp, int oplock_request, struct share_mode_lock *lck, - bool have_sharing_violation) + bool have_sharing_violation, + uint32_t create_disposition) { struct share_mode_data *d = lck->data; struct share_mode_entry *entry; uint32_t num_non_stat_opens = 0; uint32_t i; + uint16_t break_to; if ((oplock_request & INTERNAL_OPEN_ONLY) || is_stat_open(fsp->access_mask)) { return false; @@ -1342,11 +1348,21 @@ static bool delay_for_oplock(files_struct *fsp, return false; } + switch (create_disposition) { + case FILE_SUPERSEDE: + case FILE_OVERWRITE_IF: + break_to = NO_OPLOCK; + break; + default: + break_to = LEVEL_II_OPLOCK; + break; + } + if (have_sharing_violation && (entry->op_type & BATCH_OPLOCK)) { if (share_mode_stale_pid(d, 0)) { return false; } - send_break_message(fsp->conn->sconn->msg_ctx, entry); + send_break_message(fsp->conn->sconn->msg_ctx, entry, break_to); return true; } if (have_sharing_violation) { @@ -1366,7 +1382,7 @@ static bool delay_for_oplock(files_struct *fsp, return false; } - send_break_message(fsp->conn->sconn->msg_ctx, entry); + send_break_message(fsp->conn->sconn->msg_ctx, entry, break_to); return true; } @@ -2343,7 +2359,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, smb_panic("validate_oplock_types failed"); } - if (delay_for_oplock(fsp, 0, lck, false)) { + if (delay_for_oplock(fsp, 0, lck, false, create_disposition)) { schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); DEBUG(10, ("Sent oplock break request to kernel " @@ -2455,7 +2471,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, if ((req != NULL) && delay_for_oplock( fsp, oplock_request, lck, - NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION))) { + NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION), + create_disposition)) { schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); fd_close(fsp); |