Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 1712

kernel-2.6.18-238.el5.src.rpm

From: heinzm@redhat.com <heinzm@redhat.com>
Date: Wed, 27 Aug 2008 14:16:37 +0200
Subject: [md] add device-mapper object memory cache interface
Message-id: 20080827121637.131055201@redhat.com
O-Subject: [PATCH RHEL5.3 437180 01/11] dm-mem-cache.h.patch
Bugzilla: 437180

This patch introduces a device-mapper object memory cache interface,
which is being used by dm-raid45.c to create objects (ie. list of pages)
for the RAID stripe cache.

It allows to create, destroy, grow, shrink a memory cache
and allocate, delete memory objects.

Heinz

Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>

diff --git a/drivers/md/dm-mem-cache.h b/drivers/md/dm-mem-cache.h
new file mode 100644
index 0000000..655e388
--- /dev/null
+++ b/drivers/md/dm-mem-cache.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2006-2008 Red Hat, Inc. All rights reserved.
+ *
+ * Module Author: Heinz Mauelshagen <Mauelshagen@RedHat.com>
+ *
+ * Allocate/free total_pages to a per client page pool.
+ * Allocate/free memory objects with chunks (1..n) of pages_per_chunk pages
+ * hanging off.
+ *
+ * This file is released under the GPL.
+ */
+
+#ifndef _DM_MEM_CACHE_H
+#define _DM_MEM_CACHE_H
+
+#define	DM_MEM_CACHE_H_VERSION	"0.1"
+
+#include "dm.h"
+#include <linux/dm-io.h>
+
+static inline struct page_list *pl_elem(struct page_list *pl, unsigned int p)
+{
+	while (pl && p--)
+		pl = pl->next;
+
+	return pl;
+}
+
+struct dm_mem_cache_object {
+	struct page_list *pl; /* Dynamically allocated array */
+	void *private;	      /* Caller context reference */
+};
+
+struct dm_mem_cache_client;
+
+/*
+ * Create/destroy dm memory cache client resources.
+ */
+struct dm_mem_cache_client *dm_mem_cache_client_create(
+	unsigned int total_pages, unsigned int objects, unsigned int chunks);
+void dm_mem_cache_client_destroy(struct dm_mem_cache_client *client);
+
+/*
+ * Grow/shrink a dm memory cache client resources.
+ */
+int dm_mem_cache_grow(struct dm_mem_cache_client *client, unsigned int pages);
+int dm_mem_cache_shrink(struct dm_mem_cache_client *client, unsigned int pages);
+
+/*
+ * Allocate/free a memory object
+ */
+struct dm_mem_cache_object *
+dm_mem_cache_alloc(struct dm_mem_cache_client *client,
+		   unsigned int pages_per_chunk);
+void dm_mem_cache_free(struct dm_mem_cache_client *client,
+		       struct dm_mem_cache_object *object);
+
+#endif