Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / drivers / md / dm-memcache.h
blob87e4256daf5de421e7215e54b3205fdc3355fb3a
1 /*
2 * Copyright (C) 2006-2008 Red Hat, Inc. All rights reserved.
4 * Module Author: Heinz Mauelshagen <Mauelshagen@RedHat.com>
6 * Device-mapper memory object handling:
8 * o allocate/free total_pages in a per client page pool.
10 * o allocate/free memory objects with chunks (1..n) of
11 * pages_per_chunk pages hanging off.
13 * This file is released under the GPL.
16 #ifndef _DM_MEM_CACHE_H
17 #define _DM_MEM_CACHE_H
19 #define DM_MEM_CACHE_H_VERSION "0.1"
21 #include "dm.h"
22 #include <linux/dm-io.h>
24 static inline struct page_list *pl_elem(struct page_list *pl, unsigned p)
26 while (pl && p--)
27 pl = pl->next;
29 return pl;
32 struct dm_mem_cache_object {
33 struct page_list *pl; /* Dynamically allocated array */
34 void *private; /* Caller context reference */
37 struct dm_mem_cache_client;
40 * Create/destroy dm memory cache client resources.
42 * On creation, a number of @objects with @chunks of
43 * @pages_per_chunk pages will be allocated.
45 struct dm_mem_cache_client *
46 dm_mem_cache_client_create(unsigned objects, unsigned chunks,
47 unsigned pages_per_chunk);
48 void dm_mem_cache_client_destroy(struct dm_mem_cache_client *client);
51 * Grow/shrink a dm memory cache client resources
52 * by @objetcs amount of objects.
54 int dm_mem_cache_grow(struct dm_mem_cache_client *client, unsigned objects);
55 int dm_mem_cache_shrink(struct dm_mem_cache_client *client, unsigned objects);
58 * Allocate/free a memory object
60 * On allocation one object with an amount of chunks and
61 * an amount of pages per chunk will be returned on success.
63 struct dm_mem_cache_object *
64 dm_mem_cache_alloc(struct dm_mem_cache_client *client);
65 void dm_mem_cache_free(struct dm_mem_cache_client *client,
66 struct dm_mem_cache_object *object);
68 #endif