Skip to content

Commit

Permalink
dm cache background tracker: limit amount of background work that may…
Browse files Browse the repository at this point in the history
… be issued at once

On large systems the cache policy can be over enthusiastic and queue far
too much dirty data to be written back.  This consumes memory.

Signed-off-by: Joe Thornber <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
jthornber authored and snitm committed Nov 10, 2017
1 parent deb7191 commit 64748b1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions drivers/md/dm-cache-background-tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,17 @@ EXPORT_SYMBOL_GPL(btracker_nr_demotions_queued);

static bool max_work_reached(struct background_tracker *b)
{
// FIXME: finish
return false;
return atomic_read(&b->pending_promotes) +
atomic_read(&b->pending_writebacks) +
atomic_read(&b->pending_demotes) >= b->max_work;
}

struct bt_work *alloc_work(struct background_tracker *b)
{
if (max_work_reached(b))
return NULL;

return kmem_cache_alloc(b->work_cache, GFP_NOWAIT);
}

int btracker_queue(struct background_tracker *b,
Expand All @@ -174,10 +183,7 @@ int btracker_queue(struct background_tracker *b,
if (pwork)
*pwork = NULL;

if (max_work_reached(b))
return -ENOMEM;

w = kmem_cache_alloc(b->work_cache, GFP_NOWAIT);
w = alloc_work(b);
if (!w)
return -ENOMEM;

Expand Down

0 comments on commit 64748b1

Please sign in to comment.