Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 375261
b: refs/heads/master
c: 1921c56
h: refs/heads/master
i:
  375259: 1e43948
v: v3
  • Loading branch information
Joe Thornber authored and Alasdair G Kergon committed May 10, 2013
1 parent 73a1389 commit 7e53870
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5d0db96d13a4e2cd22b52494fb19ce5a9c8b8d90
refs/heads/master: 1921c56d95c4ac92b359ad44ffbc1e9a36060b29
38 changes: 32 additions & 6 deletions trunk/drivers/md/persistent-data/dm-space-map-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ static void sm_metadata_destroy(struct dm_space_map *sm)
kfree(smm);
}

static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
{
DMERR("doesn't support extend");
return -EINVAL;
}

static int sm_metadata_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count)
{
struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
Expand Down Expand Up @@ -382,6 +376,8 @@ static int sm_metadata_copy_root(struct dm_space_map *sm, void *where_le, size_t
return 0;
}

static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks);

static struct dm_space_map ops = {
.destroy = sm_metadata_destroy,
.extend = sm_metadata_extend,
Expand Down Expand Up @@ -522,6 +518,36 @@ static struct dm_space_map bootstrap_ops = {

/*----------------------------------------------------------------*/

static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
{
int r, i;
enum allocation_event ev;
struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
dm_block_t old_len = smm->ll.nr_blocks;

/*
* Flick into a mode where all blocks get allocated in the new area.
*/
smm->begin = old_len;
memcpy(&smm->sm, &bootstrap_ops, sizeof(smm->sm));

/*
* Extend.
*/
r = sm_ll_extend(&smm->ll, extra_blocks);

/*
* Switch back to normal behaviour.
*/
memcpy(&smm->sm, &ops, sizeof(smm->sm));
for (i = old_len; !r && i < smm->begin; i++)
r = sm_ll_inc(&smm->ll, i, &ev);

return r;
}

/*----------------------------------------------------------------*/

struct dm_space_map *dm_sm_metadata_init(void)
{
struct sm_metadata *smm;
Expand Down

0 comments on commit 7e53870

Please sign in to comment.