2 Unix SMB/CIFS implementation.
5 Copyright (C) Stefan Metzmacher 2009
6 Copyright (C) Jeremy Allison 2010
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "smbd/smbd.h"
24 #include "smbd/globals.h"
25 #include "../libcli/smb/smb_common.h"
26 #include "../lib/util/tevent_ntstatus.h"
30 #define DBGC_CLASS DBGC_SMB2
32 struct smbd_smb2_lock_element {
38 struct smbd_smb2_lock_state {
39 struct smbd_smb2_request *smb2req;
40 struct smb_request *smb1req;
41 struct blocking_lock_record *blr;
43 struct smbd_lock_element *locks;
46 static void remove_pending_lock(struct smbd_smb2_lock_state *state,
47 struct blocking_lock_record *blr);
49 static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
50 struct tevent_context *ev,
51 struct smbd_smb2_request *smb2req,
52 struct files_struct *in_fsp,
53 uint16_t in_lock_count,
54 struct smbd_smb2_lock_element *in_locks);
55 static NTSTATUS smbd_smb2_lock_recv(struct tevent_req *req);
57 static void smbd_smb2_request_lock_done(struct tevent_req *subreq);
58 NTSTATUS smbd_smb2_request_process_lock(struct smbd_smb2_request *req)
60 const uint8_t *inbody;
61 uint16_t in_lock_count;
62 uint64_t in_file_id_persistent;
63 uint64_t in_file_id_volatile;
64 struct files_struct *in_fsp;
65 struct smbd_smb2_lock_element *in_locks;
66 struct tevent_req *subreq;
67 const uint8_t *lock_buffer;
71 status = smbd_smb2_request_verify_sizes(req, 0x30);
72 if (!NT_STATUS_IS_OK(status)) {
73 return smbd_smb2_request_error(req, status);
75 inbody = SMBD_SMB2_IN_BODY_PTR(req);
77 in_lock_count = CVAL(inbody, 0x02);
78 /* 0x04 - 4 bytes reserved */
79 in_file_id_persistent = BVAL(inbody, 0x08);
80 in_file_id_volatile = BVAL(inbody, 0x10);
82 if (in_lock_count < 1) {
83 return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
86 if (((in_lock_count - 1) * 0x18) > SMBD_SMB2_IN_DYN_LEN(req)) {
87 return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
90 in_locks = talloc_array(req, struct smbd_smb2_lock_element,
92 if (in_locks == NULL) {
93 return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
97 lock_buffer = inbody + 0x18;
99 in_locks[l].offset = BVAL(lock_buffer, 0x00);
100 in_locks[l].length = BVAL(lock_buffer, 0x08);
101 in_locks[l].flags = IVAL(lock_buffer, 0x10);
102 /* 0x14 - 4 reserved bytes */
104 status = req->session->status;
105 if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_SESSION_EXPIRED)) {
107 * We need to catch NT_STATUS_NETWORK_SESSION_EXPIRED
108 * for lock requests only.
110 * Unlock requests still need to be processed!
112 * This means smbd_smb2_request_check_session()
113 * can't handle the difference and always
114 * allows SMB2_OP_LOCK.
116 if (in_locks[0].flags != SMB2_LOCK_FLAG_UNLOCK) {
117 return smbd_smb2_request_error(req, status);
121 lock_buffer = SMBD_SMB2_IN_DYN_PTR(req);
123 for (l=1; l < in_lock_count; l++) {
124 in_locks[l].offset = BVAL(lock_buffer, 0x00);
125 in_locks[l].length = BVAL(lock_buffer, 0x08);
126 in_locks[l].flags = IVAL(lock_buffer, 0x10);
127 /* 0x14 - 4 reserved bytes */
132 in_fsp = file_fsp_smb2(req, in_file_id_persistent, in_file_id_volatile);
133 if (in_fsp == NULL) {
134 return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
137 subreq = smbd_smb2_lock_send(req, req->ev_ctx,
141 if (subreq == NULL) {
142 return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
144 tevent_req_set_callback(subreq, smbd_smb2_request_lock_done, req);
146 return smbd_smb2_request_pending_queue(req, subreq, 500);
149 static void smbd_smb2_request_lock_done(struct tevent_req *subreq)
151 struct smbd_smb2_request *smb2req = tevent_req_callback_data(subreq,
152 struct smbd_smb2_request);
155 NTSTATUS error; /* transport error */
157 status = smbd_smb2_lock_recv(subreq);
159 if (!NT_STATUS_IS_OK(status)) {
160 error = smbd_smb2_request_error(smb2req, status);
161 if (!NT_STATUS_IS_OK(error)) {
162 smbd_server_connection_terminate(smb2req->xconn,
169 outbody = smbd_smb2_generate_outbody(smb2req, 0x04);
170 if (outbody.data == NULL) {
171 error = smbd_smb2_request_error(smb2req, NT_STATUS_NO_MEMORY);
172 if (!NT_STATUS_IS_OK(error)) {
173 smbd_server_connection_terminate(smb2req->xconn,
180 SSVAL(outbody.data, 0x00, 0x04); /* struct size */
181 SSVAL(outbody.data, 0x02, 0); /* reserved */
183 error = smbd_smb2_request_done(smb2req, outbody, NULL);
184 if (!NT_STATUS_IS_OK(error)) {
185 smbd_server_connection_terminate(smb2req->xconn,
191 static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
192 struct tevent_context *ev,
193 struct smbd_smb2_request *smb2req,
194 struct files_struct *fsp,
195 uint16_t in_lock_count,
196 struct smbd_smb2_lock_element *in_locks)
198 struct tevent_req *req;
199 struct smbd_smb2_lock_state *state;
200 struct smb_request *smb1req;
201 int32_t timeout = -1;
202 bool isunlock = false;
204 struct smbd_lock_element *locks;
208 req = tevent_req_create(mem_ctx, &state,
209 struct smbd_smb2_lock_state);
213 state->smb2req = smb2req;
214 smb2req->subreq = req; /* So we can find this when going async. */
216 smb1req = smbd_smb2_fake_smb_request(smb2req);
217 if (tevent_req_nomem(smb1req, req)) {
218 return tevent_req_post(req, ev);
220 state->smb1req = smb1req;
222 DEBUG(10,("smbd_smb2_lock_send: %s - %s\n",
223 fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
225 locks = talloc_array(state, struct smbd_lock_element, in_lock_count);
227 tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
228 return tevent_req_post(req, ev);
231 switch (in_locks[0].flags) {
232 case SMB2_LOCK_FLAG_SHARED:
233 case SMB2_LOCK_FLAG_EXCLUSIVE:
234 if (in_lock_count > 1) {
235 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
236 return tevent_req_post(req, ev);
241 case SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY:
242 case SMB2_LOCK_FLAG_EXCLUSIVE|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY:
246 case SMB2_LOCK_FLAG_UNLOCK:
247 /* only the first lock gives the UNLOCK bit - see
254 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
255 return tevent_req_post(req, ev);
258 if (!isunlock && (in_lock_count > 1)) {
261 * 3.3.5.14.2 says we SHOULD fail with INVALID_PARAMETER if we
262 * have more than one lock and one of those is blocking.
265 for (i=0; i<in_lock_count; i++) {
266 uint32_t flags = in_locks[i].flags;
268 if ((flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) == 0) {
270 req, NT_STATUS_INVALID_PARAMETER);
271 return tevent_req_post(req, ev);
276 for (i=0; i<in_lock_count; i++) {
277 bool invalid = false;
279 switch (in_locks[i].flags) {
280 case SMB2_LOCK_FLAG_SHARED:
281 case SMB2_LOCK_FLAG_EXCLUSIVE:
288 case SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY:
289 case SMB2_LOCK_FLAG_EXCLUSIVE|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY:
295 case SMB2_LOCK_FLAG_UNLOCK:
297 tevent_req_nterror(req,
298 NT_STATUS_INVALID_PARAMETER);
299 return tevent_req_post(req, ev);
306 * If the first element was a UNLOCK
307 * we need to defer the error response
308 * to the backend, because we need to process
309 * all unlock elements before
314 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
315 return tevent_req_post(req, ev);
318 locks[i].smblctx = fsp->op->global->open_persistent_id;
319 locks[i].offset = in_locks[i].offset;
320 locks[i].count = in_locks[i].length;
322 if (in_locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE) {
323 locks[i].brltype = WRITE_LOCK;
324 } else if (in_locks[i].flags & SMB2_LOCK_FLAG_SHARED) {
325 locks[i].brltype = READ_LOCK;
326 } else if (invalid) {
328 * this is an invalid UNLOCK element
329 * and the backend needs to test for
330 * brltype != UNLOCK_LOCK and return
331 * NT_STATUS_INVALID_PARAMETER
333 locks[i].brltype = READ_LOCK;
335 locks[i].brltype = UNLOCK_LOCK;
338 DEBUG(10,("smbd_smb2_lock_send: index %d offset=%llu, count=%llu, "
339 "smblctx = %llu type %d\n",
341 (unsigned long long)locks[i].offset,
342 (unsigned long long)locks[i].count,
343 (unsigned long long)locks[i].smblctx,
344 (int)locks[i].brltype ));
347 state->locks = locks;
348 state->lock_count = in_lock_count;
351 status = smbd_do_unlocking(smb1req, fsp,
352 in_lock_count, locks);
355 status = smbd_do_locking(smb1req, fsp,
362 if (!NT_STATUS_IS_OK(status)) {
363 if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
364 status = NT_STATUS_LOCK_NOT_GRANTED;
366 tevent_req_nterror(req, status);
367 return tevent_req_post(req, ev);
371 tevent_req_defer_callback(req, smb2req->ev_ctx);
372 SMBPROFILE_IOBYTES_ASYNC_SET_IDLE(smb2req->profile);
376 tevent_req_done(req);
377 return tevent_req_post(req, ev);
380 static NTSTATUS smbd_smb2_lock_recv(struct tevent_req *req)
384 if (tevent_req_is_nterror(req, &status)) {
385 tevent_req_received(req);
389 tevent_req_received(req);
393 /****************************************************************
394 Cancel an outstanding blocking lock request.
395 *****************************************************************/
397 static bool smbd_smb2_lock_cancel(struct tevent_req *req)
399 struct smbd_smb2_request *smb2req = NULL;
400 struct smbd_smb2_lock_state *state = tevent_req_data(req,
401 struct smbd_smb2_lock_state);
406 if (!state->smb2req) {
410 smb2req = state->smb2req;
412 remove_pending_lock(state, state->blr);
415 * If the request is canceled because of logoff, tdis or close
416 * the status is NT_STATUS_RANGE_NOT_LOCKED instead of
417 * NT_STATUS_CANCELLED.
419 * Note that the close case is handled in
420 * cancel_pending_lock_requests_by_fid_smb2(SHUTDOWN_CLOSE)
423 if (!NT_STATUS_IS_OK(smb2req->session->status)) {
424 tevent_req_nterror(req, NT_STATUS_RANGE_NOT_LOCKED);
428 if (!NT_STATUS_IS_OK(smb2req->tcon->status)) {
429 tevent_req_nterror(req, NT_STATUS_RANGE_NOT_LOCKED);
433 tevent_req_nterror(req, NT_STATUS_CANCELLED);
437 /****************************************************************
438 Got a message saying someone unlocked a file. Re-schedule all
439 blocking lock requests as we don't know if anything overlapped.
440 *****************************************************************/
442 static void received_unlock_msg(struct messaging_context *msg,
445 struct server_id server_id,
448 struct smbd_server_connection *sconn =
449 talloc_get_type_abort(private_data,
450 struct smbd_server_connection);
452 DEBUG(10,("received_unlock_msg (SMB2)\n"));
454 process_blocking_lock_queue_smb2(sconn, timeval_current());
457 /****************************************************************
458 Function to get the blr on a pending record.
459 *****************************************************************/
461 struct blocking_lock_record *get_pending_smb2req_blr(struct smbd_smb2_request *smb2req)
463 struct smbd_smb2_lock_state *state = NULL;
464 const uint8_t *inhdr;
469 if (smb2req->subreq == NULL) {
472 if (!tevent_req_is_in_progress(smb2req->subreq)) {
475 inhdr = SMBD_SMB2_IN_HDR_PTR(smb2req);
476 if (SVAL(inhdr, SMB2_HDR_OPCODE) != SMB2_OP_LOCK) {
479 state = tevent_req_data(smb2req->subreq,
480 struct smbd_smb2_lock_state);
486 /****************************************************************
487 Set up the next brl timeout.
488 *****************************************************************/
490 static bool recalc_smb2_brl_timeout(struct smbd_server_connection *sconn)
492 struct smbXsrv_connection *xconn = NULL;
493 struct timeval next_timeout = timeval_zero();
494 int max_brl_timeout = lp_parm_int(-1, "brl", "recalctime", 5);
496 TALLOC_FREE(sconn->smb2.locks.brl_timeout);
498 if (sconn->client != NULL) {
499 xconn = sconn->client->connections;
502 for (; xconn != NULL; xconn = xconn->next) {
503 struct smbd_smb2_request *smb2req, *nextreq;
505 for (smb2req = xconn->smb2.requests; smb2req; smb2req = nextreq) {
506 struct blocking_lock_record *blr =
507 get_pending_smb2req_blr(smb2req);
509 nextreq = smb2req->next;
515 if (!timeval_is_zero(&blr->expire_time)) {
516 next_timeout = timeval_brl_min(&next_timeout,
522 * If we're blocked on pid 0xFFFFFFFFFFFFFFFFLL this is
523 * a POSIX lock, so calculate a timeout of
524 * 10 seconds into the future.
526 if (blr->blocking_smblctx == 0xFFFFFFFFFFFFFFFFLL) {
527 struct timeval psx_to;
529 psx_to = timeval_current_ofs(10, 0);
530 next_timeout = timeval_brl_min(&next_timeout,
536 if (timeval_is_zero(&next_timeout)) {
537 DEBUG(10, ("recalc_smb2_brl_timeout:Next "
538 "timeout = Infinite.\n"));
543 * To account for unclean shutdowns by clients we need a
544 * maximum timeout that we use for checking pending locks. If
545 * we have any pending locks at all, then check if the pending
546 * lock can continue at least every brl:recalctime seconds
547 * (default 5 seconds).
549 * This saves us needing to do a message_send_all() in the
550 * SIGCHLD handler in the parent daemon. That
551 * message_send_all() caused O(n^2) work to be done when IP
552 * failovers happened in clustered Samba, which could make the
553 * entire system unusable for many minutes.
556 if (max_brl_timeout > 0) {
557 struct timeval min_to = timeval_current_ofs(max_brl_timeout, 0);
558 next_timeout = timeval_brl_min(&next_timeout, &min_to);
562 struct timeval cur, from_now;
564 cur = timeval_current();
565 from_now = timeval_until(&cur, &next_timeout);
566 DEBUG(10, ("recalc_smb2_brl_timeout: Next "
567 "timeout = %d.%d seconds from now.\n",
568 (int)from_now.tv_sec, (int)from_now.tv_usec));
572 * brl_timeout_fn() calls change_to_root_user()
573 * so we can use sconn->root_ev_ctx.
575 sconn->smb2.locks.brl_timeout = tevent_add_timer(
581 if (!sconn->smb2.locks.brl_timeout) {
587 /****************************************************************
588 Get an SMB2 lock request to go async. lock_timeout should
590 *****************************************************************/
592 bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck,
593 struct smb_request *smb1req,
598 enum brl_type lock_type,
599 enum brl_flavour lock_flav,
602 uint64_t blocking_smblctx)
604 struct smbd_server_connection *sconn = smb1req->sconn;
605 struct smbd_smb2_request *smb2req = smb1req->smb2req;
606 struct tevent_req *req = NULL;
607 struct smbd_smb2_lock_state *state = NULL;
608 struct blocking_lock_record *blr = NULL;
609 NTSTATUS status = NT_STATUS_OK;
614 req = smb2req->subreq;
618 if (!tevent_req_is_in_progress(smb2req->subreq)) {
621 state = tevent_req_data(req, struct smbd_smb2_lock_state);
626 blr = talloc_zero(state, struct blocking_lock_record);
632 if (lock_timeout == -1) {
633 blr->expire_time.tv_sec = 0;
634 blr->expire_time.tv_usec = 0; /* Never expire. */
636 blr->expire_time = timeval_current_ofs_msec(lock_timeout);
639 blr->lock_num = lock_num;
640 blr->smblctx = smblctx;
641 blr->blocking_smblctx = blocking_smblctx;
642 blr->lock_flav = lock_flav;
643 blr->lock_type = lock_type;
644 blr->offset = offset;
647 /* Specific brl_lock() implementations can fill this in. */
648 blr->blr_private = NULL;
650 /* Add a pending lock record for this. */
651 status = brl_lock(sconn->msg_ctx,
654 messaging_server_id(sconn->msg_ctx),
657 lock_type == READ_LOCK ? PENDING_READ_LOCK : PENDING_WRITE_LOCK,
662 if (!NT_STATUS_IS_OK(status)) {
663 DEBUG(0,("push_blocking_lock_request_smb2: "
664 "failed to add PENDING_LOCK record.\n"));
670 DEBUG(10,("push_blocking_lock_request_smb2: file %s timeout %d\n",
674 recalc_smb2_brl_timeout(sconn);
676 /* Ensure we'll receive messages when this is unlocked. */
677 if (!sconn->smb2.locks.blocking_lock_unlock_state) {
678 messaging_register(sconn->msg_ctx, sconn,
679 MSG_SMB_UNLOCK, received_unlock_msg);
680 sconn->smb2.locks.blocking_lock_unlock_state = true;
683 /* allow this request to be canceled */
684 tevent_req_set_cancel_fn(req, smbd_smb2_lock_cancel);
689 /****************************************************************
690 Remove a pending lock record under lock.
691 *****************************************************************/
693 static void remove_pending_lock(struct smbd_smb2_lock_state *state,
694 struct blocking_lock_record *blr)
696 struct byte_range_lock *br_lck = brl_get_locks(
699 DEBUG(10, ("remove_pending_lock: BLR = %p\n", blr));
702 brl_lock_cancel(br_lck,
704 messaging_server_id(blr->fsp->conn->sconn->msg_ctx),
712 /****************************************************************
713 Re-proccess a blocking lock request.
714 This is equivalent to process_lockingX() inside smbd/blocking.c
715 *****************************************************************/
717 static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
718 struct timeval tv_curr)
720 NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
721 struct blocking_lock_record *blr = NULL;
722 struct smbd_smb2_lock_state *state = NULL;
723 struct byte_range_lock *br_lck = NULL;
724 struct smbd_lock_element *e = NULL;
725 files_struct *fsp = NULL;
727 if (!smb2req->subreq) {
730 SMBPROFILE_IOBYTES_ASYNC_SET_BUSY(smb2req->profile);
732 state = tevent_req_data(smb2req->subreq, struct smbd_smb2_lock_state);
740 /* We can only have one blocked lock in SMB2. */
741 SMB_ASSERT(state->lock_count == 1);
742 SMB_ASSERT(blr->lock_num == 0);
744 /* Try and get the outstanding lock. */
745 e = &state->locks[blr->lock_num];
747 br_lck = do_lock(fsp->conn->sconn->msg_ctx,
756 &blr->blocking_smblctx);
760 if (NT_STATUS_IS_OK(status)) {
762 * Success - we got the lock.
765 DEBUG(3,("reprocess_blocked_smb2_lock SUCCESS file = %s, "
766 "%s, num_locks=%d\n",
769 (int)state->lock_count));
771 remove_pending_lock(state, blr);
772 tevent_req_done(smb2req->subreq);
776 if (!NT_STATUS_EQUAL(status,NT_STATUS_LOCK_NOT_GRANTED) &&
777 !NT_STATUS_EQUAL(status,NT_STATUS_FILE_LOCK_CONFLICT)) {
779 * We have other than a "can't get lock"
780 * error. Return an error.
782 remove_pending_lock(state, blr);
783 tevent_req_nterror(smb2req->subreq, status);
788 * We couldn't get the lock for this record.
789 * If the time has expired, return a lock error.
792 if (!timeval_is_zero(&blr->expire_time) &&
793 timeval_compare(&blr->expire_time, &tv_curr) <= 0) {
794 remove_pending_lock(state, blr);
795 tevent_req_nterror(smb2req->subreq, NT_STATUS_LOCK_NOT_GRANTED);
800 * Still can't get the lock - keep waiting.
803 DEBUG(10,("reprocess_blocked_smb2_lock: failed to get lock "
804 "for file %s, %s. Still waiting....\n",
808 SMBPROFILE_IOBYTES_ASYNC_SET_IDLE(smb2req->profile);
812 /****************************************************************
813 Attempt to proccess all outstanding blocking locks pending on
815 *****************************************************************/
817 void process_blocking_lock_queue_smb2(
818 struct smbd_server_connection *sconn, struct timeval tv_curr)
820 struct smbXsrv_connection *xconn = NULL;
822 if (sconn != NULL && sconn->client != NULL) {
823 xconn = sconn->client->connections;
826 for (; xconn != NULL; xconn = xconn->next) {
827 struct smbd_smb2_request *smb2req, *nextreq;
829 for (smb2req = xconn->smb2.requests; smb2req; smb2req = nextreq) {
830 const uint8_t *inhdr;
832 nextreq = smb2req->next;
834 if (smb2req->subreq == NULL) {
835 /* This message has been processed. */
838 if (!tevent_req_is_in_progress(smb2req->subreq)) {
839 /* This message has been processed. */
843 inhdr = SMBD_SMB2_IN_HDR_PTR(smb2req);
844 if (SVAL(inhdr, SMB2_HDR_OPCODE) == SMB2_OP_LOCK) {
845 reprocess_blocked_smb2_lock(smb2req, tv_curr);
850 recalc_smb2_brl_timeout(sconn);
853 /****************************************************************************
854 Remove any locks on this fd. Called from file_close().
855 ****************************************************************************/
857 void cancel_pending_lock_requests_by_fid_smb2(files_struct *fsp,
858 struct byte_range_lock *br_lck,
859 enum file_close_type close_type)
861 struct smbd_server_connection *sconn = fsp->conn->sconn;
862 struct smbXsrv_connection *xconn = NULL;
864 if (sconn != NULL && sconn->client != NULL) {
865 xconn = sconn->client->connections;
868 for (; xconn != NULL; xconn = xconn->next) {
869 struct smbd_smb2_request *smb2req, *nextreq;
871 for (smb2req = xconn->smb2.requests; smb2req; smb2req = nextreq) {
872 struct smbd_smb2_lock_state *state = NULL;
873 files_struct *fsp_curr = NULL;
874 struct blocking_lock_record *blr = NULL;
875 const uint8_t *inhdr;
877 nextreq = smb2req->next;
879 if (smb2req->subreq == NULL) {
880 /* This message has been processed. */
883 if (!tevent_req_is_in_progress(smb2req->subreq)) {
884 /* This message has been processed. */
888 inhdr = SMBD_SMB2_IN_HDR_PTR(smb2req);
889 if (SVAL(inhdr, SMB2_HDR_OPCODE) != SMB2_OP_LOCK) {
890 /* Not a lock call. */
894 state = tevent_req_data(smb2req->subreq,
895 struct smbd_smb2_lock_state);
897 /* Strange - is this even possible ? */
901 fsp_curr = smb2req->compat_chain_fsp;
902 if (fsp_curr == NULL) {
903 /* Strange - is this even possible ? */
907 if (fsp_curr != fsp) {
908 /* It's not our fid */
914 /* Remove the entries from the lock db. */
915 brl_lock_cancel(br_lck,
917 messaging_server_id(sconn->msg_ctx),
922 /* Finally end the request. */
923 if (close_type == SHUTDOWN_CLOSE) {
924 tevent_req_done(smb2req->subreq);
926 tevent_req_nterror(smb2req->subreq,
927 NT_STATUS_RANGE_NOT_LOCKED);