Skip to content

Commit

Permalink
dm thin metadata: add dm_thin_changed_this_transaction
Browse files Browse the repository at this point in the history
Introduce dm_thin_changed_this_transaction to dm-thin-metadata to publish a
useful bit of information we're already tracking.  This will help dm thin
decide when to commit.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Joe Thornber authored and Alasdair G Kergon committed Jul 27, 2012
1 parent 66b1edc commit 40db5a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/md/dm-thin-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,9 @@ static int __insert(struct dm_thin_device *td, dm_block_t block,
if (r)
return r;

if (inserted) {
td->changed = 1;
if (inserted)
td->mapped_blocks++;
td->changed = 1;
}

return 0;
}
Expand Down Expand Up @@ -1422,6 +1421,17 @@ int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block)
return r;
}

bool dm_thin_changed_this_transaction(struct dm_thin_device *td)
{
int r;

down_read(&td->pmd->root_lock);
r = td->changed;
up_read(&td->pmd->root_lock);

return r;
}

int dm_pool_alloc_data_block(struct dm_pool_metadata *pmd, dm_block_t *result)
{
int r;
Expand Down
2 changes: 2 additions & 0 deletions drivers/md/dm-thin-metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block);
/*
* Queries.
*/
bool dm_thin_changed_this_transaction(struct dm_thin_device *td);

int dm_thin_get_highest_mapped_block(struct dm_thin_device *td,
dm_block_t *highest_mapped);

Expand Down

0 comments on commit 40db5a5

Please sign in to comment.