[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1205191140280.19017@eristoteles.iwoars.net>
Date: Sat, 19 May 2012 11:46:58 +0200 (CEST)
From: Joel Reardon <joel@...mbassador.com>
To: Artem Bityutskiy <dedekind1@...il.com>
cc: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH V2] UBI: add ubi_lnum_purge function to clear work queue
for a lnum
> Take the work_sem at the beginning. Release at the very end.
>
> Then you can do something like this:
>
> int found = 1;
>
> while (found) {
> found = 0;
>
> spin_lock(&ubi->wl_lock);
> list_for_each_entry(wrk, tmp, &ubi->works, list) {
> if (wrk->lnum == lnum) {
> list_del(&wrk->list);
> ubi->works_count -= 1;
> ubi_assert(ubi->works_count >= 0);
> spin_unlock(&ubi->wl_lock);
>
> err = wrk->func(ubi, wrk, 0);
> if (err)
> return err;
>
> spin_lock(&ubi->wl_lock);
> found = 1;
> break;
> }
> spin_unlock(&ubi->wl_lock);
> }
>
If I use list_for_each_entry_safe(), it protects against deleting as it
iterates. If I take the work_sem first, is it okay to do a simple
traversal instead of one traversal per removed item? Even if another
thread adds new work for the same vol_id/lnum, its okay, because the
caller of this function only cares about vol_id/lnums erasures that
it knows are currently on the worklist.
Cheers,
Joel Reardon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists