Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F165160999
D53351.id165234.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D53351.id165234.diff
View Options
diff --git a/sys/dev/mmc/mmcsd.c b/sys/dev/mmc/mmcsd.c
--- a/sys/dev/mmc/mmcsd.c
+++ b/sys/dev/mmc/mmcsd.c
@@ -1422,7 +1422,7 @@
struct mmcsd_softc *sc;
struct bio *bp;
device_t dev, mmcbus;
- int bio_error, err, sz;
+ int abio_error, err, sz;
part = arg;
sc = part->sc;
@@ -1430,7 +1430,7 @@
mmcbus = sc->mmcbus;
while (1) {
- bio_error = 0;
+ abio_error = 0;
MMCSD_DISK_LOCK(part);
do {
if (part->running == 0)
@@ -1475,11 +1475,11 @@
} else if (bp->bio_cmd == BIO_DELETE)
block = mmcsd_delete(part, bp);
else
- bio_error = EOPNOTSUPP;
+ abio_error = EOPNOTSUPP;
release:
MMCBUS_RELEASE_BUS(mmcbus, dev);
if (block < end) {
- bp->bio_error = (bio_error == 0) ? EIO : bio_error;
+ bp->bio_error = (abio_error == 0) ? EIO : abio_error;
bp->bio_resid = (end - block) * sz;
bp->bio_flags |= BIO_ERROR;
} else
diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c
--- a/sys/dev/nvme/nvme_ns.c
+++ b/sys/dev/nvme/nvme_ns.c
@@ -45,7 +45,7 @@
#include "nvme_private.h"
#include "nvme_linux.h"
-static void nvme_bio_child_inbed(struct bio *parent, int bio_error);
+static void nvme_bio_child_inbed(struct bio *parent, int abio_error);
static void nvme_bio_child_done(void *arg,
const struct nvme_completion *cpl);
static uint32_t nvme_get_num_segments(uint64_t addr, uint64_t size,
@@ -279,14 +279,14 @@
}
static void
-nvme_bio_child_inbed(struct bio *parent, int bio_error)
+nvme_bio_child_inbed(struct bio *parent, int abio_error)
{
struct nvme_completion parent_cpl;
int children, inbed;
- if (bio_error != 0) {
+ if (abio_error != 0) {
parent->bio_flags |= BIO_ERROR;
- parent->bio_error = bio_error;
+ parent->bio_error = abio_error;
}
/*
@@ -313,12 +313,12 @@
{
struct bio *child = arg;
struct bio *parent;
- int bio_error;
+ int abio_error;
parent = child->bio_parent;
g_destroy_bio(child);
- bio_error = nvme_completion_is_error(cpl) ? EIO : 0;
- nvme_bio_child_inbed(parent, bio_error);
+ abio_error = nvme_completion_is_error(cpl) ? EIO : 0;
+ nvme_bio_child_inbed(parent, abio_error);
}
static uint32_t
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -734,6 +734,10 @@
g_trace(G_T_BIO, "g_dev_done(%p) had error %d",
bp2, bp2->bio_error);
bp->bio_flags |= BIO_ERROR;
+ if ((bp2->bio_flags & BIO_EXTERR) != 0) {
+ bp->bio_flags |= BIO_EXTERR;
+ bp->bio_exterr = bp2->bio_exterr;
+ }
} else {
if (bp->bio_cmd == BIO_READ)
KNOTE_UNLOCKED(&sc->sc_selinfo.si_note, NOTE_READ);
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -235,8 +235,14 @@
bp2 = bp->bio_parent;
binuptime(&now);
mtx_lock(&sc->done_mtx);
- if (bp2->bio_error == 0)
- bp2->bio_error = bp->bio_error;
+ if (bp2->bio_error == 0) {
+ if ((bp->bio_flags & BIO_EXTERR) != 0) {
+ bp2->bio_flags |= BIO_EXTERR;
+ bp2->bio_exterr = bp->bio_exterr;
+ } else {
+ bp2->bio_error = bp->bio_error;
+ }
+ }
bp2->bio_completed += bp->bio_length - bp->bio_resid;
if (bp->bio_cmd == BIO_READ)
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -1162,8 +1162,14 @@
struct bio *bp2;
bp2 = bp->bio_parent;
- if (bp2->bio_error == 0)
- bp2->bio_error = bp->bio_error;
+ if (bp2->bio_error == 0) {
+ if ((bp->bio_flags & BIO_EXTERR) != 0) {
+ bp2->bio_flags |= BIO_EXTERR;
+ bp2->bio_exterr = bp->bio_exterr;
+ } else {
+ bp2->bio_error = bp->bio_error;
+ }
+ }
bp2->bio_completed += bp->bio_completed;
g_destroy_bio(bp);
bp2->bio_inbed++;
diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c
--- a/sys/geom/geom_vfs.c
+++ b/sys/geom/geom_vfs.c
@@ -26,9 +26,11 @@
* SUCH DAMAGE.
*/
+#define EXTERR_CATEGORY EXTERR_CAT_GEOMVFS
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bio.h>
+#include <sys/exterrvar.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -156,10 +158,13 @@
" supressing further ENXIO");
}
}
- bp->b_error = bip->bio_error;
bp->b_ioflags = bip->bio_flags;
if (bip->bio_error)
bp->b_ioflags |= BIO_ERROR;
+ if ((bp->b_ioflags & BIO_EXTERR) != 0)
+ bp->b_exterr = bip->bio_exterr;
+ else
+ bp->b_error = bip->bio_error;
bp->b_resid = bp->b_bcount - bip->bio_completed;
g_destroy_bio(bip);
@@ -195,6 +200,8 @@
mtx_unlock(&sc->sc_mtx);
bp->b_error = ENXIO;
bp->b_ioflags |= BIO_ERROR;
+ EXTERROR_KE(&bp->b_exterr, ENXIO,
+ "orphaned or enxio active");
bufdone(bp);
return;
}
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -2345,3 +2345,22 @@
}
return (eerror);
}
+
+int
+exterr_set_from(const struct kexterr *ke)
+{
+ struct thread *td;
+
+ td = curthread;
+ if ((td->td_pflags2 & TDP2_UEXTERR) != 0) {
+ td->td_pflags2 |= TDP2_EXTERR;
+ td->td_kexterr = *ke;
+ }
+ return (td->td_kexterr.error);
+}
+
+void
+exterr_clear(struct kexterr *ke)
+{
+ memset(ke, 0, sizeof(*ke));
+}
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -2487,7 +2487,7 @@
long bcount = bp->bio_bcount;
long resid = bp->bio_resid;
int opcode, nblks;
- int bio_error = bp->bio_error;
+ int abio_error = bp->bio_error;
uint16_t flags = bp->bio_flags;
opcode = job->uaiocb.aio_lio_opcode;
@@ -2503,16 +2503,16 @@
* error of whichever failed bio completed last.
*/
if (flags & BIO_ERROR)
- atomic_store_int(&job->error, bio_error);
+ atomic_store_int(&job->error, abio_error);
if (opcode & LIO_WRITE)
atomic_add_int(&job->outblock, nblks);
else
atomic_add_int(&job->inblock, nblks);
if (refcount_release(&job->nbio)) {
- bio_error = atomic_load_int(&job->error);
- if (bio_error != 0)
- aio_complete(job, -1, bio_error);
+ abio_error = atomic_load_int(&job->error);
+ if (abio_error != 0)
+ aio_complete(job, -1, abio_error);
else
aio_complete(job, atomic_load_long(&job->nbytes), 0);
}
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -44,6 +44,7 @@
* see man buf(9) for more info.
*/
+#define EXTERR_CATEGORY EXTERR_CAT_VFSBIO
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/asan.h>
@@ -55,6 +56,7 @@
#include <sys/counter.h>
#include <sys/devicestat.h>
#include <sys/eventhandler.h>
+#include <sys/exterrvar.h>
#include <sys/fail.h>
#include <sys/ktr.h>
#include <sys/limits.h>
@@ -1775,7 +1777,6 @@
bp->b_blkno = bp->b_lblkno = 0;
bp->b_offset = NOOFFSET;
bp->b_iodone = 0;
- bp->b_error = 0;
bp->b_resid = 0;
bp->b_bcount = 0;
bp->b_npages = 0;
@@ -1785,6 +1786,7 @@
bp->b_fsprivate1 = NULL;
bp->b_fsprivate2 = NULL;
bp->b_fsprivate3 = NULL;
+ exterr_clear(&bp->b_exterr);
LIST_INIT(&bp->b_dep);
return (bp);
@@ -2276,7 +2278,7 @@
}
if ((flags & GB_CVTENXIO) != 0)
bp->b_xflags |= BX_CVTENXIO;
- bp->b_ioflags &= ~BIO_ERROR;
+ bp->b_ioflags &= ~(BIO_ERROR | BIO_EXTERR);
if (bp->b_rcred == NOCRED && cred != NOCRED)
bp->b_rcred = crhold(cred);
vfs_busy_pages(bp, 0);
@@ -2353,7 +2355,7 @@
bundirty(bp);
bp->b_flags &= ~B_DONE;
- bp->b_ioflags &= ~BIO_ERROR;
+ bp->b_ioflags &= ~(BIO_ERROR | BIO_EXTERR);
bp->b_flags |= B_CACHE;
bp->b_iocmd = BIO_WRITE;
@@ -4520,8 +4522,11 @@
while ((bp->bio_flags & BIO_DONE) == 0)
msleep(bp, mtxp, PRIBIO, wmesg, 0);
mtx_unlock(mtxp);
- if (bp->bio_error != 0)
+ if (bp->bio_error != 0) {
+ if ((bp->bio_flags & BIO_EXTERR) != 0)
+ return (exterr_set_from(&bp->bio_exterr));
return (bp->bio_error);
+ }
if (!(bp->bio_flags & BIO_ERROR))
return (0);
return (EIO);
@@ -4568,6 +4573,8 @@
return (EINTR);
}
if (bp->b_ioflags & BIO_ERROR) {
+ if ((bp->b_ioflags & BIO_EXTERR) != 0)
+ exterr_set_from(&bp->b_exterr);
return (bp->b_error ? bp->b_error : EIO);
} else {
return (0);
diff --git a/sys/sys/bio.h b/sys/sys/bio.h
--- a/sys/sys/bio.h
+++ b/sys/sys/bio.h
@@ -37,6 +37,7 @@
#ifndef _SYS_BIO_H_
#define _SYS_BIO_H_
+#include <sys/_exterr.h>
#include <sys/queue.h>
#include <sys/disk_zone.h>
@@ -65,6 +66,7 @@
#define BIO_TRANSIENT_MAPPING 0x20
#define BIO_VLIST 0x40
#define BIO_SWAP 0x200 /* Swap-related I/O */
+#define BIO_EXTERR 0x2000
#define BIO_SPEEDUP_WRITE 0x4000 /* Resource shortage at upper layers */
#define BIO_SPEEDUP_TRIM 0x8000 /* Resource shortage at upper layers */
@@ -94,7 +96,6 @@
struct vm_page **bio_ma; /* Or unmapped. */
int bio_ma_offset; /* Offset in the first page of bio_ma. */
int bio_ma_n; /* Number of pages in bio_ma. */
- int bio_error; /* Errno for BIO_ERROR. */
long bio_resid; /* Remaining I/O in bytes. */
void (*bio_done)(struct bio *);
void *bio_driver1; /* Private use by the provider. */
@@ -130,8 +131,12 @@
/* XXX: these go away when bio chaining is introduced */
daddr_t bio_pblkno; /* physical block number */
+ struct kexterr bio_exterr;
};
+/* Errno for BIO_ERROR. */
+#define bio_error bio_exterr.error
+
struct uio;
struct devstat;
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -37,6 +37,7 @@
#ifndef _SYS_BUF_H_
#define _SYS_BUF_H_
+#include <sys/_exterr.h>
#include <sys/bufobj.h>
#include <sys/queue.h>
#include <sys/lock.h>
@@ -98,7 +99,6 @@
long b_bcount;
void *b_caller1;
caddr_t b_data;
- int b_error;
uint16_t b_iocmd; /* BIO_* bio_cmd from bio.h */
uint16_t b_ioflags; /* BIO_* bio_flags from bio.h */
off_t b_iooffset;
@@ -153,10 +153,12 @@
#elif defined(BUF_TRACKING)
const char *b_io_tracking;
#endif
+ struct kexterr b_exterr;
struct vm_page *b_pages[];
};
#define b_object b_bufobj->bo_object
+#define b_error b_exterr.error
/*
* These flags are kept in b_flags.
@@ -390,6 +392,12 @@
_lockmgr_disown(&(bp)->b_lock, LOCK_FILE, LOCK_LINE)
#endif
+#define BUF_EXTERR_FROM_CURTHR(bp) \
+ bp->b_exterr = curthread->td_kexterr
+
+#define BUF_EXTERR_TO_CURTHR(bp) \
+ curthread->td_kexterr = bp->b_exterr
+
#endif /* _KERNEL */
struct buf_queue_head {
diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h
--- a/sys/sys/exterr_cat.h
+++ b/sys/sys/exterr_cat.h
@@ -21,6 +21,8 @@
#define EXTERR_CAT_BRIDGE 7
#define EXTERR_CAT_SWAP 8
#define EXTERR_CAT_VFSSYSCALL 9
+#define EXTERR_CAT_VFSBIO 10
+#define EXTERR_CAT_GEOMVFS 11
#endif
diff --git a/sys/sys/exterrvar.h b/sys/sys/exterrvar.h
--- a/sys/sys/exterrvar.h
+++ b/sys/sys/exterrvar.h
@@ -37,6 +37,26 @@
#define SET_ERROR_MSG(mmsg) NULL
#endif
+#define _SET_ERROR2_KE(kep, eerror, mmsg, pp1, pp2) ({ \
+ (kep)->error = (eerror); \
+ (kep)->cat = EXTERR_CATEGORY; \
+ (kep)->msg = SET_ERROR_MSG(mmsg); \
+ (kep)->p1 = (pp1); \
+ (kep)->p2 = (pp2); \
+ (kep)->src_line = __LINE__; \
+ (kep)->error; \
+})
+#define _SET_ERROR0_KE(kep, eerror, mmsg) \
+ _SET_ERROR2_KE(kep, eerror, mmsg, 0, 0)
+#define _SET_ERROR1_KE(kep, eerror, mmsg, pp1) \
+ _SET_ERROR2_KE(kep, eerror, mmsg, pp1, 0)
+
+#define _EXTERROR_MACRO_KE(kep, eerror, mmsg, _1, _2, NAME, ...) \
+ NAME
+#define EXTERROR_KE(...) \
+ _EXTERROR_MACRO_KE(__VA_ARGS__, _SET_ERROR2_KE, _SET_ERROR1_KE, \
+ _SET_ERROR0_KE)(__VA_ARGS__)
+
#define _SET_ERROR2(eerror, mmsg, pp1, pp2) \
exterr_set(eerror, EXTERR_CATEGORY, SET_ERROR_MSG(mmsg), \
(uintptr_t)(pp1), (uintptr_t)(pp2), __LINE__)
@@ -49,6 +69,8 @@
_EXTERROR_MACRO(__VA_ARGS__, _SET_ERROR2, _SET_ERROR1, \
_SET_ERROR0)(__VA_ARGS__)
+void exterr_clear(struct kexterr *ke);
+int exterr_set_from(const struct kexterr *ke);
int exterr_set(int eerror, int category, const char *mmsg, uintptr_t pp1,
uintptr_t pp2, int line);
int exterr_to_ue(struct thread *td, struct uexterror *ue);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Aug 7, 11:58 AM (11 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36170069
Default Alt Text
D53351.id165234.diff (11 KB)
Attached To
Mode
D53351: exterror(9): add infra for bufs and bios
Attached
Detach File
Event Timeline
Log In to Comment