aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/alq.h
diff options
context:
space:
mode:
authorJeff Roberson <jeff@FreeBSD.org>2002-09-22 07:11:14 +0000
committerJeff Roberson <jeff@FreeBSD.org>2002-09-22 07:11:14 +0000
commit9405072a95bb04a523c575dcda2d8baff812515d (patch)
tree3b5c1a4b7dbe83eac2c0713fa153fa2ee4448971 /sys/sys/alq.h
parent95f5cd52bcb5471d241caaa06ab38b6718f58de4 (diff)
downloadsrc-9405072a95bb04a523c575dcda2d8baff812515d.tar.gz
src-9405072a95bb04a523c575dcda2d8baff812515d.zip
- Add an asynchronous fixed length record logging mechanism called
ALQ (Asynch. Logging Queues). ALQ supports many seperate queues with different record and buffer sizes. It opens and logs to any vnode so it can be used with character devices as well as regular files. Reviewed in part by: phk, jake, markm
Notes
Notes: svn path=/head/; revision=103785
Diffstat (limited to 'sys/sys/alq.h')
-rw-r--r--sys/sys/alq.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/sys/sys/alq.h b/sys/sys/alq.h
new file mode 100644
index 000000000000..58d0cb4e1bc9
--- /dev/null
+++ b/sys/sys/alq.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2002, Jeffrey Roberson <jeff@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+#ifndef _SYS_ALD_H_
+#define _SYS_ALD_H_
+
+/*
+ * Opaque type for the Async. Logging Queue
+ */
+struct alq;
+
+/*
+ * Async. Logging Entry
+ */
+struct ale {
+ struct ale *ae_next; /* Next Entry */
+ char *ae_data; /* Entry buffer */
+ int ae_flags; /* Entry flags */
+};
+
+#define AE_VALID 0x0001 /* Entry has valid data */
+
+
+/* waitok options */
+#define ALQ_NOWAIT 0x0001
+#define ALQ_WAITOK 0x0002
+
+/*
+ * alq_open: Creates a new queue
+ *
+ * Arguments:
+ * alq Storage for a pointer to the newly created queue.
+ * file The filename to open for logging.
+ * size The size of each entry in the queue.
+ * count The number of items in the buffer, this should be large enough
+ * to store items over the period of a disk write.
+ * Returns:
+ * error from open or 0 on success
+ */
+int alq_open(struct alq **, const char *file, int size, int count);
+
+/*
+ * alq_write: Write data into the queue
+ *
+ * Arguments:
+ * alq The queue we're writing to
+ * data The entry to be recorded
+ * waitok Are we permitted to wait?
+ *
+ * Returns:
+ * EWOULDBLOCK if:
+ * Waitok is ALQ_NOWAIT and the queue is full.
+ * The system is shutting down.
+ * 0 on success.
+ */
+int alq_write(struct alq *alq, void *data, int waitok);
+
+/*
+ * alq_flush: Flush the queue out to disk
+ */
+void alq_flush(struct alq *alq);
+
+/*
+ * alq_close: Flush the queue and free all resources.
+ */
+void alq_close(struct alq *alq);
+
+/*
+ * alq_get: Return an entry for direct access
+ *
+ * Arguments:
+ * alq The queue to retrieve an entry from
+ * waitok Are we permitted to wait?
+ *
+ * Returns:
+ * The next available ale on success.
+ * NULL if:
+ * Waitok is ALQ_NOWAIT and the queue is full.
+ * The system is shutting down.
+ *
+ * This leaves the queue locked until a subsequent alq_post.
+ */
+struct ale *alq_get(struct alq *alq, int waitok);
+
+/*
+ * alq_post: Schedule the ale retrieved by alq_get for writing.
+ * alq The queue to post the entry to.
+ * ale An asynch logging entry returned by alq_get.
+ */
+void alq_post(struct alq *, struct ale *);
+
+#endif /* _SYS_ALD_H_ */