| 2322 | } |
| 2323 | |
| 2324 | void |
| 2325 | bufbdflush(struct bufobj *bo, struct buf *bp) |
| 2326 | { |
| 2327 | struct buf *nbp; |
| 2328 | |
| 2329 | if (bo->bo_dirty.bv_cnt > dirtybufthresh + 10) { |
| 2330 | (void) VOP_FSYNC(bp->b_vp, MNT_NOWAIT, curthread); |
| 2331 | altbufferflushes++; |
| 2332 | } else if (bo->bo_dirty.bv_cnt > dirtybufthresh) { |
| 2333 | BO_LOCK(bo); |
| 2334 | /* |
| 2335 | * Try to find a buffer to flush. |
| 2336 | */ |
| 2337 | TAILQ_FOREACH(nbp, &bo->bo_dirty.bv_hd, b_bobufs) { |
| 2338 | if ((nbp->b_vflags & BV_BKGRDINPROG) || |
| 2339 | BUF_LOCK(nbp, |
| 2340 | LK_EXCLUSIVE | LK_NOWAIT, NULL)) |
| 2341 | continue; |
| 2342 | if (bp == nbp) |
| 2343 | panic("bdwrite: found ourselves"); |
| 2344 | BO_UNLOCK(bo); |
| 2345 | /* Don't countdeps with the bo lock held. */ |
| 2346 | if (buf_countdeps(nbp, 0)) { |
| 2347 | BO_LOCK(bo); |
| 2348 | BUF_UNLOCK(nbp); |
| 2349 | continue; |
| 2350 | } |
| 2351 | if (nbp->b_flags & B_CLUSTEROK) { |
| 2352 | vfs_bio_awrite(nbp); |
| 2353 | } else { |
| 2354 | bremfree(nbp); |
| 2355 | bawrite(nbp); |
| 2356 | } |
| 2357 | dirtybufferflushes++; |
| 2358 | break; |
| 2359 | } |
| 2360 | if (nbp == NULL) |
| 2361 | BO_UNLOCK(bo); |
| 2362 | } |
| 2363 | } |
| 2364 | |
| 2365 | /* |
| 2366 | * Delayed write. (Buffer is marked dirty). Do not bother writing |
nothing calls this directly
no test coverage detected