1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 |
37 * $Id: nfs_bio.c,v 1.70 1999/05/02 23:56:24 alc Exp $ |
38 */ 39 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/resourcevar.h> 44#include <sys/signalvar.h> 45#include <sys/proc.h> --- 414 unchanged lines hidden (view full) --- 460 rabn = lbn + 1 + nra; 461 if (!incore(vp, rabn)) { 462 rabp = nfs_getcacheblk(vp, rabn, biosize, p); 463 if (!rabp) 464 return (EINTR); 465 if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { 466 rabp->b_flags |= (B_READ | B_ASYNC); 467 vfs_busy_pages(rabp, 0); |
468 if (nfs_asyncio(rabp, cred, p)) { |
469 rabp->b_flags |= B_INVAL|B_ERROR; 470 vfs_unbusy_pages(rabp); 471 brelse(rabp); 472 } 473 } else 474 brelse(rabp); 475 } 476 } --- 145 unchanged lines hidden (view full) --- 622 (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) && 623 !(np->n_flag & NQNFSNONCACHE) && 624 !incore(vp, lbn + 1)) { 625 rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p); 626 if (rabp) { 627 if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { 628 rabp->b_flags |= (B_READ | B_ASYNC); 629 vfs_busy_pages(rabp, 0); |
630 if (nfs_asyncio(rabp, cred, p)) { |
631 rabp->b_flags |= B_INVAL|B_ERROR; 632 vfs_unbusy_pages(rabp); 633 brelse(rabp); 634 } 635 } else { 636 brelse(rabp); 637 } 638 } --- 250 unchanged lines hidden (view full) --- 889 * as an optimization we could theoretically maintain 890 * a linked list of discontinuous areas, but we would still 891 * have to commit them separately so there isn't much 892 * advantage to it except perhaps a bit of asynchronization. 893 */ 894 895 if (bp->b_dirtyend > 0 && 896 (on > bp->b_dirtyend || (on + n) < bp->b_dirtyoff)) { |
897 if (VOP_BWRITE(bp) == EINTR) 898 return (EINTR); 899 goto again; 900 } 901 902 /* 903 * Check for valid write lease and get one as required. 904 * In case getblk() and/or bwrite() delayed us. --- 49 unchanged lines hidden (view full) --- 954 955 /* 956 * If the lease is non-cachable or IO_SYNC do bwrite(). 957 * 958 * IO_INVAL appears to be unused. The idea appears to be 959 * to turn off caching in this case. Very odd. XXX 960 */ 961 if ((np->n_flag & NQNFSNONCACHE) || (ioflag & IO_SYNC)) { |
962 if (ioflag & IO_INVAL) 963 bp->b_flags |= B_NOCACHE; 964 error = VOP_BWRITE(bp); 965 if (error) 966 return (error); 967 if (np->n_flag & NQNFSNONCACHE) { 968 error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); 969 if (error) 970 return (error); 971 } 972 } else if ((n + on) == biosize && 973 (nmp->nm_flag & NFSMNT_NQNFS) == 0) { |
974 bp->b_flags |= B_ASYNC; |
975 (void)nfs_writebp(bp, 0, 0); |
976 } else { 977 bdwrite(bp); 978 } 979 } while (uio->uio_resid > 0 && n > 0); 980 return (0); 981} 982 983/* --- 105 unchanged lines hidden (view full) --- 1089 * Initiate asynchronous I/O. Return an error if no nfsiods are available. 1090 * This is mainly to avoid queueing async I/O requests when the nfsiods 1091 * are all hung on a dead server. 1092 * 1093 * Note: nfs_asyncio() does not clear (B_ERROR|B_INVAL) but when the bp 1094 * is eventually dequeued by the async daemon, nfs_doio() *will*. 1095 */ 1096int |
1097nfs_asyncio(bp, cred, procp) |
1098 register struct buf *bp; 1099 struct ucred *cred; |
1100 struct proc *procp; |
1101{ 1102 struct nfsmount *nmp; 1103 int i; 1104 int gotiod; 1105 int slpflag = 0; 1106 int slptimeo = 0; 1107 int error; 1108 --- 49 unchanged lines hidden (view full) --- 1158 */ 1159 while (nmp->nm_bufqlen >= 2*nfs_numasync) { 1160 NFS_DPF(ASYNCIO, 1161 ("nfs_asyncio: waiting for mount %p queue to drain\n", nmp)); 1162 nmp->nm_bufqwant = TRUE; 1163 error = tsleep(&nmp->nm_bufq, slpflag | PRIBIO, 1164 "nfsaio", slptimeo); 1165 if (error) { |
1166 if (nfs_sigintr(nmp, NULL, procp)) |
1167 return (EINTR); 1168 if (slpflag == PCATCH) { 1169 slpflag = 0; 1170 slptimeo = 2 * hz; 1171 } 1172 } 1173 /* 1174 * We might have lost our iod while sleeping, --- 247 unchanged lines hidden --- |