* Copyright (c) 1991 Regents of the University of California.
* %sccs.include.redist.c%
* @(#)lfs_bio.c 7.11 (Berkeley) %G%
#include <sys/resourcevar.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/lfs/lfs_extern.h>
* LFS block write function.
* No write cost accounting is done.
* This is almost certainly wrong for synchronous operations and NFS.
int locked_queue_count
; /* XXX Count of locked-down buffers. */
struct vop_bwrite_args
*ap
;
register struct buf
*bp
= ap
->a_bp
;
* Set the delayed write flag and use reassignbuf to move the buffer
* from the clean list to the dirty one.
* Set the B_LOCKED flag and unlock the buffer, causing brelse to move
* the buffer onto the LOCKED free list. This is necessary, otherwise
* getnewbuf() would try to reclaim the buffers using bawrite, which
if (!(bp
->b_flags
& B_LOCKED
)) {
bp
->b_flags
|= B_DELWRI
| B_LOCKED
;
bp
->b_flags
&= ~(B_READ
| B_DONE
| B_ERROR
);
#define PMAP_BUG_FIX_HACK
(bp
->b_vp
->v_mount
->mnt_data
))->um_lfs
->lfs_ivnode
!=
reassignbuf(bp
, bp
->b_vp
);
* This routine flushes buffers out of the B_LOCKED queue when LFS has too
* many locked down. Eventually the pageout daemon will simply call LFS
* when pages need to be reclaimed. Note, we have one static count of locked
* buffers, so we can't have more than a single file system. To make this
* work for multiple file systems, put the count into the mount structure.
register struct mount
*mp
;
/* 1M in a 4K file system. */
if (locked_queue_count
< 256)
* The lock check below is to avoid races with mount
if (mp
->mnt_stat
.f_type
== MOUNT_LFS
&&
(mp
->mnt_flag
& (MNT_MLOCK
|MNT_RDONLY
|MNT_MPBUSY
)) == 0 &&
* We set the queue to 0 here because we are about to
* write all the dirty buffers we have. If more come
* in while we're writing the segment, they may not
* get written, so we want the count to reflect these
* new writes after the segwrite completes.