Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 375263
b: refs/heads/master
c: 7c3d3f2
h: refs/heads/master
i:
  375261: 7e53870
  375259: 1e43948
  375255: 7661d79
  375247: eec122f
  375231: b779463
v: v3
  • Loading branch information
Joe Thornber authored and Alasdair G Kergon committed May 10, 2013
1 parent 49019f3 commit cf201db
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 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: 24347e9595704464f62a4ed8f46abf62b4c79cdd
refs/heads/master: 7c3d3f2a87b01ff167a5f048285d5e3dee920235
3 changes: 2 additions & 1 deletion trunk/drivers/md/persistent-data/dm-space-map-disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ static struct dm_space_map ops = {
.new_block = sm_disk_new_block,
.commit = sm_disk_commit,
.root_size = sm_disk_root_size,
.copy_root = sm_disk_copy_root
.copy_root = sm_disk_copy_root,
.register_threshold_callback = NULL
};

struct dm_space_map *dm_sm_disk_create(struct dm_transaction_manager *tm,
Expand Down
6 changes: 4 additions & 2 deletions trunk/drivers/md/persistent-data/dm-space-map-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ static struct dm_space_map ops = {
.new_block = sm_metadata_new_block,
.commit = sm_metadata_commit,
.root_size = sm_metadata_root_size,
.copy_root = sm_metadata_copy_root
.copy_root = sm_metadata_copy_root,
.register_threshold_callback = NULL
};

/*----------------------------------------------------------------*/
Expand Down Expand Up @@ -513,7 +514,8 @@ static struct dm_space_map bootstrap_ops = {
.new_block = sm_bootstrap_new_block,
.commit = sm_bootstrap_commit,
.root_size = sm_bootstrap_root_size,
.copy_root = sm_bootstrap_copy_root
.copy_root = sm_bootstrap_copy_root,
.register_threshold_callback = NULL
};

/*----------------------------------------------------------------*/
Expand Down
23 changes: 23 additions & 0 deletions trunk/drivers/md/persistent-data/dm-space-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "dm-block-manager.h"

typedef void (*dm_sm_threshold_fn)(void *context);

/*
* struct dm_space_map keeps a record of how many times each block in a device
* is referenced. It needs to be fixed on disk as part of the transaction.
Expand Down Expand Up @@ -59,6 +61,15 @@ struct dm_space_map {
*/
int (*root_size)(struct dm_space_map *sm, size_t *result);
int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);

/*
* You can register one threshold callback which is edge-triggered
* when the free space in the space map drops below the threshold.
*/
int (*register_threshold_callback)(struct dm_space_map *sm,
dm_block_t threshold,
dm_sm_threshold_fn fn,
void *context);
};

/*----------------------------------------------------------------*/
Expand Down Expand Up @@ -131,4 +142,16 @@ static inline int dm_sm_copy_root(struct dm_space_map *sm, void *copy_to_here_le
return sm->copy_root(sm, copy_to_here_le, len);
}

static inline int dm_sm_register_threshold_callback(struct dm_space_map *sm,
dm_block_t threshold,
dm_sm_threshold_fn fn,
void *context)
{
if (sm->register_threshold_callback)
return sm->register_threshold_callback(sm, threshold, fn, context);

return -EINVAL;
}


#endif /* _LINUX_DM_SPACE_MAP_H */

0 comments on commit cf201db

Please sign in to comment.