summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--sys/fs/hpfs/hpfs_alsubr.c2
-rw-r--r--sys/fs/hpfs/hpfs_subr.c4
-rw-r--r--sys/fs/hpfs/hpfs_vnops.c2
-rw-r--r--sys/fs/msdosfs/msdosfs_fat.c13
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c4
-rw-r--r--sys/fs/ntfs/ntfs_subr.c2
-rw-r--r--sys/gnu/ext2fs/ext2_balloc.c10
-rw-r--r--sys/gnu/ext2fs/ext2_bmap.c2
-rw-r--r--sys/gnu/ext2fs/ext2_inode.c2
-rw-r--r--sys/gnu/ext2fs/ext2_vfsops.c2
-rw-r--r--sys/gnu/fs/ext2fs/ext2_balloc.c10
-rw-r--r--sys/gnu/fs/ext2fs/ext2_bmap.c2
-rw-r--r--sys/gnu/fs/ext2fs/ext2_inode.c2
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vfsops.c2
-rw-r--r--sys/kern/vfs_bio.c15
-rw-r--r--sys/kern/vfs_cluster.c8
-rw-r--r--sys/nfsclient/nfs_bio.c6
-rw-r--r--sys/sys/buf.h7
-rw-r--r--sys/ufs/ffs/ffs_alloc.c2
-rw-r--r--sys/ufs/ffs/ffs_balloc.c22
-rw-r--r--sys/ufs/ffs/ffs_inode.c2
-rw-r--r--sys/ufs/ffs/ffs_snapshot.c4
-rw-r--r--sys/ufs/ffs/ffs_softdep.c2
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c4
-rw-r--r--sys/ufs/ufs/ufs_bmap.c2
25 files changed, 73 insertions, 60 deletions
diff --git a/sys/fs/hpfs/hpfs_alsubr.c b/sys/fs/hpfs/hpfs_alsubr.c
index 07d928e..226865f 100644
--- a/sys/fs/hpfs/hpfs_alsubr.c
+++ b/sys/fs/hpfs/hpfs_alsubr.c
@@ -181,7 +181,7 @@ hpfs_allocalsec (
if (error)
return (error);
- bp = getblk(hpmp->hpm_devvp, lsn, DEV_BSIZE, 0, 0);
+ bp = getblk(hpmp->hpm_devvp, lsn, DEV_BSIZE, 0, 0, 0);
clrbuf(bp);
/* Fill AlSec info */
diff --git a/sys/fs/hpfs/hpfs_subr.c b/sys/fs/hpfs/hpfs_subr.c
index b45ebbd..a547027 100644
--- a/sys/fs/hpfs/hpfs_subr.c
+++ b/sys/fs/hpfs/hpfs_subr.c
@@ -75,7 +75,7 @@ hpfs_bmdeinit(
dprintf(("[%d: 0x%x] ", i, hpmp->hpm_bmind[i]));
bp = getblk(hpmp->hpm_devvp, hpmp->hpm_bmind[i],
- BMSIZE, 0, 0);
+ BMSIZE, 0, 0, 0);
clrbuf(bp);
bcopy(hpmp->hpm_bitmap + BMSIZE * i, bp->b_data,
@@ -732,7 +732,7 @@ hpfs_update (
if (!(hp->h_flag & H_CHANGE))
return (0);
- bp = getblk(hp->h_devvp, hp->h_no, FNODESIZE, 0, 0);
+ bp = getblk(hp->h_devvp, hp->h_no, FNODESIZE, 0, 0, 0);
clrbuf(bp);
bcopy (&hp->h_fn, bp->b_data, sizeof(struct fnode));
diff --git a/sys/fs/hpfs/hpfs_vnops.c b/sys/fs/hpfs/hpfs_vnops.c
index 40649e1..51d445d 100644
--- a/sys/fs/hpfs/hpfs_vnops.c
+++ b/sys/fs/hpfs/hpfs_vnops.c
@@ -372,7 +372,7 @@ hpfs_write(ap)
bn, runl, towrite, xfersz));
if ((off == 0) && (towrite == xfersz)) {
- bp = getblk(hp->h_devvp, bn, xfersz, 0, 0);
+ bp = getblk(hp->h_devvp, bn, xfersz, 0, 0, 0);
clrbuf(bp);
} else {
error = bread(hp->h_devvp, bn, xfersz, NOCRED, &bp);
diff --git a/sys/fs/msdosfs/msdosfs_fat.c b/sys/fs/msdosfs/msdosfs_fat.c
index c1b8a9d..1e9a3cf 100644
--- a/sys/fs/msdosfs/msdosfs_fat.c
+++ b/sys/fs/msdosfs/msdosfs_fat.c
@@ -398,7 +398,8 @@ updatefats(pmp, bp, fatbn)
for (i = 1; i < pmp->pm_FATs; i++) {
fatbn += pmp->pm_FATsecs;
/* getblk() never fails */
- bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0);
+ bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount,
+ 0, 0, 0);
bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
bwrite(bpn);
@@ -1074,11 +1075,13 @@ extendfile(dep, count, bpp, ncp, flags)
* Get the buf header for the new block of the file.
*/
if (dep->de_Attributes & ATTR_DIRECTORY)
- bp = getblk(pmp->pm_devvp, cntobn(pmp, cn++),
- pmp->pm_bpcluster, 0, 0);
+ bp = getblk(pmp->pm_devvp,
+ cntobn(pmp, cn++),
+ pmp->pm_bpcluster, 0, 0, 0);
else {
- bp = getblk(DETOV(dep), de_cn2bn(pmp, frcn++),
- pmp->pm_bpcluster, 0, 0);
+ bp = getblk(DETOV(dep),
+ de_cn2bn(pmp, frcn++),
+ pmp->pm_bpcluster, 0, 0, 0);
/*
* Do the bmap now, as in msdosfs_write
*/
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index f54fc57..910ce7b 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -711,7 +711,7 @@ msdosfs_write(ap)
* or we write the cluster from its start beyond EOF,
* then no need to read data from disk.
*/
- bp = getblk(thisvp, bn, pmp->pm_bpcluster, 0, 0);
+ bp = getblk(thisvp, bn, pmp->pm_bpcluster, 0, 0, 0);
clrbuf(bp);
/*
* Do the bmap now, since pcbmap needs buffers
@@ -1301,7 +1301,7 @@ msdosfs_mkdir(ap)
*/
bn = cntobn(pmp, newcluster);
/* always succeeds */
- bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0);
+ bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0, 0);
bzero(bp->b_data, pmp->pm_bpcluster);
bcopy(&dosdirtemplate, bp->b_data, sizeof dosdirtemplate);
denp = (struct direntry *)bp->b_data;
diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c
index 20b98a5..68f654f 100644
--- a/sys/fs/ntfs/ntfs_subr.c
+++ b/sys/fs/ntfs/ntfs_subr.c
@@ -1453,7 +1453,7 @@ ntfs_writentvattr_plain(
if ((off == 0) && (tocopy == ntfs_cntob(cl)))
{
bp = getblk(ntmp->ntm_devvp, ntfs_cntobn(cn),
- ntfs_cntob(cl), 0, 0);
+ ntfs_cntob(cl), 0, 0, 0);
clrbuf(bp);
} else {
error = bread(ntmp->ntm_devvp, ntfs_cntobn(cn),
diff --git a/sys/gnu/ext2fs/ext2_balloc.c b/sys/gnu/ext2fs/ext2_balloc.c
index 62a94c1..53946e5 100644
--- a/sys/gnu/ext2fs/ext2_balloc.c
+++ b/sys/gnu/ext2fs/ext2_balloc.c
@@ -147,7 +147,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
nsize, cred, &newb);
if (error)
return (error);
- bp = getblk(vp, bn, nsize, 0, 0);
+ bp = getblk(vp, bn, nsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
if (flags & B_CLRBUF)
vfs_bio_clrbuf(bp);
@@ -194,7 +194,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
cred, &newb)) != 0)
return (error);
nb = newb;
- bp = getblk(vp, indirs[1].in_lbn, fs->s_blocksize, 0, 0);
+ bp = getblk(vp, indirs[1].in_lbn, fs->s_blocksize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
vfs_bio_clrbuf(bp);
/*
@@ -246,7 +246,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
return (error);
}
nb = newb;
- nbp = getblk(vp, indirs[i].in_lbn, fs->s_blocksize, 0, 0);
+ nbp = getblk(vp, indirs[i].in_lbn, fs->s_blocksize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(nbp);
/*
@@ -281,7 +281,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
return (error);
}
nb = newb;
- nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0);
+ nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
if (flags & B_CLRBUF)
vfs_bio_clrbuf(nbp);
@@ -306,7 +306,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
return (error);
}
} else {
- nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0);
+ nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
}
*bpp = nbp;
diff --git a/sys/gnu/ext2fs/ext2_bmap.c b/sys/gnu/ext2fs/ext2_bmap.c
index 69a069f..1260d97f 100644
--- a/sys/gnu/ext2fs/ext2_bmap.c
+++ b/sys/gnu/ext2fs/ext2_bmap.c
@@ -185,7 +185,7 @@ ext2_bmaparray(vp, bn, bnp, runp, runb)
bqrelse(bp);
ap->in_exists = 1;
- bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0);
+ bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0, 0);
if ((bp->b_flags & B_CACHE) == 0) {
#ifdef DIAGNOSTIC
if (!daddr)
diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c
index fc14dba..806c8a3 100644
--- a/sys/gnu/ext2fs/ext2_inode.c
+++ b/sys/gnu/ext2fs/ext2_inode.c
@@ -396,7 +396,7 @@ ext2_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
* explicitly instead of letting bread do everything for us.
*/
vp = ITOV(ip);
- bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0);
+ bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0, 0);
if (bp->b_flags & (B_DONE | B_DELWRI)) {
} else {
bp->b_iocmd = BIO_READ;
diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c
index d91a92e..964be9f 100644
--- a/sys/gnu/ext2fs/ext2_vfsops.c
+++ b/sys/gnu/ext2fs/ext2_vfsops.c
@@ -1179,7 +1179,7 @@ ext2_sbupdate(mp, waitfor)
/*
printf("\nupdating superblock, waitfor=%s\n", waitfor == MNT_WAIT ? "yes":"no");
*/
- bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0);
+ bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0, 0);
bcopy((caddr_t)es, bp->b_data, (u_int)sizeof(struct ext2_super_block));
if (waitfor == MNT_WAIT)
error = bwrite(bp);
diff --git a/sys/gnu/fs/ext2fs/ext2_balloc.c b/sys/gnu/fs/ext2fs/ext2_balloc.c
index 62a94c1..53946e5 100644
--- a/sys/gnu/fs/ext2fs/ext2_balloc.c
+++ b/sys/gnu/fs/ext2fs/ext2_balloc.c
@@ -147,7 +147,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
nsize, cred, &newb);
if (error)
return (error);
- bp = getblk(vp, bn, nsize, 0, 0);
+ bp = getblk(vp, bn, nsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
if (flags & B_CLRBUF)
vfs_bio_clrbuf(bp);
@@ -194,7 +194,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
cred, &newb)) != 0)
return (error);
nb = newb;
- bp = getblk(vp, indirs[1].in_lbn, fs->s_blocksize, 0, 0);
+ bp = getblk(vp, indirs[1].in_lbn, fs->s_blocksize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
vfs_bio_clrbuf(bp);
/*
@@ -246,7 +246,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
return (error);
}
nb = newb;
- nbp = getblk(vp, indirs[i].in_lbn, fs->s_blocksize, 0, 0);
+ nbp = getblk(vp, indirs[i].in_lbn, fs->s_blocksize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(nbp);
/*
@@ -281,7 +281,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
return (error);
}
nb = newb;
- nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0);
+ nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
if (flags & B_CLRBUF)
vfs_bio_clrbuf(nbp);
@@ -306,7 +306,7 @@ ext2_debug("ext2_balloc called (%d, %d, %d)\n",
return (error);
}
} else {
- nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0);
+ nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
}
*bpp = nbp;
diff --git a/sys/gnu/fs/ext2fs/ext2_bmap.c b/sys/gnu/fs/ext2fs/ext2_bmap.c
index 69a069f..1260d97f 100644
--- a/sys/gnu/fs/ext2fs/ext2_bmap.c
+++ b/sys/gnu/fs/ext2fs/ext2_bmap.c
@@ -185,7 +185,7 @@ ext2_bmaparray(vp, bn, bnp, runp, runb)
bqrelse(bp);
ap->in_exists = 1;
- bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0);
+ bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0, 0);
if ((bp->b_flags & B_CACHE) == 0) {
#ifdef DIAGNOSTIC
if (!daddr)
diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c
index fc14dba..806c8a3 100644
--- a/sys/gnu/fs/ext2fs/ext2_inode.c
+++ b/sys/gnu/fs/ext2fs/ext2_inode.c
@@ -396,7 +396,7 @@ ext2_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
* explicitly instead of letting bread do everything for us.
*/
vp = ITOV(ip);
- bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0);
+ bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0, 0);
if (bp->b_flags & (B_DONE | B_DELWRI)) {
} else {
bp->b_iocmd = BIO_READ;
diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c
index d91a92e..964be9f 100644
--- a/sys/gnu/fs/ext2fs/ext2_vfsops.c
+++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c
@@ -1179,7 +1179,7 @@ ext2_sbupdate(mp, waitfor)
/*
printf("\nupdating superblock, waitfor=%s\n", waitfor == MNT_WAIT ? "yes":"no");
*/
- bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0);
+ bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0, 0);
bcopy((caddr_t)es, bp->b_data, (u_int)sizeof(struct ext2_super_block));
if (waitfor == MNT_WAIT)
error = bwrite(bp);
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
diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c
index c124e64..379419e 100644
--- a/sys/nfsclient/nfs_bio.c
+++ b/sys/nfsclient/nfs_bio.c
@@ -1032,14 +1032,14 @@ nfs_getcacheblk(struct vnode *vp, daddr_t bn, int size, struct thread *td)
nmp = VFSTONFS(mp);
if (nmp->nm_flag & NFSMNT_INT) {
- bp = getblk(vp, bn, size, PCATCH, 0);
+ bp = getblk(vp, bn, size, PCATCH, 0, 0);
while (bp == NULL) {
if (nfs_sigintr(nmp, NULL, td))
return (NULL);
- bp = getblk(vp, bn, size, 0, 2 * hz);
+ bp = getblk(vp, bn, size, 0, 2 * hz, 0);
}
} else {
- bp = getblk(vp, bn, size, 0, 0);
+ bp = getblk(vp, bn, size, 0, 0, 0);
}
if (vp->v_type == VREG) {
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 7b709b5..2928ecd 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -455,6 +455,11 @@ buf_countdeps(struct buf *bp, int i)
(bp)->b_resid = 0; \
}
+/*
+ * Flags for getblk's last parameter.
+ */
+#define GB_LOCK_NOWAIT 0x0001 /* Fail if we block on a buf lock. */
+
#ifdef _KERNEL
extern int nbuf; /* The number of buffer headers */
extern int maxswzone; /* Max KVA for swap structures */
@@ -489,7 +494,7 @@ struct buf * getpbuf(int *);
struct buf *incore(struct vnode *, daddr_t);
struct buf *gbincore(struct vnode *, daddr_t);
int inmem(struct vnode *, daddr_t);
-struct buf *getblk(struct vnode *, daddr_t, int, int, int);
+struct buf *getblk(struct vnode *, daddr_t, int, int, int, int);
struct buf *geteblk(int);
int bufwait(struct buf *);
void bufdone(struct buf *);
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index 881fdca..2ebf67e 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -1626,7 +1626,7 @@ gotit:
cgp->cg_initediblk < cgp->cg_niblk) {
ibp = getblk(ip->i_devvp, fsbtodb(fs,
ino_to_fsba(fs, cg * fs->fs_ipg + cgp->cg_initediblk)),
- (int)fs->fs_bsize, 0, 0);
+ (int)fs->fs_bsize, 0, 0, 0);
bzero(ibp->b_data, (int)fs->fs_bsize);
dp2 = (struct ufs2_dinode *)(ibp->b_data);
for (i = 0; i < INOPB(fs); i++) {
diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c
index fda439d..74d9152 100644
--- a/sys/ufs/ffs/ffs_balloc.c
+++ b/sys/ufs/ffs/ffs_balloc.c
@@ -176,7 +176,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
nsize, cred, &newb);
if (error)
return (error);
- bp = getblk(vp, lbn, nsize, 0, 0);
+ bp = getblk(vp, lbn, nsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
if (flags & BA_CLRBUF)
vfs_bio_clrbuf(bp);
@@ -213,7 +213,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
return (error);
nb = newb;
*allocblk++ = nb;
- bp = getblk(vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0);
+ bp = getblk(vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(bp);
if (DOINGSOFTDEP(vp)) {
@@ -262,7 +262,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
}
nb = newb;
*allocblk++ = nb;
- nbp = getblk(vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0);
+ nbp = getblk(vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(nbp);
if (DOINGSOFTDEP(vp)) {
@@ -314,7 +314,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
}
nb = newb;
*allocblk++ = nb;
- nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0);
+ nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
if (flags & BA_CLRBUF)
vfs_bio_clrbuf(nbp);
@@ -351,7 +351,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
goto fail;
}
} else {
- nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0);
+ nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
}
*bpp = nbp;
@@ -541,7 +541,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
nsize, cred, &newb);
if (error)
return (error);
- bp = getblk(vp, -1 - lbn, nsize, 0, 0);
+ bp = getblk(vp, -1 - lbn, nsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
bp->b_xflags |= BX_ALTDATA;
if (flags & BA_CLRBUF)
@@ -637,7 +637,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
&dp->di_db[0]), nsize, cred, &newb);
if (error)
return (error);
- bp = getblk(vp, lbn, nsize, 0, 0);
+ bp = getblk(vp, lbn, nsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
if (flags & BA_CLRBUF)
vfs_bio_clrbuf(bp);
@@ -674,7 +674,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
return (error);
nb = newb;
*allocblk++ = nb;
- bp = getblk(vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0);
+ bp = getblk(vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(bp);
if (DOINGSOFTDEP(vp)) {
@@ -723,7 +723,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
}
nb = newb;
*allocblk++ = nb;
- nbp = getblk(vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0);
+ nbp = getblk(vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(nbp);
if (DOINGSOFTDEP(vp)) {
@@ -775,7 +775,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
}
nb = newb;
*allocblk++ = nb;
- nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0);
+ nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
if (flags & BA_CLRBUF)
vfs_bio_clrbuf(nbp);
@@ -818,7 +818,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
goto fail;
}
} else {
- nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0);
+ nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
}
*bpp = nbp;
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index ed4e04c..ef24fb0 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -549,7 +549,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
* explicitly instead of letting bread do everything for us.
*/
vp = ITOV(ip);
- bp = getblk(vp, lbn, (int)fs->fs_bsize, 0, 0);
+ bp = getblk(vp, lbn, (int)fs->fs_bsize, 0, 0, 0);
if ((bp->b_flags & B_CACHE) == 0) {
curproc->p_stats->p_ru.ru_inblock++; /* pay for read */
bp->b_iocmd = BIO_READ;
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index afbea57..653d5f8 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -899,7 +899,7 @@ indiracct_ufs1(snapvp, cancelvp, level, blkno, lbn, rlbn, remblks,
* We have to expand bread here since it will deadlock looking
* up the block number for any blocks that are not in the cache.
*/
- bp = getblk(cancelvp, lbn, fs->fs_bsize, 0, 0);
+ bp = getblk(cancelvp, lbn, fs->fs_bsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, blkno);
if ((bp->b_flags & (B_DONE | B_DELWRI)) == 0 &&
(error = readblock(bp, fragstoblks(fs, blkno)))) {
@@ -1174,7 +1174,7 @@ indiracct_ufs2(snapvp, cancelvp, level, blkno, lbn, rlbn, remblks,
* We have to expand bread here since it will deadlock looking
* up the block number for any blocks that are not in the cache.
*/
- bp = getblk(cancelvp, lbn, fs->fs_bsize, 0, 0);
+ bp = getblk(cancelvp, lbn, fs->fs_bsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, blkno);
if ((bp->b_flags & (B_DONE | B_DELWRI)) == 0 &&
(error = readblock(bp, fragstoblks(fs, blkno)))) {
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 3678404..3d3fd92 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -1896,7 +1896,7 @@ setup_allocindir_phase2(bp, ip, aip)
bp->b_blkno = blkno;
}
newindirdep->ir_savebp =
- getblk(ip->i_devvp, bp->b_blkno, bp->b_bcount, 0, 0);
+ getblk(ip->i_devvp, bp->b_blkno, bp->b_bcount, 0, 0, 0);
BUF_KERNPROC(newindirdep->ir_savebp);
bcopy(bp->b_data, newindirdep->ir_savebp->b_data, bp->b_bcount);
}
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 1d9cd21..17aab31 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1483,7 +1483,7 @@ ffs_sbupdate(mp, waitfor)
if (i + fs->fs_frag > blks)
size = (blks - i) * fs->fs_fsize;
bp = getblk(mp->um_devvp, fsbtodb(fs, fs->fs_csaddr + i),
- size, 0, 0);
+ size, 0, 0, 0);
bcopy(space, bp->b_data, (u_int)size);
space = (char *)space + size;
if (waitfor != MNT_WAIT)
@@ -1511,7 +1511,7 @@ ffs_sbupdate(mp, waitfor)
fs->fs_sblockloc = SBLOCK_UFS2;
}
bp = getblk(mp->um_devvp, btodb(fs->fs_sblockloc), (int)fs->fs_sbsize,
- 0, 0);
+ 0, 0, 0);
fs->fs_fmod = 0;
fs->fs_time = time_second;
bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c
index 4630b68..2eab99d 100644
--- a/sys/ufs/ufs/ufs_bmap.c
+++ b/sys/ufs/ufs/ufs_bmap.c
@@ -215,7 +215,7 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb)
bqrelse(bp);
ap->in_exists = 1;
- bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0);
+ bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0, 0);
if ((bp->b_flags & B_CACHE) == 0) {
#ifdef DIAGNOSTIC
if (!daddr)
OpenPOWER on IntegriCloud