Skip to contentSkip to conversation

ocfs2: bug in dlm_process_recovery_data()

Ocfs2-devel Dan Carpenter 2 participants 4 messages Feb 9, 2010 – Feb 10, 2010 OCFS2

lore
Share & tools
lore
#0 lore raw

I noticed a change was merged to dlm_process_recovery_data() so I thought you might want to fix this as well.

fs/ocfs2/dlm/dlmrecovery.c
1788 list_for_each_entry(lock, tmpq, list) {
1789 if (lock->ml.cookie != ml->cookie)
1790 lock = NULL;

We dereference lock in list_for_each_entry(). Maybe you want list_for_each_entry_safe() or something?

1791 else
1792 break;
1793 }
1794 if (lock)
1795 break;

regards,
dan carpenter

#1 lore raw
Quoted 8 lines · Dan Carpenter

I noticed a change was merged to dlm_process_recovery_data() so I thought you might want to fix this as well.

fs/ocfs2/dlm/dlmrecovery.c
1788 list_for_each_entry(lock, tmpq, list) {
1789 if (lock->ml.cookie != ml->cookie)
1790 lock = NULL;

Quoted 9 lines

We dereference lock in list_for_each_entry(). Maybe you want list_for_each_entry_safe() or something?

1791 else
1792 break;
1793 }
1794 if (lock)
1795 break;

Why? That's only required if we are deleting a list entry.

#2 lore raw
Quoted 12 lines · Sunil Mushran
Quoted 11 lines · Dan Carpenter

I noticed a change was merged to dlm_process_recovery_data() so I thought you might want to fix this as well.

fs/ocfs2/dlm/dlmrecovery.c
1788 list_for_each_entry(lock, tmpq, list) {
1789 if (lock->ml.cookie != ml->cookie)
1790 lock = NULL;

We dereference lock in list_for_each_entry(). Maybe you want list_for_each_entry_safe() or something?

Quoted 8 lines
Quoted 6 lines

1791 else
1792 break;
1793 }
1794 if (lock)
1795 break;

Why? That's only required if we are deleting a list entry.

list_for_each() is defined in include/linux/list.h

/**
* list_for_each_entry - iterate over list of given type

 * @pos:        the type * to use as a loop cursor.
 * @head:       the head for your list.
 * @member:     the name of the list_struct within the struct.
 */
#define list_for_each_entry(pos, head, member)                          \
        for (pos = list_entry((head)->next, typeof(*pos), member);      \
             prefetch(pos->member.next), &pos->member != (head);        \
             pos = list_entry(pos->member.next, typeof(*pos), member))
                              ^^^^^^^^^^^^^^^^

In this case "pos" is "lock" so the code basically is doing this:
lock = NULL;

lock = list_entry(lock->member.next, typeof(*lock), member));
                  ^^^^^^^^^^^^^^^^^

regards,
dan carpenter

#3 lore raw
Quoted 5 lines · Dan Carpenter

In this case "pos" is "lock" so the code basically is doing this:
lock = NULL;

lock = list_entry(lock->member.next, typeof(*lock), member));
                  ^^^^^^^^^^^^^^^^^

Yes, you are correct. The reason it is working is because the resource will have only one lock on the list. This is the remastery code. I'll fix it.