Module Name: src Committed By: jdolecek Date: Fri Jun 19 19:29:39 UTC 2020
Modified Files: src/sys/dev/raidframe: rf_dag.h rf_dagfuncs.c rf_diskqueue.c rf_diskqueue.h rf_netbsd.h rf_netbsdkintf.c Log Message: pass down b_flags B_PHYS|B_RAW|B_MEDIA_FLAGS from bio subsystem to component I/O fixes the xbd(4) KASSERT() triggered by raidframe, noted in PR kern/55397 by Frank Kardel To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/raidframe/rf_dag.h cvs rdiff -u -r1.31 -r1.32 src/sys/dev/raidframe/rf_dagfuncs.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/raidframe/rf_diskqueue.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/raidframe/rf_diskqueue.h cvs rdiff -u -r1.34 -r1.35 src/sys/dev/raidframe/rf_netbsd.h cvs rdiff -u -r1.383 -r1.384 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/raidframe/rf_dag.h diff -u src/sys/dev/raidframe/rf_dag.h:1.20 src/sys/dev/raidframe/rf_dag.h:1.21 --- src/sys/dev/raidframe/rf_dag.h:1.20 Thu Oct 10 03:43:59 2019 +++ src/sys/dev/raidframe/rf_dag.h Fri Jun 19 19:29:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dag.h,v 1.20 2019/10/10 03:43:59 christos Exp $ */ +/* $NetBSD: rf_dag.h,v 1.21 2020/06/19 19:29:39 jdolecek Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -178,7 +178,7 @@ struct RF_DagHeader_s { RF_Raid_t *raidPtr; /* the descriptor for the RAID device this DAG * is for */ RF_RaidAccessDesc_t *desc; /* ptr to descriptor for this access */ - void *bp; /* the bp for this I/O passed down from the + const struct buf *bp; /* the bp for this I/O passed down from the * file system. ignored outside kernel */ }; Index: src/sys/dev/raidframe/rf_dagfuncs.c diff -u src/sys/dev/raidframe/rf_dagfuncs.c:1.31 src/sys/dev/raidframe/rf_dagfuncs.c:1.32 --- src/sys/dev/raidframe/rf_dagfuncs.c:1.31 Thu Oct 10 03:43:59 2019 +++ src/sys/dev/raidframe/rf_dagfuncs.c Fri Jun 19 19:29:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagfuncs.c,v 1.31 2019/10/10 03:43:59 christos Exp $ */ +/* $NetBSD: rf_dagfuncs.c,v 1.32 2020/06/19 19:29:39 jdolecek Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_dagfuncs.c,v 1.31 2019/10/10 03:43:59 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagfuncs.c,v 1.32 2020/06/19 19:29:39 jdolecek Exp $"); #include <sys/param.h> #include <sys/ioctl.h> @@ -272,10 +272,6 @@ rf_DiskReadFuncForThreads(RF_DagNode_t * unsigned which_ru = RF_EXTRACT_RU(node->params[3].v); RF_IoType_t iotype = (node->dagHdr->status == rf_enable) ? RF_IO_TYPE_READ : RF_IO_TYPE_NOP; RF_DiskQueue_t *dqs = ((RF_Raid_t *) (node->dagHdr->raidPtr))->Queues; - void *b_proc = NULL; - - if (node->dagHdr->bp) - b_proc = (void *) ((struct buf *) node->dagHdr->bp)->b_proc; req = rf_CreateDiskQueueData(iotype, pda->startSector, pda->numSector, bf, parityStripeID, which_ru, node->wakeFunc, node, @@ -284,7 +280,7 @@ rf_DiskReadFuncForThreads(RF_DagNode_t * #else NULL, #endif - (void *) (node->dagHdr->raidPtr), 0, b_proc, PR_NOWAIT); + (void *) (node->dagHdr->raidPtr), 0, node->dagHdr->bp, PR_NOWAIT); if (!req) { (node->wakeFunc) (node, ENOMEM); } else { @@ -308,10 +304,6 @@ rf_DiskWriteFuncForThreads(RF_DagNode_t unsigned which_ru = RF_EXTRACT_RU(node->params[3].v); RF_IoType_t iotype = (node->dagHdr->status == rf_enable) ? RF_IO_TYPE_WRITE : RF_IO_TYPE_NOP; RF_DiskQueue_t *dqs = ((RF_Raid_t *) (node->dagHdr->raidPtr))->Queues; - void *b_proc = NULL; - - if (node->dagHdr->bp) - b_proc = (void *) ((struct buf *) node->dagHdr->bp)->b_proc; /* normal processing (rollaway or forward recovery) begins here */ req = rf_CreateDiskQueueData(iotype, pda->startSector, pda->numSector, @@ -322,7 +314,7 @@ rf_DiskWriteFuncForThreads(RF_DagNode_t NULL, #endif (void *) (node->dagHdr->raidPtr), - 0, b_proc, PR_NOWAIT); + 0, node->dagHdr->bp, PR_NOWAIT); if (!req) { (node->wakeFunc) (node, ENOMEM); Index: src/sys/dev/raidframe/rf_diskqueue.c diff -u src/sys/dev/raidframe/rf_diskqueue.c:1.56 src/sys/dev/raidframe/rf_diskqueue.c:1.57 --- src/sys/dev/raidframe/rf_diskqueue.c:1.56 Thu Oct 10 03:43:59 2019 +++ src/sys/dev/raidframe/rf_diskqueue.c Fri Jun 19 19:29:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_diskqueue.c,v 1.56 2019/10/10 03:43:59 christos Exp $ */ +/* $NetBSD: rf_diskqueue.c,v 1.57 2020/06/19 19:29:39 jdolecek Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -66,7 +66,7 @@ ****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.56 2019/10/10 03:43:59 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.57 2020/06/19 19:29:39 jdolecek Exp $"); #include <dev/raidframe/raidframevar.h> @@ -362,7 +362,7 @@ rf_CreateDiskQueueData(RF_IoType_t typ, RF_ReconUnitNum_t which_ru, void (*wakeF) (void *, int), void *arg, RF_AccTraceEntry_t *tracerec, RF_Raid_t *raidPtr, - RF_DiskQueueDataFlags_t flags, void *kb_proc, + RF_DiskQueueDataFlags_t flags, const struct buf *mbp, int waitflag) { RF_DiskQueueData_t *p; @@ -381,6 +381,10 @@ rf_CreateDiskQueueData(RF_IoType_t typ, return (NULL); } SET(p->bp->b_cflags, BC_BUSY); /* mark buffer busy */ + if (mbp) { + SET(p->bp->b_flags, mbp->b_flags & rf_b_pass); + p->bp->b_proc = mbp->b_proc; + } p->sectorOffset = ssect + rf_protectedSectors; p->numSector = nsect; @@ -395,7 +399,6 @@ rf_CreateDiskQueueData(RF_IoType_t typ, p->priority = RF_IO_NORMAL_PRIORITY; p->raidPtr = raidPtr; p->flags = flags; - p->b_proc = kb_proc; return (p); } Index: src/sys/dev/raidframe/rf_diskqueue.h diff -u src/sys/dev/raidframe/rf_diskqueue.h:1.25 src/sys/dev/raidframe/rf_diskqueue.h:1.26 --- src/sys/dev/raidframe/rf_diskqueue.h:1.25 Thu Oct 10 03:43:59 2019 +++ src/sys/dev/raidframe/rf_diskqueue.h Fri Jun 19 19:29:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_diskqueue.h,v 1.25 2019/10/10 03:43:59 christos Exp $ */ +/* $NetBSD: rf_diskqueue.h,v 1.26 2020/06/19 19:29:39 jdolecek Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -74,8 +74,6 @@ struct RF_DiskQueueData_s { * targeted */ RF_DiskQueueDataFlags_t flags; /* flags controlling operation */ - struct proc *b_proc; /* the b_proc from the original bp passed into - * the driver for this I/O */ struct buf *bp; /* a bp to use to get this I/O done */ /* TAILQ bits for a queue for completed I/O requests */ TAILQ_ENTRY(RF_DiskQueueData_s) iodone_entries; @@ -145,7 +143,7 @@ RF_DiskQueueData_t *rf_CreateDiskQueueDa void *, RF_AccTraceEntry_t *, RF_Raid_t *, RF_DiskQueueDataFlags_t, - void *, int); + const struct buf *, int); void rf_FreeDiskQueueData(RF_DiskQueueData_t *); int rf_ConfigureDiskQueue(RF_Raid_t *, RF_DiskQueue_t *, RF_RowCol_t, const RF_DiskQueueSW_t *, Index: src/sys/dev/raidframe/rf_netbsd.h diff -u src/sys/dev/raidframe/rf_netbsd.h:1.34 src/sys/dev/raidframe/rf_netbsd.h:1.35 --- src/sys/dev/raidframe/rf_netbsd.h:1.34 Thu Oct 10 03:43:59 2019 +++ src/sys/dev/raidframe/rf_netbsd.h Fri Jun 19 19:29:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsd.h,v 1.34 2019/10/10 03:43:59 christos Exp $ */ +/* $NetBSD: rf_netbsd.h,v 1.35 2020/06/19 19:29:39 jdolecek Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -104,4 +104,6 @@ typedef struct RF_ConfigSet_s { struct RF_ConfigSet_s *next; } RF_ConfigSet_t; +extern const int rf_b_pass; + #endif /* _RF__RF_NETBSDSTUFF_H_ */ Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.383 src/sys/dev/raidframe/rf_netbsdkintf.c:1.384 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.383 Tue Jun 16 14:45:08 2020 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Fri Jun 19 19:29:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.383 2020/06/16 14:45:08 oster Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.384 2020/06/19 19:29:39 jdolecek Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***********************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.383 2020/06/16 14:45:08 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.384 2020/06/19 19:29:39 jdolecek Exp $"); #ifdef _KERNEL_OPT #include "opt_raid_autoconfig.h" @@ -175,13 +175,15 @@ static RF_SparetWait_t *rf_sparet_resp_q * installation process */ #endif +const int rf_b_pass = (B_PHYS|B_RAW|B_MEDIA_FLAGS); + MALLOC_DEFINE(M_RAIDFRAME, "RAIDframe", "RAIDframe structures"); /* prototypes */ static void KernelWakeupFunc(struct buf *); static void InitBP(struct buf *, struct vnode *, unsigned, dev_t, RF_SectorNum_t, RF_SectorCount_t, void *, void (*) (struct buf *), - void *, int, struct proc *); + void *, int); static void raidinit(struct raid_softc *); static int raiddoaccess(RF_Raid_t *raidPtr, struct buf *bp); static int rf_get_component_caches(RF_Raid_t *raidPtr, int *); @@ -2004,7 +2006,7 @@ rf_DispatchKernelIO(RF_DiskQueue_t *queu op, queue->rf_cinfo->ci_dev, req->sectorOffset, req->numSector, req->buf, KernelWakeupFunc, (void *) req, - queue->raidPtr->logBytesPerSector, req->b_proc); + queue->raidPtr->logBytesPerSector); if (rf_debugKernelAccess) { db1_printf(("dispatch: bp->b_blkno = %ld\n", @@ -2120,11 +2122,9 @@ KernelWakeupFunc(struct buf *bp) static void InitBP(struct buf *bp, struct vnode *b_vp, unsigned rw_flag, dev_t dev, RF_SectorNum_t startSect, RF_SectorCount_t numSect, void *bf, - void (*cbFunc) (struct buf *), void *cbArg, int logBytesPerSector, - struct proc *b_proc) + void (*cbFunc) (struct buf *), void *cbArg, int logBytesPerSector) { - /* bp->b_flags = B_PHYS | rw_flag; */ - bp->b_flags = rw_flag; /* XXX need B_PHYS here too??? */ + bp->b_flags = rw_flag | (bp->b_flags & rf_b_pass); bp->b_oflags = 0; bp->b_cflags = 0; bp->b_bcount = numSect << logBytesPerSector; @@ -2137,7 +2137,6 @@ InitBP(struct buf *bp, struct vnode *b_v if (bp->b_bcount == 0) { panic("bp->b_bcount is zero in InitBP!!"); } - bp->b_proc = b_proc; bp->b_iodone = cbFunc; bp->b_private = cbArg; }