NetBSD-Bugs archive

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

kern/42342: LFS: b_[co]?flags and their values mismatch



>Number:         42342
>Category:       kern
>Synopsis:       LFS: b_[co]?flags and their values mismatch
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 18 14:40:01 +0000 2009
>Originator:     NAKAJIMA Yoshihiro
>Release:        NetBSD-current/20091113
>Organization:
>Environment:
System: NetBSD asura 5.99.22 NetBSD 5.99.22 (ASURA) #1: Wed Nov 18 23:06:44 JST 
2009 nakayosh@asura:/usr/src/sys/arch/amd64/compile/ASURA amd64
Architecture: x86_64
Machine: amd64
>Description:
        After NetBSD 4.0, b_flags in struct buf was split to b_flags,
        b_cflags and b_oflags.  But some variables remain unchanged in LFS.

>How-To-Repeat:
>Fix:

Date: Wed Nov 18 23:12:53 JST 2009
diff -u src/sys/ufs/lfs/lfs_bio.c.ORIG src/sys/ufs/lfs/lfs_bio.c
--- src/sys/ufs/lfs/lfs_bio.c.ORIG      2008-05-07 03:43:45.000000000 +0900
+++ src/sys/ufs/lfs/lfs_bio.c   2009-11-18 22:38:40.000000000 +0900
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_bio.c,v 1.114 2008/05/06 18:43:45 ad Exp $ */
+/*     $NetBSD$        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@@ -448,8 +448,7 @@
        ASSERT_MAYBE_SEGLOCK(fs);
        KASSERT(bp->b_cflags & BC_BUSY);
        KASSERT(flags & BW_CLEAN || !LFS_IS_MALLOC_BUF(bp));
-       KASSERT(((bp->b_oflags | bp->b_flags) & (BO_DELWRI|B_LOCKED))
-           != BO_DELWRI);
+       KASSERT((bp->b_flags & B_LOCKED) || !(bp->b_oflags & BO_DELWRI));
 
        /*
         * Don't write *any* blocks if we're mounted read-only, or
diff -u src/sys/ufs/lfs/lfs_segment.c.ORIG src/sys/ufs/lfs/lfs_segment.c
--- src/sys/ufs/lfs/lfs_segment.c.ORIG  2009-08-07 22:58:38.000000000 +0900
+++ src/sys/ufs/lfs/lfs_segment.c       2009-11-18 23:02:19.000000000 +0900
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_segment.c,v 1.214 2009/08/07 13:58:38 wiz Exp $    */
+/*     $NetBSD$        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -1372,13 +1372,13 @@
                        continue;
                }
 #ifdef DIAGNOSTIC
-# ifdef LFS_USE_B_INVAL
-               if ((bp->b_flags & BC_INVAL) != 0 && bp->b_iodone == NULL) {
+# ifdef LFS_USE_BC_INVAL
+               if ((bp->b_cflags & BC_INVAL) != 0 && bp->b_iodone == NULL) {
                        DLOG((DLOG_SEG, "lfs_gather: lbn %" PRId64
                              " is BC_INVAL\n", bp->b_lblkno));
                        VOP_PRINT(bp->b_vp);
                }
-# endif /* LFS_USE_B_INVAL */
+# endif /* LFS_USE_BC_INVAL */
                if (!(bp->b_oflags & BO_DELWRI))
                        panic("lfs_gather: bp not BO_DELWRI");
                if (!(bp->b_flags & B_LOCKED)) {
@@ -2037,7 +2037,7 @@
        LFS_WRITESEGENTRY(sup, fs, sp->seg_number, bp); /* Ifile */
 
        /*
-        * Mark blocks B_BUSY, to prevent then from being changed between
+        * Mark blocks BC_BUSY, to prevent then from being changed between
         * the checksum computation and the actual write.
         *
         * If we are cleaning, check indirect blocks for UNWRITTEN, and if
@@ -2149,7 +2149,7 @@
                /* Loop through gop_write cluster blocks */
                for (byteoffset = 0; byteoffset < (*bpp)->b_bcount;
                     byteoffset += fs->lfs_bsize) {
-#ifdef LFS_USE_B_INVAL
+#ifdef LFS_USE_BC_INVAL
                        if (((*bpp)->b_cflags & BC_INVAL) != 0 &&
                            (*bpp)->b_iodone != NULL) {
                                if (copyin((void *)(*bpp)->b_saveaddr +
@@ -2160,7 +2160,7 @@
                                                (*bpp)->b_lblkno);
                                }
                        } else
-#endif /* LFS_USE_B_INVAL */
+#endif /* LFS_USE_BC_INVAL */
                        {
                                sum = lfs_cksum_part((char *)
                                    (*bpp)->b_data + byteoffset, el_size, sum);
@@ -2256,9 +2256,9 @@
                        }
 #endif
 
-#ifdef LFS_USE_B_INVAL
+#ifdef LFS_USE_BC_INVAL
                        /*
-                        * Fake buffers from the cleaner are marked as B_INVAL.
+                        * Fake buffers from the cleaner are marked as BC_INVAL.
                         * We need to copy the data from user space rather than
                         * from the buffer indicated.
                         * XXX == what do I do on an error?
@@ -2269,7 +2269,7 @@
                                        panic("lfs_writeseg: "
                                            "copyin failed [2]");
                        } else
-#endif /* LFS_USE_B_INVAL */
+#endif /* LFS_USE_BC_INVAL */
                        if (cl->flags & LFS_CL_MALLOC) {
                                /* copy data into our cluster. */
                                memcpy(p, bp->b_data, bp->b_bcount);
@@ -2520,8 +2520,7 @@
                        tbp->b_flags |= B_ASYNC; /* for biodone */
                }
 
-               if (((tbp->b_flags | tbp->b_oflags) &
-                   (B_LOCKED | BO_DELWRI)) == B_LOCKED)
+               if ((tbp->b_flags & B_LOCKED) && !(tbp->b_oflags & BO_DELWRI))
                        LFS_UNLOCK_BUF(tbp);
 
                if (tbp->b_oflags & BO_DONE) {
@@ -2548,7 +2547,7 @@
                        tbp->b_flags |= B_ASYNC;
                        /* Master buffers have BC_AGE */
                        if (tbp->b_private == tbp)
-                               tbp->b_flags |= BC_AGE;
+                               tbp->b_cflags |= BC_AGE;
                }
                mutex_exit(&bufcache_lock);
 



Home | Main Index | Thread Index | Old Index