Source-Changes-HG archive

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

[src/trunk]: src/sbin/fsck_lfs Note that fsck_lfs may not know beforehand whe...



details:   https://anonhg.NetBSD.org/src/rev/d6f5980514bf
branches:  trunk
changeset: 580038:d6f5980514bf
user:      perseant <perseant%NetBSD.org@localhost>
date:      Wed Apr 06 02:38:17 2005 +0000

description:
Note that fsck_lfs may not know beforehand whether a given block is a
superblock or a segment summary, and tries both.  These may be different
sizes.  Fix a broken assertion that they are the same size.

Fixes PR # 29151.

diffstat:

 sbin/fsck_lfs/bufcache.c |  18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diffs (39 lines):

diff -r b45f18f19c06 -r d6f5980514bf sbin/fsck_lfs/bufcache.c
--- a/sbin/fsck_lfs/bufcache.c  Tue Apr 05 22:54:26 2005 +0000
+++ b/sbin/fsck_lfs/bufcache.c  Wed Apr 06 02:38:17 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufcache.c,v 1.4 2005/03/19 00:43:17 perseant Exp $ */
+/* $NetBSD: bufcache.c,v 1.5 2005/04/06 02:38:17 perseant Exp $ */
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -182,15 +182,27 @@
 
        /*
         * First check the buffer cache lists.
+        * We might sometimes need to resize a buffer.  If we are growing
+        * the buffer, its contents are invalid; but shrinking is okay.
         */
        if ((bp = incore(vp, lbn)) != NULL) {
                assert(!(bp->b_flags & B_NEEDCOMMIT));
                assert(!(bp->b_flags & B_BUSY));
-               assert(bp->b_bcount == size);
                bp->b_flags |= B_BUSY;
                bremfree(bp);
-               return bp;
+               if (bp->b_bcount == size)
+                       return bp;
+               else if (bp->b_bcount > size) {
+                       assert(!(bp->b_flags & B_DELWRI));
+                       bp->b_bcount = size;
+                       bp->b_data = realloc(bp->b_data, size);
+                       return bp;
+               }
+
+               buf_destroy(bp);
+               bp = NULL;
        }
+
        /*
         * Not on the list.
         * Get a new block of the appropriate size and use that.



Home | Main Index | Thread Index | Old Index