diff options
author | Stefan Metzmacher <metze@samba.org> | 2019-08-08 19:26:28 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2019-09-09 14:23:41 +0000 |
commit | 66d92f37c3a643d97489a59bb6d1e75e91528c20 (patch) | |
tree | f67d670b6a73097cf4f969c4650a53dfb071d597 /source3/smbd | |
parent | 7471b0f63276e707784c98b832992ff08b1898ef (diff) | |
download | samba-66d92f37c3a643d97489a59bb6d1e75e91528c20.tar.gz |
s3:locking: add brl_req_guid() and brl_req_mem_ctx() helper functions
This allows the vfs backend to detect a retry and keep state between
the retries.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/blocking.c | 2 | ||||
-rw-r--r-- | source3/smbd/globals.c | 18 | ||||
-rw-r--r-- | source3/smbd/globals.h | 2 | ||||
-rw-r--r-- | source3/smbd/reply.c | 7 | ||||
-rw-r--r-- | source3/smbd/smb2_lock.c | 1 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 2 |
6 files changed, 32 insertions, 0 deletions
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index fbd1ea812f3..94e75a9b405 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -45,6 +45,8 @@ NTSTATUS smbd_do_locks_try( status = do_lock( fsp, + locks, /* req_mem_ctx */ + &e->req_guid, e->smblctx, e->count, e->offset, diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c index 6bc448b901d..0cdce20d122 100644 --- a/source3/smbd/globals.c +++ b/source3/smbd/globals.c @@ -109,3 +109,21 @@ void smbd_init_globals(void) ZERO_STRUCT(sec_ctx_stack); } + +struct GUID smbd_request_guid(struct smb_request *smb1req, uint16_t idx) +{ + struct GUID v = { + .time_low = (uint32_t)smb1req->mid, + .time_hi_and_version = idx, + }; + + if (smb1req->smb2req != NULL) { + v.time_mid = (uint16_t)smb1req->smb2req->current_idx; + } else { + v.time_mid = (uint16_t)(uintptr_t)smb1req->vwv; + } + + SBVAL((uint8_t *)&v, 8, (uintptr_t)smb1req->xconn); + + return v; +} diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index bdd8c49e2ba..a612a42f63b 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -115,6 +115,8 @@ DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbXsrv_connection *xconn); void smbd_lock_socket(struct smbXsrv_connection *xconn); void smbd_unlock_socket(struct smbXsrv_connection *xconn); +struct GUID smbd_request_guid(struct smb_request *smb1req, uint16_t idx); + NTSTATUS smbd_do_unlocking(struct smb_request *req, files_struct *fsp, uint16_t num_ulocks, diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 0c4493fdb95..4446d927aeb 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3944,6 +3944,7 @@ void reply_lockread(struct smb_request *req) */ *lck = (struct smbd_lock_element) { + .req_guid = smbd_request_guid(req, 0), .smblctx = req->smbpid, .brltype = WRITE_LOCK, .count = SVAL(req->vwv+1, 0), @@ -4971,6 +4972,7 @@ void reply_writeunlock(struct smb_request *req) if (numtowrite && !fsp->print_file) { struct smbd_lock_element l = { + .req_guid = smbd_request_guid(req, 0), .smblctx = req->smbpid, .brltype = UNLOCK_LOCK, .offset = startpos, @@ -5866,6 +5868,7 @@ void reply_lock(struct smb_request *req) } *lck = (struct smbd_lock_element) { + .req_guid = smbd_request_guid(req, 0), .smblctx = req->smbpid, .brltype = WRITE_LOCK, .count = IVAL(req->vwv+1, 0), @@ -5957,6 +5960,7 @@ void reply_unlock(struct smb_request *req) } lck = (struct smbd_lock_element) { + .req_guid = smbd_request_guid(req, 0), .smblctx = req->smbpid, .brltype = UNLOCK_LOCK, .offset = IVAL(req->vwv+3, 0), @@ -8550,6 +8554,8 @@ void reply_lockingX(struct smb_request *req) * smb_unlkrng structs */ for (i = 0; i < num_ulocks; i++) { + ulocks[i].req_guid = smbd_request_guid(req, + UINT16_MAX - i), ulocks[i].smblctx = get_lock_pid( data, i, large_file_format); ulocks[i].count = get_lock_count( @@ -8607,6 +8613,7 @@ void reply_lockingX(struct smb_request *req) } for (i = 0; i < num_locks; i++) { + locks[i].req_guid = smbd_request_guid(req, i), locks[i].smblctx = get_lock_pid(data, i, large_file_format); locks[i].count = get_lock_count(data, i, large_file_format); locks[i].offset = get_lock_offset(data, i, large_file_format); diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c index 26de8b521ed..381aae6cb60 100644 --- a/source3/smbd/smb2_lock.c +++ b/source3/smbd/smb2_lock.c @@ -318,6 +318,7 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } + locks[i].req_guid = smbd_request_guid(smb2req->smb1req, i); locks[i].smblctx = fsp->op->global->open_persistent_id; locks[i].offset = in_locks[i].offset; locks[i].count = in_locks[i].length; diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index cb3c80af59b..7c1e020324b 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -7668,6 +7668,7 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn, if (lock_type == UNLOCK_LOCK) { struct smbd_lock_element l = { + .req_guid = smbd_request_guid(req, 0), .smblctx = smblctx, .brltype = UNLOCK_LOCK, .offset = offset, @@ -7683,6 +7684,7 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn, } *lck = (struct smbd_lock_element) { + .req_guid = smbd_request_guid(req, 0), .smblctx = smblctx, .brltype = lock_type, .count = count, |