r1383: sync from 3.0 tree
[Samba.git] / source / smbd / blocking.c
blob3983a4cbdfbadeca884e7f7f80f6b155e5e95877
1 /*
2 Unix SMB/CIFS implementation.
3 Blocking Locking functions
4 Copyright (C) Jeremy Allison 1998-2003
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "includes.h"
23 extern char *OutBuffer;
25 /****************************************************************************
26 This is the structure to queue to implement blocking locks.
27 notify. It consists of the requesting SMB and the expiry time.
28 *****************************************************************************/
30 typedef struct {
31 ubi_slNode msg_next;
32 int com_type;
33 files_struct *fsp;
34 time_t expire_time;
35 int lock_num;
36 SMB_BIG_UINT offset;
37 SMB_BIG_UINT count;
38 uint16 lock_pid;
39 char *inbuf;
40 int length;
41 } blocking_lock_record;
43 static ubi_slList blocking_lock_queue = { NULL, (ubi_slNodePtr)&blocking_lock_queue, 0};
45 /****************************************************************************
46 Destructor for the above structure.
47 ****************************************************************************/
49 static void free_blocking_lock_record(blocking_lock_record *blr)
51 SAFE_FREE(blr->inbuf);
52 SAFE_FREE(blr);
55 /****************************************************************************
56 Get the files_struct given a particular queued SMB.
57 *****************************************************************************/
59 static files_struct *get_fsp_from_pkt(char *inbuf)
61 switch(CVAL(inbuf,smb_com)) {
62 case SMBlock:
63 case SMBlockread:
64 return file_fsp(inbuf,smb_vwv0);
65 case SMBlockingX:
66 return file_fsp(inbuf,smb_vwv2);
67 default:
68 DEBUG(0,("get_fsp_from_pkt: PANIC - unknown type on blocking lock queue - exiting.!\n"));
69 exit_server("PANIC - unknown type on blocking lock queue");
71 return NULL; /* Keep compiler happy. */
74 /****************************************************************************
75 Determine if this is a secondary element of a chained SMB.
76 **************************************************************************/
78 static BOOL in_chained_smb(void)
80 return (chain_size != 0);
83 static void received_unlock_msg(int msg_type, pid_t src, void *buf, size_t len);
85 /****************************************************************************
86 Function to push a blocking lock request onto the lock queue.
87 ****************************************************************************/
89 BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout,
90 int lock_num, uint16 lock_pid, SMB_BIG_UINT offset, SMB_BIG_UINT count)
92 static BOOL set_lock_msg;
93 blocking_lock_record *blr;
94 BOOL my_lock_ctx = False;
95 NTSTATUS status;
97 if(in_chained_smb() ) {
98 DEBUG(0,("push_blocking_lock_request: cannot queue a chained request (currently).\n"));
99 return False;
103 * Now queue an entry on the blocking lock queue. We setup
104 * the expiration time here.
107 if((blr = (blocking_lock_record *)malloc(sizeof(blocking_lock_record))) == NULL) {
108 DEBUG(0,("push_blocking_lock_request: Malloc fail !\n" ));
109 return False;
112 if((blr->inbuf = (char *)malloc(length)) == NULL) {
113 DEBUG(0,("push_blocking_lock_request: Malloc fail (2)!\n" ));
114 SAFE_FREE(blr);
115 return False;
118 blr->com_type = CVAL(inbuf,smb_com);
119 blr->fsp = get_fsp_from_pkt(inbuf);
120 blr->expire_time = (lock_timeout == -1) ? (time_t)-1 : time(NULL) + (time_t)lock_timeout;
121 blr->lock_num = lock_num;
122 blr->lock_pid = lock_pid;
123 blr->offset = offset;
124 blr->count = count;
125 memcpy(blr->inbuf, inbuf, length);
126 blr->length = length;
128 /* Add a pending lock record for this. */
129 status = brl_lock(blr->fsp->dev, blr->fsp->inode, blr->fsp->fnum,
130 lock_pid, sys_getpid(), blr->fsp->conn->cnum,
131 offset, count, PENDING_LOCK, &my_lock_ctx);
133 if (!NT_STATUS_IS_OK(status)) {
134 DEBUG(0,("push_blocking_lock_request: failed to add PENDING_LOCK record.\n"));
135 free_blocking_lock_record(blr);
136 return False;
139 ubi_slAddTail(&blocking_lock_queue, blr);
141 /* Ensure we'll receive messages when this is unlocked. */
142 if (!set_lock_msg) {
143 message_register(MSG_SMB_UNLOCK, received_unlock_msg);
144 set_lock_msg = True;
147 DEBUG(3,("push_blocking_lock_request: lock request length=%d blocked with expiry time %d (+%d) \
148 for fnum = %d, name = %s\n", length, (int)blr->expire_time, lock_timeout,
149 blr->fsp->fnum, blr->fsp->fsp_name ));
151 /* Push the MID of this packet on the signing queue. */
152 srv_defer_sign_response(SVAL(inbuf,smb_mid));
154 return True;
157 /****************************************************************************
158 Return a smd with a given size.
159 *****************************************************************************/
161 static void send_blocking_reply(char *outbuf, int outsize)
163 if(outsize > 4)
164 smb_setlen(outbuf,outsize - 4);
166 if (!send_smb(smbd_server_fd(),outbuf))
167 exit_server("send_blocking_reply: send_smb failed.");
170 /****************************************************************************
171 Return a lockingX success SMB.
172 *****************************************************************************/
174 static void reply_lockingX_success(blocking_lock_record *blr)
176 char *outbuf = OutBuffer;
177 int bufsize = BUFFER_SIZE;
178 char *inbuf = blr->inbuf;
179 int outsize = 0;
181 construct_reply_common(inbuf, outbuf);
182 set_message(outbuf,2,0,True);
185 * As this message is a lockingX call we must handle
186 * any following chained message correctly.
187 * This is normally handled in construct_reply(),
188 * but as that calls switch_message, we can't use
189 * that here and must set up the chain info manually.
192 outsize = chain_reply(inbuf,outbuf,blr->length,bufsize);
194 outsize += chain_size;
196 send_blocking_reply(outbuf,outsize);
199 /****************************************************************************
200 Return a generic lock fail error blocking call.
201 *****************************************************************************/
203 static void generic_blocking_lock_error(blocking_lock_record *blr, NTSTATUS status)
205 char *outbuf = OutBuffer;
206 char *inbuf = blr->inbuf;
207 construct_reply_common(inbuf, outbuf);
209 /* whenever a timeout is given w2k maps LOCK_NOT_GRANTED to
210 FILE_LOCK_CONFLICT! (tridge) */
211 if (NT_STATUS_EQUAL(status, NT_STATUS_LOCK_NOT_GRANTED)) {
212 status = NT_STATUS_FILE_LOCK_CONFLICT;
215 ERROR_NT(status);
216 if (!send_smb(smbd_server_fd(),outbuf))
217 exit_server("generic_blocking_lock_error: send_smb failed.");
220 /****************************************************************************
221 Return a lock fail error for a lockingX call. Undo all the locks we have
222 obtained first.
223 *****************************************************************************/
225 static void reply_lockingX_error(blocking_lock_record *blr, NTSTATUS status)
227 char *inbuf = blr->inbuf;
228 files_struct *fsp = blr->fsp;
229 connection_struct *conn = conn_find(SVAL(inbuf,smb_tid));
230 uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
231 SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT) 0;
232 uint16 lock_pid;
233 unsigned char locktype = CVAL(inbuf,smb_vwv3);
234 BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
235 char *data;
236 int i;
238 data = smb_buf(inbuf) + ((large_file_format ? 20 : 10)*num_ulocks);
241 * Data now points at the beginning of the list
242 * of smb_lkrng structs.
246 * Ensure we don't do a remove on the lock that just failed,
247 * as under POSIX rules, if we have a lock already there, we
248 * will delete it (and we shouldn't) .....
251 for(i = blr->lock_num - 1; i >= 0; i--) {
252 BOOL err;
254 lock_pid = get_lock_pid( data, i, large_file_format);
255 count = get_lock_count( data, i, large_file_format);
256 offset = get_lock_offset( data, i, large_file_format, &err);
259 * We know err cannot be set as if it was the lock
260 * request would never have been queued. JRA.
263 do_unlock(fsp,conn,lock_pid,count,offset);
266 generic_blocking_lock_error(blr, status);
269 /****************************************************************************
270 Return a lock fail error.
271 *****************************************************************************/
273 static void blocking_lock_reply_error(blocking_lock_record *blr, NTSTATUS status)
275 switch(blr->com_type) {
276 case SMBlock:
277 case SMBlockread:
278 generic_blocking_lock_error(blr, status);
279 break;
280 case SMBlockingX:
281 reply_lockingX_error(blr, status);
282 break;
283 default:
284 DEBUG(0,("blocking_lock_reply_error: PANIC - unknown type on blocking lock queue - exiting.!\n"));
285 exit_server("PANIC - unknown type on blocking lock queue");
289 /****************************************************************************
290 Attempt to finish off getting all pending blocking locks for a lockread call.
291 Returns True if we want to be removed from the list.
292 *****************************************************************************/
294 static BOOL process_lockread(blocking_lock_record *blr)
296 char *outbuf = OutBuffer;
297 char *inbuf = blr->inbuf;
298 ssize_t nread = -1;
299 char *data, *p;
300 int outsize = 0;
301 SMB_BIG_UINT startpos;
302 size_t numtoread;
303 NTSTATUS status;
304 connection_struct *conn = conn_find(SVAL(inbuf,smb_tid));
305 files_struct *fsp = blr->fsp;
306 BOOL my_lock_ctx = False;
308 numtoread = SVAL(inbuf,smb_vwv1);
309 startpos = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv2);
311 numtoread = MIN(BUFFER_SIZE-outsize,numtoread);
312 data = smb_buf(outbuf) + 3;
314 status = do_lock_spin( fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtoread, startpos, READ_LOCK, &my_lock_ctx);
315 if (NT_STATUS_V(status)) {
316 if (!NT_STATUS_EQUAL(status,NT_STATUS_LOCK_NOT_GRANTED) &&
317 !NT_STATUS_EQUAL(status,NT_STATUS_FILE_LOCK_CONFLICT)) {
319 * We have other than a "can't get lock"
320 * error. Send an error.
321 * Return True so we get dequeued.
323 generic_blocking_lock_error(blr, status);
324 return True;
328 * Still waiting for lock....
331 DEBUG(10,("process_lockread: failed to get lock for file = %s. Still waiting....\n",
332 fsp->fsp_name));
333 return False;
336 nread = read_file(fsp,data,startpos,numtoread);
338 if (nread < 0) {
339 generic_blocking_lock_error(blr,NT_STATUS_ACCESS_DENIED);
340 return True;
343 construct_reply_common(inbuf, outbuf);
344 outsize = set_message(outbuf,5,0,True);
346 outsize += nread;
347 SSVAL(outbuf,smb_vwv0,nread);
348 SSVAL(outbuf,smb_vwv5,nread+3);
349 p = smb_buf(outbuf);
350 *p++ = 1;
351 SSVAL(p,0,nread); p += 2;
352 set_message_end(outbuf, p+nread);
354 DEBUG(3, ( "process_lockread file = %s, fnum=%d num=%d nread=%d\n",
355 fsp->fsp_name, fsp->fnum, (int)numtoread, (int)nread ) );
357 send_blocking_reply(outbuf,outsize);
358 return True;
361 /****************************************************************************
362 Attempt to finish off getting all pending blocking locks for a lock call.
363 Returns True if we want to be removed from the list.
364 *****************************************************************************/
366 static BOOL process_lock(blocking_lock_record *blr)
368 char *outbuf = OutBuffer;
369 char *inbuf = blr->inbuf;
370 int outsize;
371 SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT)0;
372 NTSTATUS status;
373 connection_struct *conn = conn_find(SVAL(inbuf,smb_tid));
374 files_struct *fsp = blr->fsp;
375 BOOL my_lock_ctx = False;
377 count = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv1);
378 offset = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv3);
380 errno = 0;
381 status = do_lock_spin(fsp, conn, SVAL(inbuf,smb_pid), count, offset, WRITE_LOCK, &my_lock_ctx);
382 if (NT_STATUS_IS_ERR(status)) {
383 if (!NT_STATUS_EQUAL(status,NT_STATUS_LOCK_NOT_GRANTED) &&
384 !NT_STATUS_EQUAL(status,NT_STATUS_FILE_LOCK_CONFLICT)) {
386 * We have other than a "can't get lock"
387 * error. Send an error.
388 * Return True so we get dequeued.
391 blocking_lock_reply_error(blr, status);
392 return True;
395 * Still can't get the lock - keep waiting.
397 DEBUG(10,("process_lock: failed to get lock for file = %s. Still waiting....\n",
398 fsp->fsp_name));
399 return False;
403 * Success - we got the lock.
406 DEBUG(3,("process_lock : file=%s fnum=%d offset=%.0f count=%.0f\n",
407 fsp->fsp_name, fsp->fnum, (double)offset, (double)count));
409 construct_reply_common(inbuf, outbuf);
410 outsize = set_message(outbuf,0,0,True);
411 send_blocking_reply(outbuf,outsize);
412 return True;
415 /****************************************************************************
416 Attempt to finish off getting all pending blocking locks for a lockingX call.
417 Returns True if we want to be removed from the list.
418 *****************************************************************************/
420 static BOOL process_lockingX(blocking_lock_record *blr)
422 char *inbuf = blr->inbuf;
423 unsigned char locktype = CVAL(inbuf,smb_vwv3);
424 files_struct *fsp = blr->fsp;
425 connection_struct *conn = conn_find(SVAL(inbuf,smb_tid));
426 uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
427 uint16 num_locks = SVAL(inbuf,smb_vwv7);
428 SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT)0;
429 uint16 lock_pid;
430 BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
431 char *data;
432 BOOL my_lock_ctx = False;
433 NTSTATUS status = NT_STATUS_OK;
435 data = smb_buf(inbuf) + ((large_file_format ? 20 : 10)*num_ulocks);
438 * Data now points at the beginning of the list
439 * of smb_lkrng structs.
442 for(; blr->lock_num < num_locks; blr->lock_num++) {
443 BOOL err;
445 lock_pid = get_lock_pid( data, blr->lock_num, large_file_format);
446 count = get_lock_count( data, blr->lock_num, large_file_format);
447 offset = get_lock_offset( data, blr->lock_num, large_file_format, &err);
450 * We know err cannot be set as if it was the lock
451 * request would never have been queued. JRA.
453 errno = 0;
454 status = do_lock_spin(fsp,conn,lock_pid,count,offset,
455 ((locktype & 1) ? READ_LOCK : WRITE_LOCK), &my_lock_ctx);
456 if (NT_STATUS_IS_ERR(status)) break;
459 if(blr->lock_num == num_locks) {
461 * Success - we got all the locks.
464 DEBUG(3,("process_lockingX file = %s, fnum=%d type=%d num_locks=%d\n",
465 fsp->fsp_name, fsp->fnum, (unsigned int)locktype, num_locks) );
467 reply_lockingX_success(blr);
468 return True;
469 } else if (!NT_STATUS_EQUAL(status,NT_STATUS_LOCK_NOT_GRANTED) &&
470 !NT_STATUS_EQUAL(status,NT_STATUS_FILE_LOCK_CONFLICT)) {
472 * We have other than a "can't get lock"
473 * error. Free any locks we had and return an error.
474 * Return True so we get dequeued.
477 blocking_lock_reply_error(blr, status);
478 return True;
482 * Still can't get all the locks - keep waiting.
485 DEBUG(10,("process_lockingX: only got %d locks of %d needed for file %s, fnum = %d. \
486 Waiting....\n",
487 blr->lock_num, num_locks, fsp->fsp_name, fsp->fnum));
489 return False;
492 /****************************************************************************
493 Process a blocking lock SMB.
494 Returns True if we want to be removed from the list.
495 *****************************************************************************/
497 static BOOL blocking_lock_record_process(blocking_lock_record *blr)
499 switch(blr->com_type) {
500 case SMBlock:
501 return process_lock(blr);
502 case SMBlockread:
503 return process_lockread(blr);
504 case SMBlockingX:
505 return process_lockingX(blr);
506 default:
507 DEBUG(0,("blocking_lock_record_process: PANIC - unknown type on blocking lock queue - exiting.!\n"));
508 exit_server("PANIC - unknown type on blocking lock queue");
510 return False; /* Keep compiler happy. */
513 /****************************************************************************
514 Delete entries by fnum from the blocking lock pending queue.
515 *****************************************************************************/
517 void remove_pending_lock_requests_by_fid(files_struct *fsp)
519 blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst( &blocking_lock_queue );
520 blocking_lock_record *prev = NULL;
522 while(blr != NULL) {
523 if(blr->fsp->fnum == fsp->fnum) {
525 DEBUG(10,("remove_pending_lock_requests_by_fid - removing request type %d for \
526 file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
528 brl_unlock(blr->fsp->dev, blr->fsp->inode, blr->fsp->fnum,
529 blr->lock_pid, sys_getpid(), blr->fsp->conn->cnum,
530 blr->offset, blr->count, True, NULL, NULL);
532 free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
533 blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
534 continue;
537 prev = blr;
538 blr = (blocking_lock_record *)ubi_slNext(blr);
542 /****************************************************************************
543 Delete entries by mid from the blocking lock pending queue. Always send reply.
544 *****************************************************************************/
546 void remove_pending_lock_requests_by_mid(int mid)
548 blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst( &blocking_lock_queue );
549 blocking_lock_record *prev = NULL;
551 while(blr != NULL) {
552 if(SVAL(blr->inbuf,smb_mid) == mid) {
553 files_struct *fsp = blr->fsp;
555 DEBUG(10,("remove_pending_lock_requests_by_mid - removing request type %d for \
556 file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
558 blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
559 brl_unlock(blr->fsp->dev, blr->fsp->inode, blr->fsp->fnum,
560 blr->lock_pid, sys_getpid(), blr->fsp->conn->cnum,
561 blr->offset, blr->count, True, NULL, NULL);
562 free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
563 blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
564 continue;
567 prev = blr;
568 blr = (blocking_lock_record *)ubi_slNext(blr);
572 /****************************************************************************
573 Set a flag as an unlock request affects one of our pending locks.
574 *****************************************************************************/
576 static void received_unlock_msg(int msg_type, pid_t src, void *buf, size_t len)
578 DEBUG(10,("received_unlock_msg\n"));
579 process_blocking_lock_queue(time(NULL));
582 /****************************************************************************
583 Return the number of seconds to the next blocking locks timeout, or default_timeout
584 *****************************************************************************/
586 unsigned blocking_locks_timeout(unsigned default_timeout)
588 unsigned timeout = default_timeout;
589 time_t t;
590 blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst(&blocking_lock_queue);
592 /* note that we avoid the time() syscall if there are no blocking locks */
593 if (!blr)
594 return timeout;
596 t = time(NULL);
598 while (blr) {
599 if ((blr->expire_time != (time_t)-1) &&
600 (timeout > (blr->expire_time - t))) {
601 timeout = blr->expire_time - t;
603 blr = (blocking_lock_record *)ubi_slNext(blr);
606 if (timeout < 1)
607 timeout = 1;
609 return timeout;
612 /****************************************************************************
613 Process the blocking lock queue. Note that this is only called as root.
614 *****************************************************************************/
616 void process_blocking_lock_queue(time_t t)
618 blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst( &blocking_lock_queue );
619 blocking_lock_record *prev = NULL;
621 if(blr == NULL)
622 return;
625 * Go through the queue and see if we can get any of the locks.
628 while(blr != NULL) {
629 connection_struct *conn = NULL;
630 uint16 vuid;
631 files_struct *fsp = NULL;
634 * Ensure we don't have any old chain_fsp values
635 * sitting around....
637 chain_size = 0;
638 file_chain_reset();
639 fsp = blr->fsp;
641 conn = conn_find(SVAL(blr->inbuf,smb_tid));
642 vuid = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID :
643 SVAL(blr->inbuf,smb_uid);
645 DEBUG(5,("process_blocking_lock_queue: examining pending lock fnum = %d for file %s\n",
646 fsp->fnum, fsp->fsp_name ));
648 if((blr->expire_time != -1) && (blr->expire_time <= t)) {
650 * Lock expired - throw away all previously
651 * obtained locks and return lock error.
653 DEBUG(5,("process_blocking_lock_queue: pending lock fnum = %d for file %s timed out.\n",
654 fsp->fnum, fsp->fsp_name ));
656 brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
657 blr->lock_pid, sys_getpid(), conn->cnum,
658 blr->offset, blr->count, True, NULL, NULL);
660 blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
661 free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
662 blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
663 continue;
666 if(!change_to_user(conn,vuid)) {
667 DEBUG(0,("process_blocking_lock_queue: Unable to become user vuid=%d.\n",
668 vuid ));
670 * Remove the entry and return an error to the client.
672 blocking_lock_reply_error(blr,NT_STATUS_ACCESS_DENIED);
674 brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
675 blr->lock_pid, sys_getpid(), conn->cnum,
676 blr->offset, blr->count, True, NULL, NULL);
678 free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
679 blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
680 continue;
683 if(!set_current_service(conn,SVAL(blr->inbuf,smb_flg),True)) {
684 DEBUG(0,("process_blocking_lock_queue: Unable to become service Error was %s.\n", strerror(errno) ));
686 * Remove the entry and return an error to the client.
688 blocking_lock_reply_error(blr,NT_STATUS_ACCESS_DENIED);
690 brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
691 blr->lock_pid, sys_getpid(), conn->cnum,
692 blr->offset, blr->count, True, NULL, NULL);
694 free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
695 blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
696 change_to_root_user();
697 continue;
701 * Go through the remaining locks and try and obtain them.
702 * The call returns True if all locks were obtained successfully
703 * and False if we still need to wait.
706 if(blocking_lock_record_process(blr)) {
708 brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
709 blr->lock_pid, sys_getpid(), conn->cnum,
710 blr->offset, blr->count, True, NULL, NULL);
712 free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
713 blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
714 change_to_root_user();
715 continue;
718 change_to_root_user();
721 * Move to the next in the list.
723 prev = blr;
724 blr = (blocking_lock_record *)ubi_slNext(blr);