提交 7e664b3d 编写于 作者: J Joe Thornber 提交者: Mike Snitzer

dm space map metadata: fix extending the space map

When extending a metadata space map we should do the first commit whilst
still in bootstrap mode -- a mode where all blocks get allocated in the
new area.

That way the commit overhead is allocated from the newly added space.
Otherwise we risk running out of space.

With this fix, and the previous commit "dm space map common: make sure
new space is used during extend", the following device mapper testsuite
test passes:
 dmtest run --suite thin-provisioning -n /resize_metadata_no_io/
Signed-off-by: NJoe Thornber <ejt@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
上级 12c91a5c
...@@ -608,20 +608,28 @@ static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks) ...@@ -608,20 +608,28 @@ static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
* Flick into a mode where all blocks get allocated in the new area. * Flick into a mode where all blocks get allocated in the new area.
*/ */
smm->begin = old_len; smm->begin = old_len;
memcpy(&smm->sm, &bootstrap_ops, sizeof(smm->sm)); memcpy(sm, &bootstrap_ops, sizeof(*sm));
/* /*
* Extend. * Extend.
*/ */
r = sm_ll_extend(&smm->ll, extra_blocks); r = sm_ll_extend(&smm->ll, extra_blocks);
if (r)
goto out;
for (i = old_len; !r && i < smm->begin; i++) {
r = sm_ll_inc(&smm->ll, i, &ev);
if (r)
goto out;
}
r = sm_metadata_commit(sm);
out:
/* /*
* Switch back to normal behaviour. * Switch back to normal behaviour.
*/ */
memcpy(&smm->sm, &ops, sizeof(smm->sm)); memcpy(sm, &ops, sizeof(*sm));
for (i = old_len; !r && i < smm->begin; i++)
r = sm_ll_inc(&smm->ll, i, &ev);
return r; return r;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册