NetBSD-Bugs archive

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

Re: kern/46282: 6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread



The following reply was made to PR kern/46282; it has been noted by GNATS.

From: "J. Hannken-Illjes" <hannken%eis.cs.tu-bs.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/46282: 6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> 
bio_doread
Date: Sat, 31 Mar 2012 09:51:41 +0200

 --Apple-Mail-2-538299323
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
        charset=us-ascii
 
 Please try the attached patch. It replaces bread() with
 getblk() / VOP_STRATEGY() and returns an error if getblk() fails.
 
 --
 Juergen Hannken-Illjes - hannken%eis.cs.tu-bs.de@localhost - TU Braunschweig 
(Germany)
 
 
 --Apple-Mail-2-538299323
 Content-Disposition: attachment;
        filename=msdosfs_fat.c.diff
 Content-Type: application/octet-stream;
        name="msdosfs_fat.c.diff"
 Content-Transfer-Encoding: 7bit
 
 Index: sys/fs/msdosfs/msdosfs_fat.c
 ===================================================================
 RCS file: /cvsroot/src/sys/fs/msdosfs/msdosfs_fat.c,v
 retrieving revision 1.19
 diff -p -u -4 -r1.19 msdosfs_fat.c
 --- sys/fs/msdosfs/msdosfs_fat.c       26 Jan 2010 20:25:52 -0000      1.19
 +++ sys/fs/msdosfs/msdosfs_fat.c       31 Mar 2012 07:48:29 -0000
 @@ -253,13 +253,28 @@ pcbmap(struct denode *dep, u_long findcn
                fatblock(pmp, byteoffset, &bn, &bsize, &bo);
                if (bn != bp_bn) {
                        if (bp)
                                brelse(bp, 0);
 -                      error = bread(pmp->pm_devvp, de_bn2kb(pmp, bn), bsize,
 -                          NOCRED, 0, &bp);
 -                      if (error) {
 -                              brelse(bp, 0);
 -                              return (error);
 +                      bp = getblk(pmp->pm_devvp, de_bn2kb(pmp, bn), bsize,
 +                          0, 0);
 +                      if (bp == NULL) {
 +                              /*
 +                               * getblk() above returns NULL only iff we are
 +                               * pagedaemon.  See the implementation of getblk
 +                               * for detail.
 +                               */
 +                              return ENOMEM;
 +                      }
 +                      if (!ISSET(bp->b_oflags, (BO_DONE | BO_DELWRI))) {
 +                              SET(bp->b_flags, B_READ);
 +                              BIO_SETPRIO(bp, BPRIO_TIMECRITICAL);
 +                              VOP_STRATEGY(pmp->pm_devvp, bp);
 +                              curlwp->l_ru.ru_inblock++;
 +                              error = biowait(bp);
 +                              if (error) {
 +                                      brelse(bp, 0);
 +                                      return error;
 +                              }
                        }
                        bp_bn = bn;
                }
                prevcn = cn;
 
 --Apple-Mail-2-538299323--
 


Home | Main Index | Thread Index | Old Index