btrfs: add cond_resched() calls when resolving backrefs
authorEdmund Nadolski <enadolski@suse.com>
Wed, 12 Jul 2017 22:20:09 +0000 (16:20 -0600)
committerDavid Sterba <dsterba@suse.com>
Wed, 16 Aug 2017 14:12:01 +0000 (16:12 +0200)
Since backref resolution is CPU-intensive, the cond_resched calls
should help alleviate soft lockup occurences.

Signed-off-by: Edmund Nadolski <enadolski@suse.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/backref.c

index 4cda81964dd4102f7ae0b5fdef8259dc5ffd1db1..9593102bdc2cf344e606332ed18486c3187a4ba1 100644 (file)
@@ -660,6 +660,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info,
                prelim_ref_insert(fs_info, &preftrees->direct, ref);
 
                ulist_reinit(parents);
+               cond_resched();
        }
 out:
        ulist_free(parents);
@@ -702,6 +703,7 @@ static int add_missing_keys(struct btrfs_fs_info *fs_info,
                btrfs_tree_read_unlock(eb);
                free_extent_buffer(eb);
                prelim_ref_insert(fs_info, &preftrees->indirect, ref);
+               cond_resched();
        }
        return 0;
 }
@@ -1243,6 +1245,7 @@ again:
                        }
                        eie = NULL;
                }
+               cond_resched();
        }
 
 out: