diff options
| author | Matthew Dillon <dillon@FreeBSD.org> | 2001-01-19 05:31:07 +0000 |
|---|---|---|
| committer | Matthew Dillon <dillon@FreeBSD.org> | 2001-01-19 05:31:07 +0000 |
| commit | bcc740c45371de671c013caa8b61cd23a33ea95c (patch) | |
| tree | 116618a927ec6e12c2bb6ab929e88f8662c913fc /sys/kern/vfs_cluster.c | |
| parent | 08812b3925ae0a1a184e562499deb9a3cc59ec40 (diff) | |
Notes
Diffstat (limited to 'sys/kern/vfs_cluster.c')
| -rw-r--r-- | sys/kern/vfs_cluster.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 088dc405589b..88362367ca8d 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -399,15 +399,22 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp) tbp = getblk(vp, lbn + i, size, 0, 0); - if ((tbp->b_flags & B_CACHE) || + /* + * If the buffer is already fully valid or locked + * (which could also mean that a background write is + * in progress), or the buffer is not backed by VMIO, + * stop. + */ + if ((tbp->b_flags & (B_CACHE|B_LOCKED)) || (tbp->b_flags & B_VMIO) == 0) { bqrelse(tbp); break; } - for (j = 0;j < tbp->b_npages; j++) + for (j = 0;j < tbp->b_npages; j++) { if (tbp->b_pages[j]->valid) break; + } if (j != tbp->b_npages) { bqrelse(tbp); @@ -710,8 +717,13 @@ cluster_wbuild(vp, size, start_lbn, len) while (len > 0) { s = splbio(); + /* + * If the buffer is not delayed-write (i.e. dirty), or it + * is delayed-write but either locked or inval, it cannot + * partake in teh clustered write. + */ if (((tbp = gbincore(vp, start_lbn)) == NULL) || - ((tbp->b_flags & (B_INVAL | B_DELWRI)) != B_DELWRI) || + ((tbp->b_flags & (B_LOCKED | B_INVAL | B_DELWRI)) != B_DELWRI) || BUF_LOCK(tbp, LK_EXCLUSIVE | LK_NOWAIT)) { ++start_lbn; --len; @@ -784,12 +796,16 @@ cluster_wbuild(vp, size, start_lbn, len) /* * If it IS in core, but has different - * characteristics, don't cluster with it. + * characteristics, or is locked (which + * means it could be undergoing a background + * I/O or be in a weird state), then don't + * cluster with it. */ if ((tbp->b_flags & (B_VMIO | B_CLUSTEROK | B_INVAL | B_DELWRI | B_NEEDCOMMIT)) != (B_DELWRI | B_CLUSTEROK | (bp->b_flags & (B_VMIO | B_NEEDCOMMIT))) || + (tbp->b_flags & B_LOCKED) || tbp->b_wcred != bp->b_wcred || BUF_LOCK(tbp, LK_EXCLUSIVE | LK_NOWAIT)) { splx(s); |
