summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2019-09-12 11:44:45 +0300
committerMike Snitzer <snitzer@redhat.com>2019-09-13 17:43:07 +0300
commitd0a328a385d2d1ab87e7a959d91c1841ed5a498f (patch)
treec8b573703f28e73a3603d5f9df6b2e39d138331f /drivers/md
parent26d2ef0cd0f7c12aa331b502c1c1460b85ebd04f (diff)
downloadlinux-d0a328a385d2d1ab87e7a959d91c1841ed5a498f.tar.xz
dm bufio: refactor adjust_total_allocated
Refactor adjust_total_allocated() so that it takes a bool argument indicating if it should add or subtract the buffer size. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-bufio.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index d3c86bf00075..58df20fd5465 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -285,14 +285,22 @@ static void __remove(struct dm_bufio_client *c, struct dm_buffer *b)
/*----------------------------------------------------------------*/
-static void adjust_total_allocated(unsigned char data_mode, long diff)
+static void adjust_total_allocated(struct dm_buffer *b, bool unlink)
{
+ unsigned char data_mode;
+ long diff;
+
static unsigned long * const class_ptr[DATA_MODE_LIMIT] = {
&dm_bufio_allocated_kmem_cache,
&dm_bufio_allocated_get_free_pages,
&dm_bufio_allocated_vmalloc,
};
+ data_mode = b->data_mode;
+ diff = (long)b->c->block_size;
+ if (unlink)
+ diff = -diff;
+
spin_lock(&param_spinlock);
*class_ptr[data_mode] += diff;
@@ -462,7 +470,7 @@ static void __link_buffer(struct dm_buffer *b, sector_t block, int dirty)
__insert(b->c, b);
b->last_accessed = jiffies;
- adjust_total_allocated(b->data_mode, (long)c->block_size);
+ adjust_total_allocated(b, false);
}
/*
@@ -478,7 +486,7 @@ static void __unlink_buffer(struct dm_buffer *b)
__remove(b->c, b);
list_del(&b->lru_list);
- adjust_total_allocated(b->data_mode, -(long)c->block_size);
+ adjust_total_allocated(b, true);
}
/*