diff options
author | jeff <jeff@FreeBSD.org> | 2003-03-04 00:04:44 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2003-03-04 00:04:44 +0000 |
commit | 4de0ae322cb45ae3620fef3a8fcf76d44208ee44 (patch) | |
tree | 60aed2b4c31a2d4a3c1cc94b83966280f8fc3eae /sys/kern/vfs_bio.c | |
parent | 7880d78b5504f8df1d22b8539ee31167ccd22750 (diff) | |
download | FreeBSD-src-4de0ae322cb45ae3620fef3a8fcf76d44208ee44.zip FreeBSD-src-4de0ae322cb45ae3620fef3a8fcf76d44208ee44.tar.gz |
- Add a new 'flags' parameter to getblk().
- Define one flag GB_LOCK_NOWAIT that tells getblk() to pass the LK_NOWAIT
flag to the initial BUF_LOCK(). This will eventually be used in cases
were we want to use a buffer only if it is not currently in use.
- Convert all consumers of the getblk() api to use this extra parameter.
Reviwed by: arch
Not objected to by: mckusick
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r-- | sys/kern/vfs_bio.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 10ad7dc..a2807e9 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -680,7 +680,7 @@ breadn(struct vnode * vp, daddr_t blkno, int size, int i; int rv = 0, readwait = 0; - *bpp = bp = getblk(vp, blkno, size, 0, 0); + *bpp = bp = getblk(vp, blkno, size, 0, 0, 0); /* if not found in cache, do some I/O */ if ((bp->b_flags & B_CACHE) == 0) { @@ -702,7 +702,7 @@ breadn(struct vnode * vp, daddr_t blkno, int size, for (i = 0; i < cnt; i++, rablkno++, rabsize++) { if (inmem(vp, *rablkno)) continue; - rabp = getblk(vp, *rablkno, *rabsize, 0, 0); + rabp = getblk(vp, *rablkno, *rabsize, 0, 0, 0); if ((rabp->b_flags & B_CACHE) == 0) { if (curthread != PCPU_GET(idlethread)) @@ -2367,7 +2367,8 @@ vfs_setdirty(struct buf *bp) * prior to issuing the READ. biodone() will *not* clear B_INVAL. */ struct buf * -getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo) +getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo, + int flags) { struct buf *bp; int s; @@ -2399,13 +2400,17 @@ loop: VI_LOCK(vp); if ((bp = gbincore(vp, blkno))) { + int lockflags; /* * Buffer is in-core. If the buffer is not busy, it must * be on a queue. */ + lockflags = LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK; - error = BUF_TIMELOCK(bp, - LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK, + if (flags & GB_LOCK_NOWAIT) + lockflags |= LK_NOWAIT; + + error = BUF_TIMELOCK(bp, lockflags, VI_MTX(vp), "getblk", slpflag, slptimeo); /* |