diff options
author | Stephan Uphoff <ups@FreeBSD.org> | 2005-10-24 14:23:04 +0000 |
---|---|---|
committer | Stephan Uphoff <ups@FreeBSD.org> | 2005-10-24 14:23:04 +0000 |
commit | 198b0a3b71468182952344eaa5b03dd2b405c689 (patch) | |
tree | 1872d5f6e0e62c3c1a3c148f24db744d105cedad /sys/kern/vfs_cluster.c | |
parent | 4339c67c485f0b1f7699863fc29f6c06862d1dde (diff) | |
download | src-198b0a3b71468182952344eaa5b03dd2b405c689.tar.gz src-198b0a3b71468182952344eaa5b03dd2b405c689.zip |
Only set B_RAM (Read ahead mark) on an incore buffers if we can lock it.
This fixes a race condition caused by the unlocked write access to the
b_flags field.
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=151621
Diffstat (limited to 'sys/kern/vfs_cluster.c')
-rw-r--r-- | sys/kern/vfs_cluster.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index ed80fc522a91..01fa49e0f14a 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -142,11 +142,16 @@ cluster_read(vp, filesize, lblkno, size, cred, totread, seqcount, bpp) /* * Set another read-ahead mark so we know - * to check again. + * to check again. (If we can lock the + * buffer without waiting) */ - if (((i % racluster) == (racluster - 1)) || - (i == (maxra - 1))) + if ((((i % racluster) == (racluster - 1)) || + (i == (maxra - 1))) + && (0 == BUF_LOCK(rbp, + LK_EXCLUSIVE | LK_NOWAIT, NULL))) { rbp->b_flags |= B_RAM; + BUF_UNLOCK(rbp); + } } VI_UNLOCK(vp); if (i >= maxra) { |