| 1341 | } |
| 1342 | |
| 1343 | int |
| 1344 | vfs_stdsync(mp, waitfor) |
| 1345 | struct mount *mp; |
| 1346 | int waitfor; |
| 1347 | { |
| 1348 | struct vnode *vp, *mvp; |
| 1349 | struct thread *td; |
| 1350 | int error, lockreq, allerror = 0; |
| 1351 | |
| 1352 | td = curthread; |
| 1353 | lockreq = LK_EXCLUSIVE | LK_INTERLOCK; |
| 1354 | if (waitfor != MNT_WAIT) |
| 1355 | lockreq |= LK_NOWAIT; |
| 1356 | /* |
| 1357 | * Force stale buffer cache information to be flushed. |
| 1358 | */ |
| 1359 | loop: |
| 1360 | MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { |
| 1361 | if (vp->v_bufobj.bo_dirty.bv_cnt == 0) { |
| 1362 | VI_UNLOCK(vp); |
| 1363 | continue; |
| 1364 | } |
| 1365 | if ((error = vget(vp, lockreq)) != 0) { |
| 1366 | if (error == ENOENT) { |
| 1367 | MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); |
| 1368 | goto loop; |
| 1369 | } |
| 1370 | continue; |
| 1371 | } |
| 1372 | error = VOP_FSYNC(vp, waitfor, td); |
| 1373 | if (error) |
| 1374 | allerror = error; |
| 1375 | vput(vp); |
| 1376 | } |
| 1377 | return (allerror); |
| 1378 | } |
| 1379 | |
| 1380 | int |
| 1381 | vfs_stdnosync (mp, waitfor) |