Btrfs: make sure we wait on logged extents when fsycning two subvols
[linux-block.git] / fs / btrfs / tree-log.c
index 1475979e5718ab8727ad47f8c52898257c76b0ed..fc715ff31d260bf4fe29374d9ac5d2d9ba55cfe9 100644 (file)
@@ -672,7 +672,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
                         * is this extent already allocated in the extent
                         * allocation tree?  If so, just add a reference
                         */
-                       ret = btrfs_lookup_extent(root, ins.objectid,
+                       ret = btrfs_lookup_data_extent(root, ins.objectid,
                                                ins.offset);
                        if (ret == 0) {
                                ret = btrfs_inc_extent_ref(trans, root,
@@ -2600,9 +2600,9 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
        if (atomic_read(&log_root_tree->log_commit[index2])) {
                blk_finish_plug(&plug);
                btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
+               btrfs_wait_logged_extents(log, log_transid);
                wait_log_commit(trans, log_root_tree,
                                root_log_ctx.log_transid);
-               btrfs_free_logged_extents(log, log_transid);
                mutex_unlock(&log_root_tree->log_mutex);
                ret = root_log_ctx.log_ret;
                goto out;