* This routine must only be called for vnodes which are about to be * deallocated. Supporting dequeue for arbitrary vndoes would require * validating that the locked batch matches. */
| 3474 | * validating that the locked batch matches. |
| 3475 | */ |
| 3476 | static void |
| 3477 | vdbatch_dequeue(struct vnode *vp) |
| 3478 | { |
| 3479 | struct vdbatch *vd; |
| 3480 | int i; |
| 3481 | short cpu; |
| 3482 | |
| 3483 | VNASSERT(vp->v_type == VBAD || vp->v_type == VNON, vp, |
| 3484 | ("%s: called for a used vnode\n", __func__)); |
| 3485 | |
| 3486 | cpu = vp->v_dbatchcpu; |
| 3487 | if (cpu == NOCPU) |
| 3488 | return; |
| 3489 | |
| 3490 | vd = DPCPU_ID_PTR(cpu, vd); |
| 3491 | mtx_lock(&vd->lock); |
| 3492 | for (i = 0; i < vd->index; i++) { |
| 3493 | if (vd->tab[i] != vp) |
| 3494 | continue; |
| 3495 | vp->v_dbatchcpu = NOCPU; |
| 3496 | vd->index--; |
| 3497 | vd->tab[i] = vd->tab[vd->index]; |
| 3498 | vd->tab[vd->index] = NULL; |
| 3499 | break; |
| 3500 | } |
| 3501 | mtx_unlock(&vd->lock); |
| 3502 | /* |
| 3503 | * Either we dequeued the vnode above or the target CPU beat us to it. |
| 3504 | */ |
| 3505 | MPASS(vp->v_dbatchcpu == NOCPU); |
| 3506 | } |
| 3507 | |
| 3508 | /* |
| 3509 | * Drop the hold count of the vnode. If this is the last reference to |
no test coverage detected