* Cancel an async lock request. */
| 1601 | * Cancel an async lock request. |
| 1602 | */ |
| 1603 | static int |
| 1604 | lf_cancel(struct lockf *state, struct lockf_entry *lock, void *cookie) |
| 1605 | { |
| 1606 | struct lockf_entry *reallock; |
| 1607 | |
| 1608 | /* |
| 1609 | * We need to match this request with an existing lock |
| 1610 | * request. |
| 1611 | */ |
| 1612 | LIST_FOREACH(reallock, &state->ls_pending, lf_link) { |
| 1613 | if ((void *) reallock == cookie) { |
| 1614 | /* |
| 1615 | * Double-check that this lock looks right |
| 1616 | * (maybe use a rolling ID for the cancel |
| 1617 | * cookie instead?) |
| 1618 | */ |
| 1619 | if (!(reallock->lf_vnode == lock->lf_vnode |
| 1620 | && reallock->lf_start == lock->lf_start |
| 1621 | && reallock->lf_end == lock->lf_end)) { |
| 1622 | return (ENOENT); |
| 1623 | } |
| 1624 | |
| 1625 | /* |
| 1626 | * Make sure this lock was async and then just |
| 1627 | * remove it from its wait lists. |
| 1628 | */ |
| 1629 | if (!reallock->lf_async_task) { |
| 1630 | return (ENOENT); |
| 1631 | } |
| 1632 | |
| 1633 | /* |
| 1634 | * Note that since any other thread must take |
| 1635 | * state->ls_lock before it can possibly |
| 1636 | * trigger the async callback, we are safe |
| 1637 | * from a race with lf_wakeup_lock, i.e. we |
| 1638 | * can free the lock (actually our caller does |
| 1639 | * this). |
| 1640 | */ |
| 1641 | lf_cancel_lock(state, reallock); |
| 1642 | return (0); |
| 1643 | } |
| 1644 | } |
| 1645 | |
| 1646 | /* |
| 1647 | * We didn't find a matching lock - not much we can do here. |
| 1648 | */ |
| 1649 | return (ENOENT); |
| 1650 | } |
| 1651 | |
| 1652 | /* |
| 1653 | * Walk the list of locks for an inode and |
no test coverage detected