Page MenuHomeFreeBSD

D5709.id14530.diff
No OneTemporary

D5709.id14530.diff

Index: share/man/man9/alq.9
===================================================================
--- share/man/man9/alq.9
+++ share/man/man9/alq.9
@@ -31,7 +31,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 26, 2010
+.Dd March 22, 2016
.Dt ALQ 9
.Os
.Sh NAME
@@ -73,7 +73,7 @@
.Fn alq_write "struct alq *alq" "void *data" "int flags"
.Ft void
.Fn alq_flush "struct alq *alq"
-.Ft void
+.Ft int
.Fn alq_close "struct alq *alq"
.Ft struct ale *
.Fn alq_getn "struct alq *alq" "int len" "int flags"
@@ -414,6 +414,11 @@
.Fa flags
and either the queue is full or the system is shutting down.
.Pp
+The
+.Fn alq_close
+function will return any error encountered from
+.Xr VOP_WRITE 9 .
+.Pp
NOTE: invalid arguments to non-void functions will result in
undefined behaviour.
.Sh SEE ALSO
Index: sys/kern/kern_alq.c
===================================================================
--- sys/kern/kern_alq.c
+++ sys/kern/kern_alq.c
@@ -68,6 +68,9 @@
* NB: Used as a wait channel so must
* not be first field in the alq struct
*/
+ int aq_error; /* Any error from writing, returned
+ * from alq_close().
+ */
struct ale aq_getpost; /* ALE for use by get/post */
struct mtx aq_mtx; /* Queue lock */
struct vnode *aq_vp; /* Open vnode handle */
@@ -293,8 +296,6 @@
void
alq_destroy(struct alq *alq)
{
- /* Drain all pending IO. */
- alq_shutdown(alq);
mtx_destroy(&alq->aq_mtx);
free(alq->aq_entbuf, M_ALD);
@@ -312,6 +313,7 @@
struct vnode *vp;
struct uio auio;
struct iovec aiov[2];
+ int error;
int totlen;
int iov;
int wrapearly;
@@ -367,17 +369,17 @@
*/
vn_start_write(vp, &mp, V_WAIT);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- /*
- * XXX: VOP_WRITE error checks are ignored.
- */
+ error = 0;
#ifdef MAC
if (mac_vnode_check_write(alq->aq_cred, NOCRED, vp) == 0)
#endif
- VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, alq->aq_cred);
+ error = VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, alq->aq_cred);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
ALQ_LOCK(alq);
+ if (error != 0)
+ alq->aq_error = error;
alq->aq_flags &= ~AQ_FLUSHING;
/* Adjust writetail as required, taking into account wrapping. */
@@ -470,6 +472,8 @@
alq->aq_flags |= AQ_ORDERED;
if ((error = ald_add(alq)) != 0) {
+ /* Drain all pending IO. */
+ alq_shutdown(alq);
alq_destroy(alq);
return (error);
}
@@ -912,12 +916,23 @@
/*
* Flush remaining data, close the file and free all resources.
*/
-void
+int
alq_close(struct alq *alq)
{
+ int error;
+
/* Only flush and destroy alq if not already shutting down. */
- if (ald_rem(alq) == 0)
- alq_destroy(alq);
+ if (ald_rem(alq) != 0)
+ return (0);
+ /*
+ * Drain all pending IO and fetch the error to return before
+ * destroying the alq.
+ */
+ alq_shutdown(alq);
+ error = alq->aq_error;
+ alq_destroy(alq);
+
+ return (error);
}
static int
Index: sys/sys/alq.h
===================================================================
--- sys/sys/alq.h
+++ sys/sys/alq.h
@@ -106,7 +106,7 @@
/*
* alq_close: Flush the queue and free all resources.
*/
-void alq_close(struct alq *alq);
+int alq_close(struct alq *alq);
/*
* alq_getn: Return an entry for direct access

File Metadata

Mime Type
text/plain
Expires
Wed, Feb 4, 9:43 AM (19 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28433562
Default Alt Text
D5709.id14530.diff (3 KB)

Event Timeline