[Ocfs2-devel] [PATCH 1/1] Ocfs2: Handle invalid lock_res in lockres_seq_start() for dlmdebug.c

Sunil Mushran sunil.mushran at oracle.com
Thu Sep 9 18:26:42 PDT 2010


On 09/09/2010 06:20 PM, tristan wrote:
>>>   1 files changed, 7 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
>>> index 5efdd37..06d668a 100644
>>> --- a/fs/ocfs2/dlm/dlmdebug.c
>>> +++ b/fs/ocfs2/dlm/dlmdebug.c
>>> @@ -639,6 +639,12 @@ static void *lockres_seq_start(struct seq_file 
>>> *m, loff_t *pos)
>>>       else
>>>           track_list =&dlm->tracking_list;
>>>
>>> +    if (list_empty(track_list)) {
>>> +        dl = NULL;
>>> +        spin_unlock(&dlm->track_lock);
>>> +        goto bail;
>>> +    }
>>> +
>>
>> You should add this check as part of the else block above so
>> that we check for empty list only at the start.
>   fs/ocfs2/dlm/dlmdebug.c |    7 +++++++
>
> So we just don't need to check list 'oldres->tracking'?

If you see how it works, it prints one lock resource at a time. As in,
each time _start is called, it fetches the next lock resource in the 
tracking
list. So the empty list should be checked only at the very beginning.

To be fair, your code should also work. If the list has even one lockres,
it cannot, by definition, be empty. But adding it in the if block makes the
check explicit and clean. IMHO.



More information about the Ocfs2-devel mailing list