| 606 | } |
| 607 | |
| 608 | static struct dev_event_info * |
| 609 | devctl_alloc_dei(void) |
| 610 | { |
| 611 | struct dev_event_info *dei = NULL; |
| 612 | |
| 613 | mtx_lock(&devsoftc.mtx); |
| 614 | if (devctl_queue_length == 0) |
| 615 | goto out; |
| 616 | dei = uma_zalloc(devsoftc.zone, M_NOWAIT); |
| 617 | if (dei == NULL) |
| 618 | dei = uma_zalloc(devsoftc.zone, M_NOWAIT | M_USE_RESERVE); |
| 619 | if (dei == NULL) { |
| 620 | /* |
| 621 | * Guard against no items in the queue. Normally, this won't |
| 622 | * happen, but if lots of events happen all at once and there's |
| 623 | * a chance we're out of allocated space but none have yet been |
| 624 | * queued when we get here, leaving nothing to steal. This can |
| 625 | * also happen with error injection. Fail safe by returning |
| 626 | * NULL in that case.. |
| 627 | */ |
| 628 | if (devsoftc.queued == 0) |
| 629 | goto out; |
| 630 | dei = STAILQ_FIRST(&devsoftc.devq); |
| 631 | STAILQ_REMOVE_HEAD(&devsoftc.devq, dei_link); |
| 632 | devsoftc.queued--; |
| 633 | } |
| 634 | MPASS(dei != NULL); |
| 635 | *dei->dei_data = '\0'; |
| 636 | out: |
| 637 | mtx_unlock(&devsoftc.mtx); |
| 638 | return (dei); |
| 639 | } |
| 640 | |
| 641 | static struct dev_event_info * |
| 642 | devctl_alloc_dei_sb(struct sbuf *sb) |
no test coverage detected