dm-bufio: introduce a global queue
Mikulas Patocka
maintainerPATCH 3/5 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 patches.
Signed-off-by Mikulas Patocka <[email protected]>
--- drivers/md/dm-bufio.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/md/dm-bufio.c +12 -3
@@ -133,6 +133,7 @@ enum data_mode {struct dm_buffer {struct rb_node node;struct list_head lru_list; +struct list_head global_list;sector_t block;void *data;unsigned char data_mode;/* DATA_MODE_* */
@@ -193,7 +194,9 @@ static unsigned long dm_bufio_cache_size*/ static unsigned long dm_bufio_cache_size_latch; -static DEFINE_SPINLOCK (param_spinlock); +static DEFINE_SPINLOCK (global_spinlock); + +static LIST_HEAD (global_queue);/* * Buffers are freed after this timeout
@@ -302,7 +305,7 @@ static void adjust_total_allocated(strucif (unlink) diff = -diff; -spin_lock (¶m_spinlock); +spin_lock (&global_spinlock); *class_ptr[data_mode] += diff;
@@ -311,7 +314,13 @@ static void adjust_total_allocated(strucif (dm_bufio_current_allocated > dm_bufio_peak_allocated) dm_bufio_peak_allocated = dm_bufio_current_allocated; -spin_unlock (¶m_spinlock); +if (!unlink) { +list_add (&b->global_list, &global_queue); + }else { +list_del (&b->global_list); + } + +spin_unlock (&global_spinlock); }/*