On Thu, Jan 30, 2014 at 2:02 AM, Andriy Gapon <[email protected]> wrote:

>
> I can not figure out how the following code actually works.
> Probably I am missing something in the big picture (again).
>
> if (HDR_L2_WRITE_HEAD(ab)) {
>         /*
>          * We hit a write head node.  Leave it for
>          * l2arc_write_done().
>          */
>         list_remove(buflist, ab);
>         mutex_exit(hash_lock);
>         continue;
> }
>
> So, the write head is left in memory, but it is still removed from
> l2ad_buflist.
> Supposing there is a corresponding L2 write zio in progress there will be
> a call
> to l2arc_write_done() with l2wcb_head pointing to the head.
> Wouldn't
>         list_prev(buflist, head)
> result in an illegal memory access if head is not on buflist?
>

Yes, it would.  Thankfully, we don't call list_prev() after removing it.
 The loop in l2arc_evict() begins with:

for (ab = list_tail(buflist); ab; ab = ab_prev) {
ab_prev = list_prev(buflist, ab);

--matt
_______________________________________________
developer mailing list
[email protected]
http://lists.open-zfs.org/mailman/listinfo/developer

Reply via email to