MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lf_free_lock

Function lf_free_lock

freebsd/kern/kern_lockf.c:357–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355}
356
357static int
358lf_free_lock(struct lockf_entry *lock)
359{
360 struct sx *chainlock;
361
362 KASSERT(lock->lf_refs > 0, ("lockf_entry negative ref count %p", lock));
363 if (--lock->lf_refs > 0)
364 return (0);
365 /*
366 * Adjust the lock_owner reference count and
367 * reclaim the entry if this is the last lock
368 * for that owner.
369 */
370 struct lock_owner *lo = lock->lf_owner;
371 if (lo) {
372 KASSERT(LIST_EMPTY(&lock->lf_outedges),
373 ("freeing lock with dependencies"));
374 KASSERT(LIST_EMPTY(&lock->lf_inedges),
375 ("freeing lock with dependants"));
376 chainlock = &lf_lock_owners[lo->lo_hash].lock;
377 sx_xlock(chainlock);
378 KASSERT(lo->lo_refs > 0, ("lock owner refcount"));
379 lo->lo_refs--;
380 if (lo->lo_refs == 0) {
381#ifdef LOCKF_DEBUG
382 if (lockf_debug & 1)
383 printf("lf_free_lock: freeing lock owner %p\n",
384 lo);
385#endif
386 if (lo->lo_vertex) {
387 sx_xlock(&lf_owner_graph_lock);
388 graph_free_vertex(&lf_owner_graph,
389 lo->lo_vertex);
390 sx_xunlock(&lf_owner_graph_lock);
391 }
392 LIST_REMOVE(lo, lo_link);
393 free(lo, M_LOCKF);
394#ifdef LOCKF_DEBUG
395 if (lockf_debug & 4)
396 printf("Freed lock owner %p\n", lo);
397#endif
398 }
399 sx_unlock(chainlock);
400 }
401 if ((lock->lf_flags & F_REMOTE) && lock->lf_vnode) {
402 vrele(lock->lf_vnode);
403 lock->lf_vnode = NULL;
404 }
405#ifdef LOCKF_DEBUG
406 if (lockf_debug & 4)
407 printf("Freed lock %p\n", lock);
408#endif
409 free(lock, M_LOCKF);
410 return (1);
411}
412
413/*
414 * Advisory record locking support

Callers 5

lf_advlockasyncFunction · 0.85
lf_purgelocksFunction · 0.85
lf_activate_lockFunction · 0.85
lf_cancel_lockFunction · 0.85
lf_setlockFunction · 0.85

Calls 4

graph_free_vertexFunction · 0.85
printfFunction · 0.70
freeFunction · 0.70
vreleFunction · 0.70

Tested by

no test coverage detected