Unverified Commit cc3dc797 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11713 btrfs: fix qgroup reserve leaks in cow_file_range

parents 5867be9c 3ece98fb
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1543,6 +1543,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
					     locked_page,
					     clear_bits,
					     page_ops);
		btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL);
		start += cur_alloc_size;
	}

@@ -1556,6 +1557,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
		clear_bits |= EXTENT_CLEAR_DATA_RESV;
		extent_clear_unlock_delalloc(inode, start, end, locked_page,
					     clear_bits, page_ops);
		btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL);
	}
	return ret;
}
@@ -2219,13 +2221,15 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
	 */
	if (cow_start != (u64)-1)
		cur_offset = cow_start;
	if (cur_offset < end)
	if (cur_offset < end) {
		extent_clear_unlock_delalloc(inode, cur_offset, end,
					     locked_page, EXTENT_LOCKED |
					     EXTENT_DELALLOC | EXTENT_DEFRAG |
					     EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
					     PAGE_START_WRITEBACK |
					     PAGE_END_WRITEBACK);
		btrfs_qgroup_free_data(inode, NULL, cur_offset, end - cur_offset + 1, NULL);
	}
	btrfs_free_path(path);
	return ret;
}