Deleted Added
full compact
kern_alq.c (103830) kern_alq.c (103995)
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 *
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;
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;
78static int ald_shutingdown = 0;
77static int ald_shutingdown = 0;
78struct thread *ald_thread;
79static struct proc *ald_proc;
79
80#define ALD_LOCK() mtx_lock(&ald_mtx)
81#define ALD_UNLOCK() mtx_unlock(&ald_mtx)
82
83/* Daemon functions */
84static int ald_add(struct alq *);
85static int ald_rem(struct alq *);
86static void ald_startup(void *);

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

165static void
166ald_daemon(void)
167{
168 int needwakeup;
169 struct alq *alq;
170
171 mtx_lock(&Giant);
172
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
173 EVENTHANDLER_REGISTER(shutdown_pre_sync, ald_shutdown, NULL,
174 SHUTDOWN_PRI_FIRST);
175
176 ALD_LOCK();
177
178 for (;;) {
179 while ((alq = LIST_FIRST(&ald_active)) == NULL)
180 msleep(&ald_active, &ald_mtx, PWAIT, "aldslp", 0);

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

219 while (alq->aq_flags & (AQ_FLUSHING|AQ_ACTIVE)) {
220 alq->aq_flags |= AQ_WANTED;
221 ALQ_UNLOCK(alq);
222 tsleep(alq, PWAIT, "aldclose", 0);
223 ALQ_LOCK(alq);
224 }
225 ALQ_UNLOCK(alq);
226
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,
228 curthread);
229 crfree(alq->aq_cred);
230}
231
232/*
233 * Flush all pending data to disk. This operation will block.
234 */
235static int

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

305 }
306
307 return(0);
308}
309
310static struct kproc_desc ald_kp = {
311 "ALQ Daemon",
312 ald_daemon,
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
314};
315
316SYSINIT(aldthread, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, kproc_start, &ald_kp)
317SYSINIT(ald, SI_SUB_LOCK, SI_ORDER_ANY, ald_startup, NULL)
318
319
320/* User visible queue functions */
321

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

334 int flags;
335 int error;
336 int i;
337
338 *alqp = NULL;
339 td = curthread;
340
341 NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, file, td);
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;
343
344 error = vn_open(&nd, &flags, 0);
345 if (error)
346 return (error);
347
348 NDFREE(&nd, NDF_ONLY_PNBUF);
349 /* We just unlock so we hold a reference */
350 VOP_UNLOCK(nd.ni_vp, 0, td);

--- 150 unchanged lines hidden ---
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 ---