151184Sbostic /* 251493Sbostic * Copyright (c) 1991 Regents of the University of California. 351184Sbostic * All rights reserved. 451184Sbostic * 551184Sbostic * %sccs.include.redist.c% 651184Sbostic * 7*51851Sbostic * @(#)lfs_bio.c 7.2 (Berkeley) 12/06/91 851184Sbostic */ 951184Sbostic 1051480Sbostic #include <sys/param.h> 1151480Sbostic #include <sys/proc.h> 1251480Sbostic #include <sys/buf.h> 1351480Sbostic #include <sys/resourcevar.h> 1451184Sbostic 1551493Sbostic #include <ufs/lfs/lfs.h> 1651493Sbostic #include <ufs/lfs/lfs_extern.h> 1751480Sbostic 1851480Sbostic int 1951184Sbostic lfs_bwrite(bp) 2051184Sbostic register BUF *bp; 2151184Sbostic { 22*51851Sbostic #ifdef VERBOSE 23*51851Sbostic printf("lfs_bwrite\n"); 24*51851Sbostic #endif 25*51851Sbostic /* 26*51851Sbostic * 27*51851Sbostic * LFS version of bawrite, bdwrite, bwrite. Set the delayed write 28*51851Sbostic * flag and use reassignbuf to move the buffer from the clean list 29*51851Sbostic * to the dirty one, then unlock the buffer. Note, we set the 30*51851Sbostic * B_LOCKED flag, which causes brelse to move the buffer onto the 31*51851Sbostic * LOCKED free list. This is necessary, otherwise getnewbuf() would 32*51851Sbostic * try to reclaim them using bawrite, which isn't going to work. 33*51851Sbostic * 34*51851Sbostic * XXX 35*51851Sbostic * No accounting for the cost of the write is currently done. 36*51851Sbostic * This is almost certainly wrong for synchronous operations, i.e. NFS. 37*51851Sbostic */ 3851215Sbostic bp->b_flags &= ~(B_READ | B_DONE | B_ERROR); 39*51851Sbostic bp->b_flags |= B_DELWRI | B_LOCKED; 40*51851Sbostic reassignbuf(bp, bp->b_vp); 4151184Sbostic brelse(bp); 4251480Sbostic return (0); 4351184Sbostic } 44