2 .\" Copyright (c) 2003 Hiten Pandya <hmp@FreeBSD.org>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions, and the following disclaimer,
10 .\" without modification, immediately at the beginning of the file.
11 .\" 2. The name of the author may not be used to endorse or promote products
12 .\" derived from this software without specific prior written permission.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 .\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 .Nd Asynchronous Logging Queues
44 .Fa "struct alq **app"
45 .Fa "const char *file"
46 .Fa "struct ucred *cred"
52 .Fn alq_write "struct alq *alq" "void *data" "int waitok"
54 .Fn alq_flush "struct alq *alq"
56 .Fn alq_close "struct alq *alq"
58 .Fn alq_get "struct alq *alq" "int waitok"
60 .Fn alq_post "struct alq *alq" "struct ale *ale"
64 facility provides an asynchronous fixed length recording
65 mechanism, known as Asynchronous Logging Queues.
68 thus providing the ability to journal logs to character
69 devices as well as regular files.
70 All functions accept a
72 argument, which is an opaque type that maintains state information
73 for an Asynchronous Logging Queue.
74 The logging facility runs in a separate kernel thread, which services
75 all log entry requests.
78 .Dq asynchronous log entry
81 which has the following members:
82 .Bd -literal -offset indent
84 struct ale *ae_next; /* Next Entry */
85 char *ae_data; /* Entry buffer */
86 int ae_flags; /* Entry flags */
92 field is for internal use, clients of the
94 interface should not modify this field.
95 Behaviour is undefined if this field is modified.
99 function creates a new logging queue.
102 argument is the name of the file to open for logging; if the file does not
105 will attempt to create it.
108 argument will be passed to
110 as the requested creation mode, to be used if the file will be created by
112 Consumers of this API may wish to pass
113 .Dv ALQ_DEFAULT_CMODE ,
114 a default creation mode suitable for most applications.
117 specifies the credentials to use when opening and performing I/O on the file.
118 The size of each entry in the queue is determined by
122 argument determines the number of items to be stored in the
123 asynchronous queue over an approximate period of a disk
130 to the designated queue,
134 could not write the entry immediately, and
145 function is used for flushing
147 to the log medium that was passed to
152 function will close the asynchronous logging queue,
154 and flush all pending write requests to the log medium.
155 It will free all resources that were previously allocated.
159 function returns the next available asynchronous logging entry
162 This function leaves the queue in a locked state, until a subsequent
167 could not retrieve an entry immediately, it will
175 function schedules the asynchronous logging entry,
177 which is retrieved using the
180 for writing to the asynchronous logging queue,
182 This function leaves the queue,
184 in an unlocked state.
185 .Sh IMPLEMENTATION NOTES
188 function is a wrapper around the
192 functions; by using these functions separately, a call
195 can be avoided for performance critical code paths.
197 Each asynchronous queue is protected by a spin mutex.
204 may attempt to acquire an internal sleep mutex, and should
205 consequently not be used in contexts where sleeping is
210 function returns one of the error codes listed in
214 or else it returns 0.
222 was provided as a value to
224 and either the queue is full, or when the system is shutting down.
232 was provided as a value to
234 and either the queue is full, or when the system is shutting down.
236 NOTE: invalid arguments to non-void functions will result in
246 Asynchronous Logging Queues (ALQ) facility first appeared in
252 facility was written by
253 .An Jeffrey Roberson Aq jeff@FreeBSD.org .
255 This manual page was written by
256 .An Hiten Pandya Aq hmp@FreeBSD.org .