Skip to content

Commit

Permalink
dm cache: pass a new 'critical' flag to the policies when requesting …
Browse files Browse the repository at this point in the history
…writeback work

We only allow non critical writeback if the origin is idle.  It is up
to the policy to decide what writeback work is critical.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Joe Thornber authored and Mike Snitzer committed May 29, 2015
1 parent 066dbaa commit 20f6814
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion drivers/md/dm-cache-policy-cleaner.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ static struct wb_cache_entry *get_next_dirty_entry(struct policy *p)

static int wb_writeback_work(struct dm_cache_policy *pe,
dm_oblock_t *oblock,
dm_cblock_t *cblock)
dm_cblock_t *cblock,
bool critical_only)
{
int r = -ENOENT;
struct policy *p = to_policy(pe);
Expand Down
5 changes: 3 additions & 2 deletions drivers/md/dm-cache-policy-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ static inline int policy_walk_mappings(struct dm_cache_policy *p,

static inline int policy_writeback_work(struct dm_cache_policy *p,
dm_oblock_t *oblock,
dm_cblock_t *cblock)
dm_cblock_t *cblock,
bool critical_only)
{
return p->writeback_work ? p->writeback_work(p, oblock, cblock) : -ENOENT;
return p->writeback_work ? p->writeback_work(p, oblock, cblock, critical_only) : -ENOENT;
}

static inline void policy_remove_mapping(struct dm_cache_policy *p, dm_oblock_t oblock)
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-cache-policy-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ static int __mq_writeback_work(struct mq_policy *mq, dm_oblock_t *oblock,
}

static int mq_writeback_work(struct dm_cache_policy *p, dm_oblock_t *oblock,
dm_cblock_t *cblock)
dm_cblock_t *cblock, bool critical_only)
{
int r;
struct mq_policy *mq = to_mq_policy(p);
Expand Down
7 changes: 5 additions & 2 deletions drivers/md/dm-cache-policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,18 @@ struct dm_cache_policy {
int (*remove_cblock)(struct dm_cache_policy *p, dm_cblock_t cblock);

/*
* Provide a dirty block to be written back by the core target.
* Provide a dirty block to be written back by the core target. If
* critical_only is set then the policy should only provide work if
* it urgently needs it.
*
* Returns:
*
* 0 and @cblock,@oblock: block to write back provided
*
* -ENODATA: no dirty blocks available
*/
int (*writeback_work)(struct dm_cache_policy *p, dm_oblock_t *oblock, dm_cblock_t *cblock);
int (*writeback_work)(struct dm_cache_policy *p, dm_oblock_t *oblock, dm_cblock_t *cblock,
bool critical_only);

/*
* How full is the cache?
Expand Down
3 changes: 2 additions & 1 deletion drivers/md/dm-cache-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -1787,14 +1787,15 @@ static void writeback_some_dirty_blocks(struct cache *cache)
dm_cblock_t cblock;
struct prealloc structs;
struct dm_bio_prison_cell *old_ocell;
bool busy = !iot_idle_for(&cache->origin_tracker, HZ);

memset(&structs, 0, sizeof(structs));

while (spare_migration_bandwidth(cache)) {
if (prealloc_data_structs(cache, &structs))
break;

r = policy_writeback_work(cache->policy, &oblock, &cblock);
r = policy_writeback_work(cache->policy, &oblock, &cblock, busy);
if (r)
break;

Expand Down

0 comments on commit 20f6814

Please sign in to comment.