提交 cbffe14c 编写于 作者: L Luo Meng 提交者: Zheng Zengkai

Revert "dm space maps: don't reset space map allocation cursor when committing"

hulk inclusion
category: bugfix
bugzilla: 185894, https://gitee.com/openeuler/kernel/issues/I4SJ8H?from=project-issue
CVE: NA

-----------------------------------------------

This reverts commit b0d9aeb4.

This commit b0d9aeb4 ("dm space maps: don't reset space map allocation
cursor when committing") change the way to find free block.

But when use ramdisk(not support discard) for thin-pool,and storage
over-commitment. Then constantly create and delete file, can find block
in thin-pool, but can't find block in ramdisk.

So need revert this patch.
Signed-off-by: NLuo Meng <luomeng12@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 b88ceab5
...@@ -171,14 +171,6 @@ static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b) ...@@ -171,14 +171,6 @@ static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b)
* Any block we allocate has to be free in both the old and current ll. * Any block we allocate has to be free in both the old and current ll.
*/ */
r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, smd->begin, smd->ll.nr_blocks, b); r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, smd->begin, smd->ll.nr_blocks, b);
if (r == -ENOSPC) {
/*
* There's no free block between smd->begin and the end of the metadata device.
* We search before smd->begin in case something has been freed.
*/
r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, 0, smd->begin, b);
}
if (r) if (r)
return r; return r;
...@@ -207,6 +199,7 @@ static int sm_disk_commit(struct dm_space_map *sm) ...@@ -207,6 +199,7 @@ static int sm_disk_commit(struct dm_space_map *sm)
return r; return r;
memcpy(&smd->old_ll, &smd->ll, sizeof(smd->old_ll)); memcpy(&smd->old_ll, &smd->ll, sizeof(smd->old_ll));
smd->begin = 0;
smd->nr_allocated_this_transaction = 0; smd->nr_allocated_this_transaction = 0;
r = sm_disk_get_nr_free(sm, &nr_free); r = sm_disk_get_nr_free(sm, &nr_free);
......
...@@ -452,14 +452,6 @@ static int sm_metadata_new_block_(struct dm_space_map *sm, dm_block_t *b) ...@@ -452,14 +452,6 @@ static int sm_metadata_new_block_(struct dm_space_map *sm, dm_block_t *b)
* Any block we allocate has to be free in both the old and current ll. * Any block we allocate has to be free in both the old and current ll.
*/ */
r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b); r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b);
if (r == -ENOSPC) {
/*
* There's no free block between smm->begin and the end of the metadata device.
* We search before smm->begin in case something has been freed.
*/
r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, 0, smm->begin, b);
}
if (r) if (r)
return r; return r;
...@@ -511,6 +503,7 @@ static int sm_metadata_commit(struct dm_space_map *sm) ...@@ -511,6 +503,7 @@ static int sm_metadata_commit(struct dm_space_map *sm)
return r; return r;
memcpy(&smm->old_ll, &smm->ll, sizeof(smm->old_ll)); memcpy(&smm->old_ll, &smm->ll, sizeof(smm->old_ll));
smm->begin = 0;
smm->allocated_this_transaction = 0; smm->allocated_this_transaction = 0;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册