Deleted Added
full compact
1/*
2 * Copyright (c) 2002, Jeffrey Roberson <jeff@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/kern_alq.c 103830 2002-09-23 05:20:00Z jeff $
26 * $FreeBSD: head/sys/kern/kern_alq.c 103995 2002-09-26 07:38:56Z jeff $
27 *
28 */
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/kthread.h>
34#include <sys/lock.h>

--- 34 unchanged lines hidden (view full) ---

69static MALLOC_DEFINE(M_ALD, "ALD", "ALD");
70
71/*
72 * The ald_mtx protects the ald_queues list and the ald_active list.
73 */
74static struct mtx ald_mtx;
75static LIST_HEAD(, alq) ald_queues;
76static LIST_HEAD(, alq) ald_active;
77static struct proc *ald_thread;
77static int ald_shutingdown = 0;
78struct thread *ald_thread;
79static struct proc *ald_proc;
80
81#define ALD_LOCK() mtx_lock(&ald_mtx)
82#define ALD_UNLOCK() mtx_unlock(&ald_mtx)
83
84/* Daemon functions */
85static int ald_add(struct alq *);
86static int ald_rem(struct alq *);
87static void ald_startup(void *);

--- 78 unchanged lines hidden (view full) ---

166static void
167ald_daemon(void)
168{
169 int needwakeup;
170 struct alq *alq;
171
172 mtx_lock(&Giant);
173
174 ald_thread = FIRST_THREAD_IN_PROC(ald_proc);
175
176 EVENTHANDLER_REGISTER(shutdown_pre_sync, ald_shutdown, NULL,
177 SHUTDOWN_PRI_FIRST);
178
179 ALD_LOCK();
180
181 for (;;) {
182 while ((alq = LIST_FIRST(&ald_active)) == NULL)
183 msleep(&ald_active, &ald_mtx, PWAIT, "aldslp", 0);

--- 38 unchanged lines hidden (view full) ---

222 while (alq->aq_flags & (AQ_FLUSHING|AQ_ACTIVE)) {
223 alq->aq_flags |= AQ_WANTED;
224 ALQ_UNLOCK(alq);
225 tsleep(alq, PWAIT, "aldclose", 0);
226 ALQ_LOCK(alq);
227 }
228 ALQ_UNLOCK(alq);
229
227 vn_close(alq->aq_vp, FREAD|FWRITE, alq->aq_cred,
230 vn_close(alq->aq_vp, FWRITE, alq->aq_cred,
231 curthread);
232 crfree(alq->aq_cred);
233}
234
235/*
236 * Flush all pending data to disk. This operation will block.
237 */
238static int

--- 69 unchanged lines hidden (view full) ---

308 }
309
310 return(0);
311}
312
313static struct kproc_desc ald_kp = {
314 "ALQ Daemon",
315 ald_daemon,
313 &ald_thread
316 &ald_proc
317};
318
319SYSINIT(aldthread, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, kproc_start, &ald_kp)
320SYSINIT(ald, SI_SUB_LOCK, SI_ORDER_ANY, ald_startup, NULL)
321
322
323/* User visible queue functions */
324

--- 12 unchanged lines hidden (view full) ---

337 int flags;
338 int error;
339 int i;
340
341 *alqp = NULL;
342 td = curthread;
343
344 NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, file, td);
342 flags = FREAD | FWRITE | O_NOFOLLOW | O_CREAT;
345 flags = FWRITE | O_NOFOLLOW | O_CREAT;
346
347 error = vn_open(&nd, &flags, 0);
348 if (error)
349 return (error);
350
351 NDFREE(&nd, NDF_ONLY_PNBUF);
352 /* We just unlock so we hold a reference */
353 VOP_UNLOCK(nd.ni_vp, 0, td);

--- 150 unchanged lines hidden ---