Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230689
b: refs/heads/master
c: 9d357b0
h: refs/heads/master
i:
  230687: c5f6ec4
v: v3
  • Loading branch information
NeilBrown authored and Alasdair G Kergon committed Jan 13, 2011
1 parent e501829 commit c55fc10
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4e2d19e46b507018c6ed15f6c081d8f887ae229c
refs/heads/master: 9d357b0787bb3c91835d5e658c3bda178f9ca419
14 changes: 14 additions & 0 deletions trunk/drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ struct dm_table {
void *event_context;

struct dm_md_mempools *mempools;

struct list_head target_callbacks;
};

/*
Expand Down Expand Up @@ -204,6 +206,7 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
return -ENOMEM;

INIT_LIST_HEAD(&t->devices);
INIT_LIST_HEAD(&t->target_callbacks);
atomic_set(&t->holders, 0);
t->discards_supported = 1;

Expand Down Expand Up @@ -1225,10 +1228,17 @@ int dm_table_resume_targets(struct dm_table *t)
return 0;
}

void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callbacks *cb)
{
list_add(&cb->list, &t->target_callbacks);
}
EXPORT_SYMBOL_GPL(dm_table_add_target_callbacks);

int dm_table_any_congested(struct dm_table *t, int bdi_bits)
{
struct dm_dev_internal *dd;
struct list_head *devices = dm_table_get_devices(t);
struct dm_target_callbacks *cb;
int r = 0;

list_for_each_entry(dd, devices, list) {
Expand All @@ -1243,6 +1253,10 @@ int dm_table_any_congested(struct dm_table *t, int bdi_bits)
bdevname(dd->dm_dev.bdev, b));
}

list_for_each_entry(cb, &t->target_callbacks, list)
if (cb->congested_fn)
r |= cb->congested_fn(cb, bdi_bits);

return r;
}

Expand Down
11 changes: 11 additions & 0 deletions trunk/include/linux/device-mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ struct dm_target {
char *error;
};

/* Each target can link one of these into the table */
struct dm_target_callbacks {
struct list_head list;
int (*congested_fn) (struct dm_target_callbacks *, int);
};

int dm_register_target(struct target_type *t);
void dm_unregister_target(struct target_type *t);

Expand Down Expand Up @@ -268,6 +274,11 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
int dm_table_add_target(struct dm_table *t, const char *type,
sector_t start, sector_t len, char *params);

/*
* Target_ctr should call this if it needs to add any callbacks.
*/
void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callbacks *cb);

/*
* Finally call this to make the table ready for use.
*/
Expand Down

0 comments on commit c55fc10

Please sign in to comment.