diff options
author | ups <ups@FreeBSD.org> | 2005-10-24 14:23:04 +0000 |
---|---|---|
committer | ups <ups@FreeBSD.org> | 2005-10-24 14:23:04 +0000 |
commit | 580f26e209e5e52265db5f2d6c15c02525926fcf (patch) | |
tree | 1872d5f6e0e62c3c1a3c148f24db744d105cedad /sys/kern/vfs_cluster.c | |
parent | 5931c79161136c38c59ced85bd9c919fb37c8710 (diff) | |
download | FreeBSD-src-580f26e209e5e52265db5f2d6c15c02525926fcf.zip FreeBSD-src-580f26e209e5e52265db5f2d6c15c02525926fcf.tar.gz |
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
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 ed80fc5..01fa49e 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) { |