kern_alq.c revision 121508
1103785Sjeff/* 2103785Sjeff * Copyright (c) 2002, Jeffrey Roberson <jeff@freebsd.org> 3103785Sjeff * All rights reserved. 4103785Sjeff * 5103785Sjeff * Redistribution and use in source and binary forms, with or without 6103785Sjeff * modification, are permitted provided that the following conditions 7103785Sjeff * are met: 8103785Sjeff * 1. Redistributions of source code must retain the above copyright 9103785Sjeff * notice unmodified, this list of conditions, and the following 10103785Sjeff * disclaimer. 11103785Sjeff * 2. Redistributions in binary form must reproduce the above copyright 12103785Sjeff * notice, this list of conditions and the following disclaimer in the 13103785Sjeff * documentation and/or other materials provided with the distribution. 14103785Sjeff * 15103785Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16103785Sjeff * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17103785Sjeff * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18103785Sjeff * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19103785Sjeff * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20103785Sjeff * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21103785Sjeff * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22103785Sjeff * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23103785Sjeff * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24103785Sjeff * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25103785Sjeff */ 26103785Sjeff 27116182Sobrien#include <sys/cdefs.h> 28116182Sobrien__FBSDID("$FreeBSD: head/sys/kern/kern_alq.c 121508 2003-10-25 16:10:41Z rwatson $"); 29116182Sobrien 30121508Srwatson#include "opt_mac.h" 31121508Srwatson 32103785Sjeff#include <sys/param.h> 33103785Sjeff#include <sys/systm.h> 34103785Sjeff#include <sys/kernel.h> 35103785Sjeff#include <sys/kthread.h> 36103785Sjeff#include <sys/lock.h> 37121508Srwatson#include <sys/mac.h> 38103785Sjeff#include <sys/mutex.h> 39103785Sjeff#include <sys/namei.h> 40103785Sjeff#include <sys/proc.h> 41103785Sjeff#include <sys/vnode.h> 42103785Sjeff#include <sys/alq.h> 43103785Sjeff#include <sys/malloc.h> 44103785Sjeff#include <sys/unistd.h> 45103785Sjeff#include <sys/fcntl.h> 46103785Sjeff#include <sys/eventhandler.h> 47103785Sjeff 48103785Sjeff/* Async. Logging Queue */ 49103785Sjeffstruct alq { 50103785Sjeff int aq_entmax; /* Max entries */ 51103785Sjeff int aq_entlen; /* Entry length */ 52103785Sjeff char *aq_entbuf; /* Buffer for stored entries */ 53103785Sjeff int aq_flags; /* Queue flags */ 54103785Sjeff struct mtx aq_mtx; /* Queue lock */ 55103785Sjeff struct vnode *aq_vp; /* Open vnode handle */ 56103830Sjeff struct ucred *aq_cred; /* Credentials of the opening thread */ 57103785Sjeff struct ale *aq_first; /* First ent */ 58103785Sjeff struct ale *aq_entfree; /* First free ent */ 59103785Sjeff struct ale *aq_entvalid; /* First ent valid for writing */ 60103785Sjeff LIST_ENTRY(alq) aq_act; /* List of active queues */ 61103785Sjeff LIST_ENTRY(alq) aq_link; /* List of all queues */ 62103785Sjeff}; 63103785Sjeff 64103785Sjeff#define AQ_WANTED 0x0001 /* Wakeup sleeper when io is done */ 65103785Sjeff#define AQ_ACTIVE 0x0002 /* on the active list */ 66103785Sjeff#define AQ_FLUSHING 0x0004 /* doing IO */ 67103785Sjeff#define AQ_SHUTDOWN 0x0008 /* Queue no longer valid */ 68103785Sjeff 69103785Sjeff#define ALQ_LOCK(alq) mtx_lock_spin(&(alq)->aq_mtx) 70103785Sjeff#define ALQ_UNLOCK(alq) mtx_unlock_spin(&(alq)->aq_mtx) 71103785Sjeff 72103785Sjeffstatic MALLOC_DEFINE(M_ALD, "ALD", "ALD"); 73103785Sjeff 74103785Sjeff/* 75103785Sjeff * The ald_mtx protects the ald_queues list and the ald_active list. 76103785Sjeff */ 77103785Sjeffstatic struct mtx ald_mtx; 78103785Sjeffstatic LIST_HEAD(, alq) ald_queues; 79103785Sjeffstatic LIST_HEAD(, alq) ald_active; 80103785Sjeffstatic int ald_shutingdown = 0; 81103995Sjeffstruct thread *ald_thread; 82103995Sjeffstatic struct proc *ald_proc; 83103785Sjeff 84103785Sjeff#define ALD_LOCK() mtx_lock(&ald_mtx) 85103785Sjeff#define ALD_UNLOCK() mtx_unlock(&ald_mtx) 86103785Sjeff 87103785Sjeff/* Daemon functions */ 88103785Sjeffstatic int ald_add(struct alq *); 89103785Sjeffstatic int ald_rem(struct alq *); 90103785Sjeffstatic void ald_startup(void *); 91103785Sjeffstatic void ald_daemon(void); 92103785Sjeffstatic void ald_shutdown(void *, int); 93103785Sjeffstatic void ald_activate(struct alq *); 94103785Sjeffstatic void ald_deactivate(struct alq *); 95103785Sjeff 96103785Sjeff/* Internal queue functions */ 97103785Sjeffstatic void alq_shutdown(struct alq *); 98103785Sjeffstatic int alq_doio(struct alq *); 99103785Sjeff 100103785Sjeff 101103785Sjeff/* 102103785Sjeff * Add a new queue to the global list. Fail if we're shutting down. 103103785Sjeff */ 104103785Sjeffstatic int 105103785Sjeffald_add(struct alq *alq) 106103785Sjeff{ 107103785Sjeff int error; 108103785Sjeff 109103785Sjeff error = 0; 110103785Sjeff 111103785Sjeff ALD_LOCK(); 112103785Sjeff if (ald_shutingdown) { 113103785Sjeff error = EBUSY; 114103785Sjeff goto done; 115103785Sjeff } 116103785Sjeff LIST_INSERT_HEAD(&ald_queues, alq, aq_link); 117103785Sjeffdone: 118103785Sjeff ALD_UNLOCK(); 119103785Sjeff return (error); 120103785Sjeff} 121103785Sjeff 122103785Sjeff/* 123103785Sjeff * Remove a queue from the global list unless we're shutting down. If so, 124103785Sjeff * the ald will take care of cleaning up it's resources. 125103785Sjeff */ 126103785Sjeffstatic int 127103785Sjeffald_rem(struct alq *alq) 128103785Sjeff{ 129103785Sjeff int error; 130103785Sjeff 131103785Sjeff error = 0; 132103785Sjeff 133103785Sjeff ALD_LOCK(); 134103785Sjeff if (ald_shutingdown) { 135103785Sjeff error = EBUSY; 136103785Sjeff goto done; 137103785Sjeff } 138103785Sjeff LIST_REMOVE(alq, aq_link); 139103785Sjeffdone: 140103785Sjeff ALD_UNLOCK(); 141103785Sjeff return (error); 142103785Sjeff} 143103785Sjeff 144103785Sjeff/* 145103785Sjeff * Put a queue on the active list. This will schedule it for writing. 146103785Sjeff */ 147103785Sjeffstatic void 148103785Sjeffald_activate(struct alq *alq) 149103785Sjeff{ 150103785Sjeff LIST_INSERT_HEAD(&ald_active, alq, aq_act); 151103785Sjeff wakeup(&ald_active); 152103785Sjeff} 153103785Sjeff 154103785Sjeffstatic void 155103785Sjeffald_deactivate(struct alq *alq) 156103785Sjeff{ 157103785Sjeff LIST_REMOVE(alq, aq_act); 158103785Sjeff alq->aq_flags &= ~AQ_ACTIVE; 159103785Sjeff} 160103785Sjeff 161103785Sjeffstatic void 162103785Sjeffald_startup(void *unused) 163103785Sjeff{ 164103785Sjeff mtx_init(&ald_mtx, "ALDmtx", NULL, MTX_DEF|MTX_QUIET); 165103785Sjeff LIST_INIT(&ald_queues); 166103785Sjeff LIST_INIT(&ald_active); 167103785Sjeff} 168103785Sjeff 169103785Sjeffstatic void 170103785Sjeffald_daemon(void) 171103785Sjeff{ 172103785Sjeff int needwakeup; 173103785Sjeff struct alq *alq; 174103785Sjeff 175103785Sjeff mtx_lock(&Giant); 176103785Sjeff 177103995Sjeff ald_thread = FIRST_THREAD_IN_PROC(ald_proc); 178103995Sjeff 179103785Sjeff EVENTHANDLER_REGISTER(shutdown_pre_sync, ald_shutdown, NULL, 180103785Sjeff SHUTDOWN_PRI_FIRST); 181103785Sjeff 182103785Sjeff ALD_LOCK(); 183103785Sjeff 184103785Sjeff for (;;) { 185103785Sjeff while ((alq = LIST_FIRST(&ald_active)) == NULL) 186103785Sjeff msleep(&ald_active, &ald_mtx, PWAIT, "aldslp", 0); 187103785Sjeff 188103785Sjeff ALQ_LOCK(alq); 189103785Sjeff ald_deactivate(alq); 190103785Sjeff ALD_UNLOCK(); 191103785Sjeff needwakeup = alq_doio(alq); 192103785Sjeff ALQ_UNLOCK(alq); 193103785Sjeff if (needwakeup) 194103785Sjeff wakeup(alq); 195103785Sjeff ALD_LOCK(); 196103785Sjeff } 197103785Sjeff} 198103785Sjeff 199103785Sjeffstatic void 200103785Sjeffald_shutdown(void *arg, int howto) 201103785Sjeff{ 202103785Sjeff struct alq *alq; 203103785Sjeff 204103785Sjeff ALD_LOCK(); 205103785Sjeff ald_shutingdown = 1; 206103785Sjeff 207103785Sjeff while ((alq = LIST_FIRST(&ald_queues)) != NULL) { 208103785Sjeff LIST_REMOVE(alq, aq_link); 209103785Sjeff ALD_UNLOCK(); 210103785Sjeff alq_shutdown(alq); 211103785Sjeff ALD_LOCK(); 212103785Sjeff } 213103785Sjeff ALD_UNLOCK(); 214103785Sjeff} 215103785Sjeff 216103785Sjeffstatic void 217103785Sjeffalq_shutdown(struct alq *alq) 218103785Sjeff{ 219103785Sjeff ALQ_LOCK(alq); 220103785Sjeff 221103785Sjeff /* Stop any new writers. */ 222103785Sjeff alq->aq_flags |= AQ_SHUTDOWN; 223103785Sjeff 224103785Sjeff /* Drain IO */ 225103785Sjeff while (alq->aq_flags & (AQ_FLUSHING|AQ_ACTIVE)) { 226103785Sjeff alq->aq_flags |= AQ_WANTED; 227103785Sjeff ALQ_UNLOCK(alq); 228103785Sjeff tsleep(alq, PWAIT, "aldclose", 0); 229103785Sjeff ALQ_LOCK(alq); 230103785Sjeff } 231103785Sjeff ALQ_UNLOCK(alq); 232103785Sjeff 233103995Sjeff vn_close(alq->aq_vp, FWRITE, alq->aq_cred, 234103830Sjeff curthread); 235103830Sjeff crfree(alq->aq_cred); 236103785Sjeff} 237103785Sjeff 238103785Sjeff/* 239103785Sjeff * Flush all pending data to disk. This operation will block. 240103785Sjeff */ 241103785Sjeffstatic int 242103785Sjeffalq_doio(struct alq *alq) 243103785Sjeff{ 244103785Sjeff struct thread *td; 245103785Sjeff struct mount *mp; 246103785Sjeff struct vnode *vp; 247103785Sjeff struct uio auio; 248103785Sjeff struct iovec aiov[2]; 249103785Sjeff struct ale *ale; 250103785Sjeff struct ale *alstart; 251103785Sjeff int totlen; 252103785Sjeff int iov; 253103785Sjeff 254103785Sjeff vp = alq->aq_vp; 255103785Sjeff td = curthread; 256103785Sjeff totlen = 0; 257103785Sjeff iov = 0; 258103785Sjeff 259103785Sjeff alstart = ale = alq->aq_entvalid; 260103785Sjeff alq->aq_entvalid = NULL; 261103785Sjeff 262103785Sjeff bzero(&aiov, sizeof(aiov)); 263103785Sjeff bzero(&auio, sizeof(auio)); 264103785Sjeff 265103785Sjeff do { 266103785Sjeff if (aiov[iov].iov_base == NULL) 267103785Sjeff aiov[iov].iov_base = ale->ae_data; 268103785Sjeff aiov[iov].iov_len += alq->aq_entlen; 269103785Sjeff totlen += alq->aq_entlen; 270103785Sjeff /* Check to see if we're wrapping the buffer */ 271103785Sjeff if (ale->ae_data + alq->aq_entlen != ale->ae_next->ae_data) 272103785Sjeff iov++; 273103785Sjeff ale->ae_flags &= ~AE_VALID; 274103785Sjeff ale = ale->ae_next; 275103785Sjeff } while (ale->ae_flags & AE_VALID); 276103785Sjeff 277103785Sjeff alq->aq_flags |= AQ_FLUSHING; 278103785Sjeff ALQ_UNLOCK(alq); 279103785Sjeff 280103785Sjeff if (iov == 2 || aiov[iov].iov_base == NULL) 281103785Sjeff iov--; 282103785Sjeff 283103785Sjeff auio.uio_iov = &aiov[0]; 284103785Sjeff auio.uio_offset = 0; 285103785Sjeff auio.uio_segflg = UIO_SYSSPACE; 286103785Sjeff auio.uio_rw = UIO_WRITE; 287103785Sjeff auio.uio_iovcnt = iov + 1; 288103785Sjeff auio.uio_resid = totlen; 289103785Sjeff auio.uio_td = td; 290103785Sjeff 291103785Sjeff /* 292103785Sjeff * Do all of the junk required to write now. 293103785Sjeff */ 294103785Sjeff vn_start_write(vp, &mp, V_WAIT); 295103785Sjeff vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 296103830Sjeff VOP_LEASE(vp, td, alq->aq_cred, LEASE_WRITE); 297121508Srwatson /* 298121508Srwatson * XXX: VOP_WRITE error checks are ignored. 299121508Srwatson */ 300121508Srwatson#ifdef MAC 301121508Srwatson if (mac_check_vnode_write(alq->aq_cred, NOCRED, vp) == 0) 302121508Srwatson#endif 303121508Srwatson VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, alq->aq_cred); 304103785Sjeff VOP_UNLOCK(vp, 0, td); 305103785Sjeff vn_finished_write(mp); 306103785Sjeff 307103785Sjeff ALQ_LOCK(alq); 308103785Sjeff alq->aq_flags &= ~AQ_FLUSHING; 309103785Sjeff 310103785Sjeff if (alq->aq_entfree == NULL) 311103785Sjeff alq->aq_entfree = alstart; 312103785Sjeff 313103785Sjeff if (alq->aq_flags & AQ_WANTED) { 314103785Sjeff alq->aq_flags &= ~AQ_WANTED; 315103785Sjeff return (1); 316103785Sjeff } 317103785Sjeff 318103785Sjeff return(0); 319103785Sjeff} 320103785Sjeff 321103785Sjeffstatic struct kproc_desc ald_kp = { 322103785Sjeff "ALQ Daemon", 323103785Sjeff ald_daemon, 324103995Sjeff &ald_proc 325103785Sjeff}; 326103785Sjeff 327103785SjeffSYSINIT(aldthread, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, kproc_start, &ald_kp) 328103785SjeffSYSINIT(ald, SI_SUB_LOCK, SI_ORDER_ANY, ald_startup, NULL) 329103785Sjeff 330103785Sjeff 331103785Sjeff/* User visible queue functions */ 332103785Sjeff 333103785Sjeff/* 334103785Sjeff * Create the queue data structure, allocate the buffer, and open the file. 335103785Sjeff */ 336103785Sjeffint 337116697Srwatsonalq_open(struct alq **alqp, const char *file, struct ucred *cred, int size, 338116697Srwatson int count) 339103785Sjeff{ 340103785Sjeff struct thread *td; 341103785Sjeff struct nameidata nd; 342103785Sjeff struct ale *ale; 343103785Sjeff struct ale *alp; 344103785Sjeff struct alq *alq; 345103785Sjeff char *bufp; 346103785Sjeff int flags; 347103785Sjeff int error; 348103785Sjeff int i; 349103785Sjeff 350103785Sjeff *alqp = NULL; 351103785Sjeff td = curthread; 352103785Sjeff 353103785Sjeff NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, file, td); 354103995Sjeff flags = FWRITE | O_NOFOLLOW | O_CREAT; 355103785Sjeff 356118094Sphk error = vn_open_cred(&nd, &flags, 0, cred, -1); 357103785Sjeff if (error) 358103785Sjeff return (error); 359103785Sjeff 360103785Sjeff NDFREE(&nd, NDF_ONLY_PNBUF); 361103785Sjeff /* We just unlock so we hold a reference */ 362103785Sjeff VOP_UNLOCK(nd.ni_vp, 0, td); 363103785Sjeff 364111119Simp alq = malloc(sizeof(*alq), M_ALD, M_WAITOK|M_ZERO); 365111119Simp alq->aq_entbuf = malloc(count * size, M_ALD, M_WAITOK|M_ZERO); 366111119Simp alq->aq_first = malloc(sizeof(*ale) * count, M_ALD, M_WAITOK|M_ZERO); 367103785Sjeff alq->aq_vp = nd.ni_vp; 368116697Srwatson alq->aq_cred = crhold(cred); 369103785Sjeff alq->aq_entmax = count; 370103785Sjeff alq->aq_entlen = size; 371103785Sjeff alq->aq_entfree = alq->aq_first; 372103785Sjeff 373103785Sjeff mtx_init(&alq->aq_mtx, "ALD Queue", NULL, MTX_SPIN|MTX_QUIET); 374103785Sjeff 375103785Sjeff bufp = alq->aq_entbuf; 376103785Sjeff ale = alq->aq_first; 377103785Sjeff alp = NULL; 378103785Sjeff 379103785Sjeff /* Match up entries with buffers */ 380103785Sjeff for (i = 0; i < count; i++) { 381103785Sjeff if (alp) 382103785Sjeff alp->ae_next = ale; 383103785Sjeff ale->ae_data = bufp; 384103785Sjeff alp = ale; 385103785Sjeff ale++; 386103785Sjeff bufp += size; 387103785Sjeff } 388103785Sjeff 389103785Sjeff alp->ae_next = alq->aq_first; 390103785Sjeff 391103785Sjeff if ((error = ald_add(alq)) != 0) 392103785Sjeff return (error); 393103785Sjeff *alqp = alq; 394103785Sjeff 395103785Sjeff return (0); 396103785Sjeff} 397103785Sjeff 398103785Sjeff/* 399103785Sjeff * Copy a new entry into the queue. If the operation would block either 400103785Sjeff * wait or return an error depending on the value of waitok. 401103785Sjeff */ 402103785Sjeffint 403103785Sjeffalq_write(struct alq *alq, void *data, int waitok) 404103785Sjeff{ 405103785Sjeff struct ale *ale; 406103785Sjeff 407103785Sjeff if ((ale = alq_get(alq, waitok)) == NULL) 408103785Sjeff return (EWOULDBLOCK); 409103785Sjeff 410103785Sjeff bcopy(data, ale->ae_data, alq->aq_entlen); 411103785Sjeff alq_post(alq, ale); 412103785Sjeff 413103785Sjeff return (0); 414103785Sjeff} 415103785Sjeff 416103785Sjeffstruct ale * 417103785Sjeffalq_get(struct alq *alq, int waitok) 418103785Sjeff{ 419103785Sjeff struct ale *ale; 420103785Sjeff struct ale *aln; 421103785Sjeff 422103785Sjeff ale = NULL; 423103785Sjeff 424103785Sjeff ALQ_LOCK(alq); 425103785Sjeff 426103785Sjeff /* Loop until we get an entry or we're shutting down */ 427103785Sjeff while ((alq->aq_flags & AQ_SHUTDOWN) == 0 && 428103785Sjeff (ale = alq->aq_entfree) == NULL && 429103785Sjeff (waitok & ALQ_WAITOK)) { 430103785Sjeff alq->aq_flags |= AQ_WANTED; 431103785Sjeff ALQ_UNLOCK(alq); 432103785Sjeff tsleep(alq, PWAIT, "alqget", 0); 433103785Sjeff ALQ_LOCK(alq); 434103785Sjeff } 435103785Sjeff 436103785Sjeff if (ale != NULL) { 437103785Sjeff aln = ale->ae_next; 438103785Sjeff if ((aln->ae_flags & AE_VALID) == 0) 439103785Sjeff alq->aq_entfree = aln; 440115308Sjeff else 441115308Sjeff alq->aq_entfree = NULL; 442103785Sjeff } else 443103785Sjeff ALQ_UNLOCK(alq); 444103785Sjeff 445103785Sjeff 446103785Sjeff return (ale); 447103785Sjeff} 448103785Sjeff 449103785Sjeffvoid 450103785Sjeffalq_post(struct alq *alq, struct ale *ale) 451103785Sjeff{ 452103785Sjeff int activate; 453103785Sjeff 454103785Sjeff ale->ae_flags |= AE_VALID; 455103785Sjeff 456103785Sjeff if (alq->aq_entvalid == NULL) 457103785Sjeff alq->aq_entvalid = ale; 458103785Sjeff 459103785Sjeff if ((alq->aq_flags & AQ_ACTIVE) == 0) { 460103785Sjeff alq->aq_flags |= AQ_ACTIVE; 461103785Sjeff activate = 1; 462103785Sjeff } else 463103785Sjeff activate = 0; 464103785Sjeff 465103785Sjeff ALQ_UNLOCK(alq); 466103785Sjeff if (activate) { 467103785Sjeff ALD_LOCK(); 468103785Sjeff ald_activate(alq); 469103785Sjeff ALD_UNLOCK(); 470103785Sjeff } 471103785Sjeff} 472103785Sjeff 473103785Sjeffvoid 474103785Sjeffalq_flush(struct alq *alq) 475103785Sjeff{ 476103785Sjeff int needwakeup = 0; 477103785Sjeff 478103785Sjeff ALD_LOCK(); 479103785Sjeff ALQ_LOCK(alq); 480103785Sjeff if (alq->aq_flags & AQ_ACTIVE) { 481103785Sjeff ald_deactivate(alq); 482103785Sjeff ALD_UNLOCK(); 483103785Sjeff needwakeup = alq_doio(alq); 484103785Sjeff } else 485103785Sjeff ALD_UNLOCK(); 486103785Sjeff ALQ_UNLOCK(alq); 487103785Sjeff 488103785Sjeff if (needwakeup) 489103785Sjeff wakeup(alq); 490103785Sjeff} 491103785Sjeff 492103785Sjeff/* 493103785Sjeff * Flush remaining data, close the file and free all resources. 494103785Sjeff */ 495103785Sjeffvoid 496103785Sjeffalq_close(struct alq *alq) 497103785Sjeff{ 498103785Sjeff /* 499103785Sjeff * If we're already shuting down someone else will flush and close 500103785Sjeff * the vnode. 501103785Sjeff */ 502103785Sjeff if (ald_rem(alq) != 0) 503103785Sjeff return; 504103785Sjeff 505103785Sjeff /* 506103785Sjeff * Drain all pending IO. 507103785Sjeff */ 508103785Sjeff alq_shutdown(alq); 509103785Sjeff 510103785Sjeff mtx_destroy(&alq->aq_mtx); 511103785Sjeff free(alq->aq_first, M_ALD); 512103785Sjeff free(alq->aq_entbuf, M_ALD); 513103785Sjeff free(alq, M_ALD); 514103785Sjeff} 515