Btrfs: leave critical region in btrfs_find_all_roots as soon as possible
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / backref.c
index cf0df904347fb3ca5d1f3c0825bf18185db18f10..a383c18e74e86eebaa847d756e3493e7ca3c9bfd 100644 (file)
@@ -839,6 +839,7 @@ again:
                        }
                        ret = __add_delayed_refs(head, delayed_ref_seq,
                                                 &prefs_delayed);
+                       mutex_unlock(&head->mutex);
                        if (ret) {
                                spin_unlock(&delayed_refs->lock);
                                goto out;
@@ -932,8 +933,6 @@ again:
        }
 
 out:
-       if (head)
-               mutex_unlock(&head->mutex);
        btrfs_free_path(path);
        while (!list_empty(&prefs)) {
                ref = list_first_entry(&prefs, struct __prelim_ref, list);