Source
x
module_param_named(allocated_get_free_pages_bytes, dm_bufio_allocated_get_free_pages, ulong, S_IRUGO);
/*
* Copyright (C) 2009-2011 Red Hat, Inc.
*
* Author: Mikulas Patocka <mpatocka@redhat.com>
*
* This file is released under the GPL.
*/
/*
* Memory management policy:
* Limit the number of buffers to DM_BUFIO_MEMORY_PERCENT of main memory
* or DM_BUFIO_VMALLOC_PERCENT of vmalloc memory (whichever is lower).
* Always allocate at least DM_BUFIO_MIN_BUFFERS buffers.
* Start background writeback when there are DM_BUFIO_WRITEBACK_PERCENT
* dirty buffers.
*/
/*
* Check buffer ages in this interval (seconds)
*/
/*
* Free buffers when they are older than this (seconds)
*/
/*
* The nr of bytes of cached data to keep around.
*/
/*
* Align buffer writes to this boundary.
* Tests show that SSDs have the highest IOPS when using 4k writes.
*/
/*
* dm_buffer->list_mode
*/
/*
* Linking of buffers:
* All buffers are linked to cache_hash with their hash_list field.
*
* Clean buffers that are not being written (B_WRITING not set)
* are linked to lru[LIST_CLEAN] with their lru_list field.
*
* Dirty and clean buffers that are being written are linked to
* lru[LIST_DIRTY] with their lru_list field. When the write
* finishes, the buffer cannot be relinked immediately (because we
* are in an interrupt context and relinking requires process
* context), so some clean-not-writing buffers can be held on
* dirty_lru too. They are later added to lru in the process
* context.
*/
struct dm_bufio_client {
struct mutex lock;
struct list_head lru[LIST_SIZE];
unsigned long n_buffers[LIST_SIZE];
struct block_device *bdev;
unsigned block_size;
s8 sectors_per_block_bits;
void (*alloc_callback)(struct dm_buffer *);
void (*write_callback)(struct dm_buffer *);