Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/raidframe pass down b_flags B_PHYS|B_RAW|B_MEDIA_FLA...



details:   https://anonhg.NetBSD.org/src/rev/21d5531e890a
branches:  trunk
changeset: 934800:21d5531e890a
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Jun 19 19:29:39 2020 +0000

description:
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

diffstat:

 sys/dev/raidframe/rf_dag.h         |   4 ++--
 sys/dev/raidframe/rf_dagfuncs.c    |  16 ++++------------
 sys/dev/raidframe/rf_diskqueue.c   |  11 +++++++----
 sys/dev/raidframe/rf_diskqueue.h   |   6 ++----
 sys/dev/raidframe/rf_netbsd.h      |   4 +++-
 sys/dev/raidframe/rf_netbsdkintf.c |  17 ++++++++---------
 6 files changed, 26 insertions(+), 32 deletions(-)

diffs (231 lines):

diff -r 4f0f1fd20928 -r 21d5531e890a sys/dev/raidframe/rf_dag.h
--- a/sys/dev/raidframe/rf_dag.h        Fri Jun 19 16:30:31 2020 +0000
+++ b/sys/dev/raidframe/rf_dag.h        Fri Jun 19 19:29:39 2020 +0000
@@ -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 @@
        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 */
 };
 
diff -r 4f0f1fd20928 -r 21d5531e890a sys/dev/raidframe/rf_dagfuncs.c
--- a/sys/dev/raidframe/rf_dagfuncs.c   Fri Jun 19 16:30:31 2020 +0000
+++ b/sys/dev/raidframe/rf_dagfuncs.c   Fri Jun 19 19:29:39 2020 +0000
@@ -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 @@
        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 @@
 #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 @@
        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 @@
            NULL,
 #endif
            (void *) (node->dagHdr->raidPtr),
-           0, b_proc, PR_NOWAIT);
+           0, node->dagHdr->bp, PR_NOWAIT);
 
        if (!req) {
                (node->wakeFunc) (node, ENOMEM);
diff -r 4f0f1fd20928 -r 21d5531e890a sys/dev/raidframe/rf_diskqueue.c
--- a/sys/dev/raidframe/rf_diskqueue.c  Fri Jun 19 16:30:31 2020 +0000
+++ b/sys/dev/raidframe/rf_diskqueue.c  Fri Jun 19 19:29:39 2020 +0000
@@ -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_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 @@
                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 @@
        p->priority = RF_IO_NORMAL_PRIORITY;
        p->raidPtr = raidPtr;
        p->flags = flags;
-       p->b_proc = kb_proc;
        return (p);
 }
 
diff -r 4f0f1fd20928 -r 21d5531e890a sys/dev/raidframe/rf_diskqueue.h
--- a/sys/dev/raidframe/rf_diskqueue.h  Fri Jun 19 16:30:31 2020 +0000
+++ b/sys/dev/raidframe/rf_diskqueue.h  Fri Jun 19 19:29:39 2020 +0000
@@ -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 @@
                                 * 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 @@
                                           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 *,
diff -r 4f0f1fd20928 -r 21d5531e890a sys/dev/raidframe/rf_netbsd.h
--- a/sys/dev/raidframe/rf_netbsd.h     Fri Jun 19 16:30:31 2020 +0000
+++ b/sys/dev/raidframe/rf_netbsd.h     Fri Jun 19 19:29:39 2020 +0000
@@ -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 @@
        struct RF_ConfigSet_s *next;
 } RF_ConfigSet_t;
 
+extern const int rf_b_pass;
+
 #endif /* _RF__RF_NETBSDSTUFF_H_ */
diff -r 4f0f1fd20928 -r 21d5531e890a sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Fri Jun 19 16:30:31 2020 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Fri Jun 19 19:29:39 2020 +0000
@@ -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 @@
                                                 * 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 @@
                    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 @@
 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 @@
        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;
 }



Home | Main Index | Thread Index | Old Index