Lines Matching refs:fl

148 	struct file_lock *fl;
150 LIST_FOREACH(fl, &lcklst_head, lcklst) {
152 newfl->client.svid != fl->client.svid)
155 strcmp(newfl->client_name, fl->client_name) != 0)
158 fhcmp(&newfl->filehandle, &fl->filehandle) != 0)
164 return fl;
177 struct file_lock *fl;
188 LIST_FOREACH(fl, &lcklst_head, lcklst) {
189 if (fl->status != LKST_LOCKED)
191 if (fhcmp(&fl->filehandle, &filehandle) != 0)
195 lock->caller_name, fl->client_name);
198 return (&fl->client);
217 struct file_lock *fl, *newfl;
281 fl = lock_lookup(newfl, LL_FH|LL_NAME|LL_SVID);
282 if (fl) {
289 switch(fl->status) {
302 fl->status);
308 fl = lock_lookup(newfl, LL_FH);
309 if (fl) {
361 struct file_lock *fl;
370 LIST_FOREACH(fl, &lcklst_head, lcklst) {
371 if (strcmp(fl->client_name, lck->caller_name) ||
372 fhcmp(&filehandle, &fl->filehandle) != 0 ||
373 fl->client.oh.n_len != lck->oh.n_len ||
374 memcmp(fl->client.oh.n_bytes, lck->oh.n_bytes,
375 fl->client.oh.n_len) != 0 ||
376 fl->client.svid != lck->svid)
380 "status %d", lck->caller_name, lck->svid, fl->status);
381 switch (fl->status) {
383 err = do_unlock(fl);
387 LIST_REMOVE(fl, lcklst);
388 lfree(fl);
395 fl->status = LKST_DYING;
402 fl->status, fl->client_name);
423 lfree(struct file_lock *fl)
425 free(fl->addr);
426 free(fl->client.oh.n_bytes);
427 free(fl->client_cookie.n_bytes);
428 fhfree(&fl->filehandle);
429 free(fl);
438 struct file_lock *fl;
457 LIST_FOREACH(fl, &lcklst_head, lcklst) {
458 if (pid == fl->locker)
461 if (fl == NULL) {
467 fl->locker = 0;
476 (void)do_unlock(fl);
482 pid, fl->status);
483 switch(fl->status) {
485 fl->status = LKST_LOCKED;
486 send_granted(fl, (fl->flags & LOCK_V4) ?
490 (void)do_unlock(fl);
494 " child %d", fl->status, pid);
502 * try to acquire the lock described by fl. Eventually fork a child to do a
507 do_lock(struct file_lock *fl, int block)
512 fl->fd = fhopen(fl->filehandle.fhdata, fl->filehandle.fhsize, O_RDWR);
513 if (fl->fd < 0) {
524 if ((fl->flags & LOCK_V4) == 0)
527 fl->client_name);
528 LIST_REMOVE(fl, lcklst);
531 if (fstat(fl->fd, &st) < 0) {
533 fl->client_name);
537 fl->client_name, fl->client.svid,
538 fl->client.exclusive ? " (exclusive)":"", block ? " (block)":"",
540 (unsigned long long)st.st_ino, st.st_uid, fl->flags);
542 if (fl->client.exclusive == 0)
546 error = flock(fl->fd, lflags);
548 switch (fl->locker = fork()) {
551 LIST_REMOVE(fl, lcklst);
552 (void)close(fl->fd);
553 return (fl->flags & LOCK_V4) ?
561 fl->client_name, fl->client.svid);
563 if(flock(fl->fd, lflags) != 0) {
573 fl->client_name, fl->client.svid, fl->locker);
574 fl->status = LKST_PROCESSING;
575 return (fl->flags & LOCK_V4) ?
594 if ((fl->flags & LOCK_V4) == 0)
598 fl->client_name);
600 fl->client_name);
601 LIST_REMOVE(fl, lcklst);
602 (void)close(fl->fd);
605 fl->status = LKST_LOCKED;
606 return (fl->flags & LOCK_V4) ? (enum nlm_stats)nlm4_granted : nlm_granted;
611 send_granted(struct file_lock *fl, int opcode)
620 cli = get_client(fl->addr, (rpcvers_t)
621 ((fl->flags & LOCK_V4) ? NLM_VERS4 : NLM_VERS));
624 fl->client_name, fl->client.svid);
633 timeo.tv_usec = (fl->flags & LOCK_ASYNC) ? 0 : 500000; /* 0.5s */
635 if (fl->flags & LOCK_V4) {
637 result.cookie = fl->client_cookie;
638 result.exclusive = fl->client.exclusive;
639 result.alock.caller_name = fl->client_name;
640 result.alock.fh.n_len = fl->filehandle.fhsize;
641 result.alock.fh.n_bytes = fl->filehandle.fhdata;
642 result.alock.oh = fl->client.oh;
643 result.alock.svid = fl->client.svid;
644 result.alock.l_offset = fl->client.l_offset;
645 result.alock.l_len = fl->client.l_len;
647 (fl->flags & LOCK_ASYNC) ? " (async)":"");
648 if (fl->flags & LOCK_ASYNC) {
659 result.cookie = fl->client_cookie;
660 result.exclusive = fl->client.exclusive;
661 result.alock.caller_name = fl->client_name;
662 result.alock.fh.n_len = fl->filehandle.fhsize;
663 result.alock.fh.n_bytes = fl->filehandle.fhdata;
664 result.alock.oh = fl->client.oh;
665 result.alock.svid = fl->client.svid;
667 (unsigned int)fl->client.l_offset;
669 (unsigned int)fl->client.l_len;
671 (fl->flags & LOCK_ASYNC) ? " (async)":"");
672 if (fl->flags & LOCK_ASYNC) {
690 struct file_lock *fl;
711 LIST_FOREACH(fl, &lcklst_head, lcklst) {
712 if (fl->status != LKST_WAITING ||
713 fhcmp(&rfl->filehandle, &fl->filehandle) != 0)
716 lockst = do_lock(fl, 1); /* If it's LKST_WAITING we can block */
720 send_granted(fl, (fl->flags & LOCK_V4) ?
727 lfree(fl);
814 struct file_lock *fl, *next_fl;
819 for (fl = LIST_FIRST(&lcklst_head); fl != NULL; fl = next_fl) {
820 next_fl = LIST_NEXT(fl, lcklst);
821 if (strcmp(hostname, fl->client_name) == 0 &&
822 fl->nsm_status != state) {
824 fl->status, fl->nsm_status);
825 switch(fl->status) {
827 err = do_unlock(fl);
834 LIST_REMOVE(fl, lcklst);
835 lfree(fl);
838 fl->status = LKST_DYING;
844 fl->status, fl->client_name);