Quick fix for not being able to sync all the buffers in boot() if

an ext2fs file system is mounted.  The soft update changes added
a check for B_DELWRI buffers.  This exposed the complete brokenness
of the previous quick fix for failing syncs (PR 3571, committed on
1997/08/04).  Use a new buffer flag B_DIRTY and don't abuse B_DELWRI.
B_DIRTY buffers are still written too late, as broken in the previous
fix.  This is fairly harmless, because B_DIRTY is only used for
bitmap buffers and fsck.ext2 can fix up the bitmaps perfectly.

Fixed a race in ULCK_BUF() (bremfree() was outside of the splbio()
section).
This commit is contained in:
Bruce Evans 1998-10-03 16:19:28 +00:00
parent aef1f383cf
commit 8f359bc68c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39924
6 changed files with 26 additions and 22 deletions

View File

@ -56,11 +56,7 @@ void mark_buffer_dirty(struct buf *bh)
int s;
s = splbio();
if (!(bh->b_flags & B_DELWRI)) {
numdirtybuffers++;
bh->b_flags |= B_DELWRI;
bh->b_flags &= ~(B_READ | B_ERROR);
}
bh->b_flags |= B_DIRTY;
splx(s);
}

View File

@ -168,10 +168,16 @@ extern u_char *fragtbl[];
}
#define ULCK_BUF(bp) { \
long flags; \
int s; \
s = splbio(); \
(bp)->b_flags &= ~B_LOCKED; \
splx(s); \
flags = (bp)->b_flags; \
(bp)->b_flags &= ~(B_DIRTY | B_LOCKED); \
bremfree(bp); \
brelse(bp); \
(bp)->b_flags |= B_BUSY; \
splx(s); \
if (flags & B_DIRTY) \
bdwrite(bp); \
else \
brelse(bp); \
}

View File

@ -56,11 +56,7 @@ void mark_buffer_dirty(struct buf *bh)
int s;
s = splbio();
if (!(bh->b_flags & B_DELWRI)) {
numdirtybuffers++;
bh->b_flags |= B_DELWRI;
bh->b_flags &= ~(B_READ | B_ERROR);
}
bh->b_flags |= B_DIRTY;
splx(s);
}

View File

@ -168,10 +168,16 @@ extern u_char *fragtbl[];
}
#define ULCK_BUF(bp) { \
long flags; \
int s; \
s = splbio(); \
(bp)->b_flags &= ~B_LOCKED; \
splx(s); \
flags = (bp)->b_flags; \
(bp)->b_flags &= ~(B_DIRTY | B_LOCKED); \
bremfree(bp); \
brelse(bp); \
(bp)->b_flags |= B_BUSY; \
splx(s); \
if (flags & B_DIRTY) \
bdwrite(bp); \
else \
brelse(bp); \
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)buf.h 8.9 (Berkeley) 3/30/95
* $Id: buf.h,v 1.57 1998/09/24 15:02:46 luoqi Exp $
* $Id: buf.h,v 1.58 1998/09/25 17:34:49 peter Exp $
*/
#ifndef _SYS_BUF_H_
@ -151,7 +151,7 @@ struct buf {
#define B_PHYS 0x00040000 /* I/O to user memory. */
#define B_RAW 0x00080000 /* Set by physio for raw transfers. */
#define B_READ 0x00100000 /* Read buffer. */
#define B_AVAIL3 0x00200000 /* Available flag */
#define B_DIRTY 0x00200000 /* Needs writing later. */
#define B_RELBUF 0x00400000 /* Release VMIO buffer. */
#define B_WANTED 0x00800000 /* Process wants this buffer. */
#define B_WRITE 0x00000000 /* Write buffer (pseudo flag). */
@ -165,7 +165,7 @@ struct buf {
#define B_AVAIL1 0x80000000 /* Available flag */
#define PRINT_BUF_FLAGS "\20\40avail1\37cluster\36vmio\35ram\34ordered" \
"\33paging\32xxx\31writeinprog\30wanted\27relbuf\26avail3" \
"\33paging\32xxx\31writeinprog\30wanted\27relbuf\26dirty" \
"\25read\24raw\23phys\22clusterok\21malloc\20nocache" \
"\17locked\16inval\15avail2\14error\13eintr\12done\11freebuf" \
"\10delwri\7call\6cache\5busy\4bad\3async\2needcommit\1age"

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)buf.h 8.9 (Berkeley) 3/30/95
* $Id: buf.h,v 1.57 1998/09/24 15:02:46 luoqi Exp $
* $Id: buf.h,v 1.58 1998/09/25 17:34:49 peter Exp $
*/
#ifndef _SYS_BUF_H_
@ -151,7 +151,7 @@ struct buf {
#define B_PHYS 0x00040000 /* I/O to user memory. */
#define B_RAW 0x00080000 /* Set by physio for raw transfers. */
#define B_READ 0x00100000 /* Read buffer. */
#define B_AVAIL3 0x00200000 /* Available flag */
#define B_DIRTY 0x00200000 /* Needs writing later. */
#define B_RELBUF 0x00400000 /* Release VMIO buffer. */
#define B_WANTED 0x00800000 /* Process wants this buffer. */
#define B_WRITE 0x00000000 /* Write buffer (pseudo flag). */
@ -165,7 +165,7 @@ struct buf {
#define B_AVAIL1 0x80000000 /* Available flag */
#define PRINT_BUF_FLAGS "\20\40avail1\37cluster\36vmio\35ram\34ordered" \
"\33paging\32xxx\31writeinprog\30wanted\27relbuf\26avail3" \
"\33paging\32xxx\31writeinprog\30wanted\27relbuf\26dirty" \
"\25read\24raw\23phys\22clusterok\21malloc\20nocache" \
"\17locked\16inval\15avail2\14error\13eintr\12done\11freebuf" \
"\10delwri\7call\6cache\5busy\4bad\3async\2needcommit\1age"