Re: [PATCH 6/7] dlm: debug fs

From: Jesper Juhl
Date: Mon Apr 25 2005 - 11:30:36 EST


On Mon, 25 Apr 2005, David Teigland wrote:

>
> A CONFIG setting optionally adds this file which creates a debugfs file
> for each lockspace: /debug/dlm/<lockspace_name>. Reading the debugfs file
> displays all resources/locks currently managed in the given lockspace.
>
> Signed-Off-By: Dave Teigland <teigland@xxxxxxxxxx>
> Signed-Off-By: Patrick Caulfield <pcaulfie@xxxxxxxxxx>
>
> ---
>
[...]
> +static int rsb_iter_next(struct rsb_iter *ri)
> +{
> + struct dlm_ls *ls = ri->ls;
> + int i;
> +
> + top:
> + if (!ri->next) {
> + /* Find the next non-empty hash bucket */
> + for (i = ri->entry; i < ls->ls_rsbtbl_size; i++) {
> + read_lock(&ls->ls_rsbtbl[i].lock);
> + if (!list_empty(&ls->ls_rsbtbl[i].list)) {
> + ri->next = ls->ls_rsbtbl[i].list.next;
> + read_unlock(&ls->ls_rsbtbl[i].lock);
> + break;
> + }
> + read_unlock(&ls->ls_rsbtbl[i].lock);
> + }
> + ri->entry = i;
> +
> + if (ri->entry >= ls->ls_rsbtbl_size)
> + return 1;
> + } else {
> + i = ri->entry;
> + read_lock(&ls->ls_rsbtbl[i].lock);
> + ri->next = ri->next->next;
> + if (ri->next->next == ls->ls_rsbtbl[i].list.next) {
> + /* End of list - move to next bucket */
> + ri->next = NULL;
> + ri->entry++;
> + read_unlock(&ls->ls_rsbtbl[i].lock);
> + goto top;
> + }
> + read_unlock(&ls->ls_rsbtbl[i].lock);
> + }
> + ri->rsb = list_entry(ri->next, struct dlm_rsb, res_hashchain);
> +
> + return 0;
> +}
Personally I think there must be a way to construct this function to be a
bit more readable, I'm playing with that, perhaps I'll come up with
something. But, in any case you might as well move the label 'top' inside
the if just before the for loop, since the only place you ever goto top
you've just set ri->next to NULL, so you know you are going to end up
inside the if in any case, no need to actually do the test every time.


--
Jesper Juhl


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/