aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@163.com>2015-12-21 10:50:23 -0500
committerDavid Sterba <dsterba@suse.com>2016-01-07 08:42:46 -0500
commita7ca42256d9fad572fb7f2c471514d7d3572b1db (patch)
tree71f23fc115664b87d48ecaa9b239737797060352
parent7ae1681e126919e7119cebebde1d42df8d7a49b9 (diff)
btrfs: use list_for_each_entry* in backref.c
Use list_for_each_entry*() to simplify the code. Signed-off-by: Geliang Tang <geliangtang@163.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/backref.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index d453d62ab0c6..08405a3da6b1 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -520,13 +520,10 @@ static inline int ref_for_same_block(struct __prelim_ref *ref1,
520static int __add_missing_keys(struct btrfs_fs_info *fs_info, 520static int __add_missing_keys(struct btrfs_fs_info *fs_info,
521 struct list_head *head) 521 struct list_head *head)
522{ 522{
523 struct list_head *pos; 523 struct __prelim_ref *ref;
524 struct extent_buffer *eb; 524 struct extent_buffer *eb;
525 525
526 list_for_each(pos, head) { 526 list_for_each_entry(ref, head, list) {
527 struct __prelim_ref *ref;
528 ref = list_entry(pos, struct __prelim_ref, list);
529
530 if (ref->parent) 527 if (ref->parent)
531 continue; 528 continue;
532 if (ref->key_for_search.type) 529 if (ref->key_for_search.type)
@@ -563,23 +560,15 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
563 */ 560 */
564static void __merge_refs(struct list_head *head, int mode) 561static void __merge_refs(struct list_head *head, int mode)
565{ 562{
566 struct list_head *pos1; 563 struct __prelim_ref *ref1;
567 564
568 list_for_each(pos1, head) { 565 list_for_each_entry(ref1, head, list) {
569 struct list_head *n2; 566 struct __prelim_ref *ref2 = ref1, *tmp;
570 struct list_head *pos2;
571 struct __prelim_ref *ref1;
572 567
573 ref1 = list_entry(pos1, struct __prelim_ref, list); 568 list_for_each_entry_safe_continue(ref2, tmp, head, list) {
574
575 for (pos2 = pos1->next, n2 = pos2->next; pos2 != head;
576 pos2 = n2, n2 = pos2->next) {
577 struct __prelim_ref *ref2;
578 struct __prelim_ref *xchg; 569 struct __prelim_ref *xchg;
579 struct extent_inode_elem *eie; 570 struct extent_inode_elem *eie;
580 571
581 ref2 = list_entry(pos2, struct __prelim_ref, list);
582
583 if (!ref_for_same_block(ref1, ref2)) 572 if (!ref_for_same_block(ref1, ref2))
584 continue; 573 continue;
585 if (mode == 1) { 574 if (mode == 1) {