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
This commit is contained in:
Stephan Uphoff 2005-10-24 14:23:04 +00:00
parent 4339c67c48
commit 198b0a3b71
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=151621

View File

@ -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) {