summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2003-03-04 00:04:44 +0000
committerjeff <jeff@FreeBSD.org>2003-03-04 00:04:44 +0000
commit4de0ae322cb45ae3620fef3a8fcf76d44208ee44 (patch)
tree60aed2b4c31a2d4a3c1cc94b83966280f8fc3eae /sys/kern
parent7880d78b5504f8df1d22b8539ee31167ccd22750 (diff)
downloadFreeBSD-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')
-rw-r--r--sys/kern/vfs_bio.c15
-rw-r--r--sys/kern/vfs_cluster.c8
2 files changed, 14 insertions, 9 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);
/*
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c
index 96e541c..bf944c5 100644
--- a/sys/kern/vfs_cluster.c
+++ b/sys/kern/vfs_cluster.c
@@ -125,7 +125,7 @@ cluster_read(vp, filesize, lblkno, size, cred, totread, seqcount, bpp)
/*
* get the requested block
*/
- *bpp = reqbp = bp = getblk(vp, lblkno, size, 0, 0);
+ *bpp = reqbp = bp = getblk(vp, lblkno, size, 0, 0, 0);
origblkno = lblkno;
origtotread = totread;
@@ -243,7 +243,7 @@ single_block_read:
rbp = cluster_rbuild(vp, filesize, lblkno,
blkno, size, ntoread, NULL);
} else {
- rbp = getblk(vp, lblkno, size, 0, 0);
+ rbp = getblk(vp, lblkno, size, 0, 0, 0);
rbp->b_flags |= B_ASYNC | B_RAM;
rbp->b_iocmd = BIO_READ;
rbp->b_blkno = blkno;
@@ -349,7 +349,7 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
tbp = fbp;
tbp->b_iocmd = BIO_READ;
} else {
- tbp = getblk(vp, lbn, size, 0, 0);
+ tbp = getblk(vp, lbn, size, 0, 0, 0);
if (tbp->b_flags & B_CACHE)
return tbp;
tbp->b_flags |= B_ASYNC | B_RAM;
@@ -420,7 +420,7 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
break;
}
- tbp = getblk(vp, lbn + i, size, 0, 0);
+ tbp = getblk(vp, lbn + i, size, 0, 0, 0);
/*
* Stop scanning if the buffer is fully valid
OpenPOWER on IntegriCloud