[dm-devel] [PATCH] dm-bufio: prefetch
Alasdair G Kergon
agk at redhat.com
Tue Mar 13 23:04:50 UTC 2012
Let's move this 'found_buffer' code after both places that use it, I think.
(goto an earlier point in the function would normally mean a loop, which
this isn't)
Alasdair
On Tue, Mar 13, 2012 at 10:46:00AM -0400, Mikulas Patocka wrote:
> @@ -882,6 +888,19 @@ static struct dm_buffer *__bufio_new(str
>
> b = __find(c, block);
> if (b) {
> +found_buffer:
> + if (nf == NF_PREFETCH)
> + return NULL;
> + /*
> + * Note: it is essential that we don't wait for the buffer to be
> + * read if dm_bufio_get function is used. Both dm_bufio_get and
> + * dm_bufio_prefetch can be used in the driver request routine.
> + * If the user called both dm_bufio_prefetch and dm_bufio_get on
> + * the same buffer, it would deadlock if we waited.
> + */
> + if (nf == NF_GET && unlikely(test_bit(B_READING, &b->state)))
> + return NULL;
> +
> b->hold_count++;
> __relink_lru(b, test_bit(B_DIRTY, &b->state) ||
> test_bit(B_WRITING, &b->state));
> @@ -900,10 +921,7 @@ static struct dm_buffer *__bufio_new(str
> b = __find(c, block);
> if (b) {
> __free_buffer_wake(new_b);
> - b->hold_count++;
> - __relink_lru(b, test_bit(B_DIRTY, &b->state) ||
> - test_bit(B_WRITING, &b->state));
> - return b;
> + goto found_buffer;
> }
More information about the dm-devel
mailing list