summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2019-09-12 04:44:46 -0400
committerMike Snitzer <snitzer@redhat.com>2019-09-13 10:43:27 -0400
commitaf53badc0cd8a511b016a10c0cccf916692f1fc2 (patch)
tree219d84d62f10d6d36221e99b5c6a99b2e42a1e09 /drivers/md
parentd0a328a385d2d1ab87e7a959d91c1841ed5a498f (diff)
dm bufio: introduce a global queue
Rename param_spinlock to global_spinlock and introduce a global queue of all used buffers. The queue will be used in the following commits. 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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 58df20fd5465..2451a4d68aed 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -132,6 +132,7 @@ enum data_mode {
132struct dm_buffer { 132struct dm_buffer {
133 struct rb_node node; 133 struct rb_node node;
134 struct list_head lru_list; 134 struct list_head lru_list;
135 struct list_head global_list;
135 sector_t block; 136 sector_t block;
136 void *data; 137 void *data;
137 unsigned char data_mode; /* DATA_MODE_* */ 138 unsigned char data_mode; /* DATA_MODE_* */
@@ -192,7 +193,9 @@ static unsigned long dm_bufio_cache_size;
192 */ 193 */
193static unsigned long dm_bufio_cache_size_latch; 194static unsigned long dm_bufio_cache_size_latch;
194 195
195static DEFINE_SPINLOCK(param_spinlock); 196static DEFINE_SPINLOCK(global_spinlock);
197
198static LIST_HEAD(global_queue);
196 199
197/* 200/*
198 * Buffers are freed after this timeout 201 * Buffers are freed after this timeout
@@ -301,7 +304,7 @@ static void adjust_total_allocated(struct dm_buffer *b, bool unlink)
301 if (unlink) 304 if (unlink)
302 diff = -diff; 305 diff = -diff;
303 306
304 spin_lock(&param_spinlock); 307 spin_lock(&global_spinlock);
305 308
306 *class_ptr[data_mode] += diff; 309 *class_ptr[data_mode] += diff;
307 310
@@ -310,7 +313,13 @@ static void adjust_total_allocated(struct dm_buffer *b, bool unlink)
310 if (dm_bufio_current_allocated > dm_bufio_peak_allocated) 313 if (dm_bufio_current_allocated > dm_bufio_peak_allocated)
311 dm_bufio_peak_allocated = dm_bufio_current_allocated; 314 dm_bufio_peak_allocated = dm_bufio_current_allocated;
312 315
313 spin_unlock(&param_spinlock); 316 if (!unlink) {
317 list_add(&b->global_list, &global_queue);
318 } else {
319 list_del(&b->global_list);
320 }
321
322 spin_unlock(&global_spinlock);
314} 323}
315 324
316/* 325/*