Deleted Added
full compact
nfs_bio.c (46349) nfs_bio.c (46580)
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
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.69 1999/04/06 03:07:54 peter Exp $
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);
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)) {
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);
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)) {
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)) {
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 bp->b_proc = p;
898 if (VOP_BWRITE(bp) == EINTR)
899 return (EINTR);
900 goto again;
901 }
902
903 /*
904 * Check for valid write lease and get one as required.
905 * In case getblk() and/or bwrite() delayed us.

--- 49 unchanged lines hidden (view full) ---

955
956 /*
957 * If the lease is non-cachable or IO_SYNC do bwrite().
958 *
959 * IO_INVAL appears to be unused. The idea appears to be
960 * to turn off caching in this case. Very odd. XXX
961 */
962 if ((np->n_flag & NQNFSNONCACHE) || (ioflag & IO_SYNC)) {
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)) {
963 bp->b_proc = p;
964 if (ioflag & IO_INVAL)
965 bp->b_flags |= B_NOCACHE;
966 error = VOP_BWRITE(bp);
967 if (error)
968 return (error);
969 if (np->n_flag & NQNFSNONCACHE) {
970 error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
971 if (error)
972 return (error);
973 }
974 } else if ((n + on) == biosize &&
975 (nmp->nm_flag & NFSMNT_NQNFS) == 0) {
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) {
976 bp->b_proc = (struct proc *)0;
977 bp->b_flags |= B_ASYNC;
974 bp->b_flags |= B_ASYNC;
978 (void)nfs_writebp(bp, 0);
975 (void)nfs_writebp(bp, 0, 0);
979 } else {
980 bdwrite(bp);
981 }
982 } while (uio->uio_resid > 0 && n > 0);
983 return (0);
984}
985
986/*

--- 105 unchanged lines hidden (view full) ---

1092 * Initiate asynchronous I/O. Return an error if no nfsiods are available.
1093 * This is mainly to avoid queueing async I/O requests when the nfsiods
1094 * are all hung on a dead server.
1095 *
1096 * Note: nfs_asyncio() does not clear (B_ERROR|B_INVAL) but when the bp
1097 * is eventually dequeued by the async daemon, nfs_doio() *will*.
1098 */
1099int
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
1100nfs_asyncio(bp, cred)
1097nfs_asyncio(bp, cred, procp)
1101 register struct buf *bp;
1102 struct ucred *cred;
1098 register struct buf *bp;
1099 struct ucred *cred;
1100 struct proc *procp;
1103{
1104 struct nfsmount *nmp;
1105 int i;
1106 int gotiod;
1107 int slpflag = 0;
1108 int slptimeo = 0;
1109 int error;
1110

--- 49 unchanged lines hidden (view full) ---

1160 */
1161 while (nmp->nm_bufqlen >= 2*nfs_numasync) {
1162 NFS_DPF(ASYNCIO,
1163 ("nfs_asyncio: waiting for mount %p queue to drain\n", nmp));
1164 nmp->nm_bufqwant = TRUE;
1165 error = tsleep(&nmp->nm_bufq, slpflag | PRIBIO,
1166 "nfsaio", slptimeo);
1167 if (error) {
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) {
1168 if (nfs_sigintr(nmp, NULL, bp->b_proc))
1166 if (nfs_sigintr(nmp, NULL, procp))
1169 return (EINTR);
1170 if (slpflag == PCATCH) {
1171 slpflag = 0;
1172 slptimeo = 2 * hz;
1173 }
1174 }
1175 /*
1176 * We might have lost our iod while sleeping,

--- 247 unchanged lines hidden ---
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 ---