In lfs_bwrite, don't mark buffers dirty if lfs is mounted read-only.
(Previously buffers could be marked dirty by the cleaner, and possibly by other means.) Also check for softdep mount in vfs_shutdown before trying to bawrite buffers, since other filesystems don't need it and lfs doesn't bawrite. (This fragment reviewed by fvdl.) Partially addresses PR#8964.
This commit is contained in:
parent
abddb5f851
commit
fa6a733240
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_subr.c,v 1.115 1999/11/23 23:52:40 fvdl Exp $ */
|
||||
/* $NetBSD: vfs_subr.c,v 1.116 1999/12/15 07:10:32 perseant Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
||||
@ -2294,7 +2294,9 @@ vfs_shutdown()
|
||||
* written will be remarked as dirty until other
|
||||
* buffers are written.
|
||||
*/
|
||||
if (bp->b_flags & B_DELWRI) {
|
||||
if (bp->b_vp && bp->b_vp->v_mount
|
||||
&& (bp->b_vp->v_mount->mnt_flag & MNT_SOFTDEP)
|
||||
&& (bp->b_flags & B_DELWRI)) {
|
||||
s = splbio();
|
||||
bremfree(bp);
|
||||
bp->b_flags |= B_BUSY;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs.h,v 1.18 1999/12/08 23:17:31 simonb Exp $ */
|
||||
/* $NetBSD: lfs.h,v 1.19 1999/12/15 07:10:34 perseant Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
@ -80,7 +80,6 @@
|
||||
/* #define DEBUG_LFS */ /* Intensive debugging of LFS subsystem */
|
||||
|
||||
/* #define LFS_ATIME_IFILE */ /* Store atime in Ifile, don't push */
|
||||
/* #define LFS_HONOR_RDONLY */ /* Don't write blocks if mounted ro */
|
||||
|
||||
/*
|
||||
* Parameters and generic definitions
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs_bio.c,v 1.15 1999/12/04 12:18:21 ragge Exp $ */
|
||||
/* $NetBSD: lfs_bio.c,v 1.16 1999/12/15 07:10:34 perseant Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
@ -140,8 +140,10 @@ lfs_bwrite(v)
|
||||
register struct buf *bp = ap->a_bp;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if(bp->b_flags & B_ASYNC)
|
||||
if(VTOI(bp->b_vp)->i_lfs->lfs_ronly == 0
|
||||
&& (bp->b_flags & B_ASYNC)) {
|
||||
panic("bawrite LFS buffer");
|
||||
}
|
||||
#endif /* DIAGNOSTIC */
|
||||
return lfs_bwrite_ext(bp,0);
|
||||
}
|
||||
@ -184,6 +186,19 @@ lfs_bwrite_ext(bp, flags)
|
||||
struct inode *ip;
|
||||
int db, error, s;
|
||||
|
||||
/*
|
||||
* Don't write *any* blocks if we're mounted read-only.
|
||||
* In particular the cleaner can't write blocks either.
|
||||
*/
|
||||
if(VTOI(bp->b_vp)->i_lfs->lfs_ronly) {
|
||||
bp->b_flags &= ~(B_DELWRI|B_LOCKED|B_READ|B_ERROR);
|
||||
if(bp->b_flags & B_CALL)
|
||||
bp->b_flags &= ~B_BUSY;
|
||||
else
|
||||
brelse(bp);
|
||||
return EROFS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the delayed write flag and use reassignbuf to move the buffer
|
||||
* from the clean list to the dirty one.
|
||||
@ -242,17 +257,7 @@ lfs_bwrite_ext(bp, flags)
|
||||
++locked_queue_count;
|
||||
locked_queue_bytes += bp->b_bufsize;
|
||||
s = splbio();
|
||||
#ifdef LFS_HONOR_RDONLY
|
||||
/*
|
||||
* XXX KS - Don't write blocks if we're mounted ro.
|
||||
* Placement here means that the cleaner can't write
|
||||
* blocks either.
|
||||
*/
|
||||
if(VTOI(bp->b_vp)->i_lfs->lfs_ronly)
|
||||
bp->b_flags &= ~(B_DELWRI|B_LOCKED);
|
||||
else
|
||||
#endif
|
||||
bp->b_flags |= B_DELWRI | B_LOCKED;
|
||||
bp->b_flags |= B_DELWRI | B_LOCKED;
|
||||
bp->b_flags &= ~(B_READ | B_ERROR);
|
||||
reassignbuf(bp, bp->b_vp);
|
||||
splx(s);
|
||||
@ -316,8 +321,12 @@ lfs_flush(fs, flags)
|
||||
|
||||
if(lfs_dostats)
|
||||
++lfs_stats.write_exceeded;
|
||||
if (lfs_writing && flags==0) /* XXX flags */
|
||||
if (lfs_writing && flags==0) {/* XXX flags */
|
||||
#ifdef DEBUG_LFS
|
||||
printf("lfs_flush: not flushing because another flush is active\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
lfs_writing = 1;
|
||||
|
||||
simple_lock(&mountlist_slock);
|
||||
@ -378,6 +387,10 @@ lfs_check(vp, blkno, flags)
|
||||
{
|
||||
if(lfs_dostats)
|
||||
++lfs_stats.wait_exceeded;
|
||||
#ifdef DEBUG_LFS
|
||||
printf("lfs_check: waiting: count=%d, bytes=%ld\n",
|
||||
locked_queue_count, locked_queue_bytes);
|
||||
#endif
|
||||
error = tsleep(&locked_queue_count, PCATCH | PUSER,
|
||||
"buffers", hz * LFS_BUFWAIT);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user