Skip to content

Commit a7ca422

Browse files
geliangtangkdave
authored andcommitted
btrfs: use list_for_each_entry* in backref.c
Use list_for_each_entry*() to simplify the code. Signed-off-by: Geliang Tang <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 7ae1681 commit a7ca422

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

fs/btrfs/backref.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,10 @@ static inline int ref_for_same_block(struct __prelim_ref *ref1,
520520
static int __add_missing_keys(struct btrfs_fs_info *fs_info,
521521
struct list_head *head)
522522
{
523-
struct list_head *pos;
523+
struct __prelim_ref *ref;
524524
struct extent_buffer *eb;
525525

526-
list_for_each(pos, head) {
527-
struct __prelim_ref *ref;
528-
ref = list_entry(pos, struct __prelim_ref, list);
529-
526+
list_for_each_entry(ref, head, list) {
530527
if (ref->parent)
531528
continue;
532529
if (ref->key_for_search.type)
@@ -563,23 +560,15 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
563560
*/
564561
static void __merge_refs(struct list_head *head, int mode)
565562
{
566-
struct list_head *pos1;
563+
struct __prelim_ref *ref1;
567564

568-
list_for_each(pos1, head) {
569-
struct list_head *n2;
570-
struct list_head *pos2;
571-
struct __prelim_ref *ref1;
565+
list_for_each_entry(ref1, head, list) {
566+
struct __prelim_ref *ref2 = ref1, *tmp;
572567

573-
ref1 = list_entry(pos1, struct __prelim_ref, list);
574-
575-
for (pos2 = pos1->next, n2 = pos2->next; pos2 != head;
576-
pos2 = n2, n2 = pos2->next) {
577-
struct __prelim_ref *ref2;
568+
list_for_each_entry_safe_continue(ref2, tmp, head, list) {
578569
struct __prelim_ref *xchg;
579570
struct extent_inode_elem *eie;
580571

581-
ref2 = list_entry(pos2, struct __prelim_ref, list);
582-
583572
if (!ref_for_same_block(ref1, ref2))
584573
continue;
585574
if (mode == 1) {

0 commit comments

Comments
 (0)