1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

s3/smbd: add and use retry_open() instead of defer_open() in two places

Add a new function that does an immediate open rescheduling.

The first deferred open this commit changes was never scheduled, as the
scheduling relies on a timeout of the watch on the sharemode lock.

This has been broken since the commits in

$ git log --reverse -p -10 8283fd0e0090ed12b0b12d5acb550642d621b026

That patchset added the dbwrap watch record logic to defer_open() and
removed the timers.

I'm doing this mainly to untangle the defer_open() logic which is
complicated by the lck arg.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=7537

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2017-03-07 15:03:12 +01:00 committed by Jeremy Allison
parent b17ff9b181
commit beaba62228

View File

@ -2057,6 +2057,40 @@ static void defer_open_done(struct tevent_req *req)
TALLOC_FREE(state); TALLOC_FREE(state);
} }
/**
* Reschedule an open for immediate execution
**/
static void retry_open(struct timeval request_time,
struct smb_request *req,
struct file_id id)
{
struct deferred_open_record *open_rec = NULL;
bool ok;
DBG_DEBUG("request time [%s] mid [%" PRIu64 "] file_id [%s]\n",
timeval_string(talloc_tos(), &request_time, false),
req->mid,
file_id_string_tos(&id));
open_rec = deferred_open_record_create(false, false, id);
if (open_rec == NULL) {
exit_server("talloc failed");
}
ok = push_deferred_open_message_smb(req,
request_time,
timeval_set(0, 0),
id,
open_rec);
if (!ok) {
exit_server("push_deferred_open_message_smb failed");
}
ok = schedule_deferred_open_message_smb(req->xconn, req->mid);
if (!ok) {
exit_server("schedule_deferred_open_message_smb failed");
}
}
/**************************************************************************** /****************************************************************************
On overwrite open ensure that the attributes match. On overwrite open ensure that the attributes match.
@ -2841,8 +2875,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) { if (lck == NULL) {
defer_open(NULL, request_time, timeval_set(0, 0), retry_open(request_time, req, fsp->file_id);
req, false, false, fsp->file_id);
DEBUG(10, ("No share mode lock found after " DEBUG(10, ("No share mode lock found after "
"EWOULDBLOCK, retrying sync\n")); "EWOULDBLOCK, retrying sync\n"));
return NT_STATUS_SHARING_VIOLATION; return NT_STATUS_SHARING_VIOLATION;
@ -2868,8 +2901,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
* No oplock from Samba around. Immediately retry with * No oplock from Samba around. Immediately retry with
* a blocking open. * a blocking open.
*/ */
defer_open(lck, request_time, timeval_set(0, 0), req, retry_open(request_time, req, fsp->file_id);
false, false, fsp->file_id);
TALLOC_FREE(lck); TALLOC_FREE(lck);
DEBUG(10, ("No Samba oplock around after EWOULDBLOCK. " DEBUG(10, ("No Samba oplock around after EWOULDBLOCK. "