From: Kevin Corry <corryk@us.ibm.com>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, evms-devel@lists.sourceforge.net
Subject: [PATCH] EVMS core (8/9) evms_biosplit.h
Date: Thu, 10 Oct 2002 14:39:28 -0500 [thread overview]
Message-ID: <0210101439280A.17770@boiler> (raw)
In-Reply-To: <02101014305502.17770@boiler>
Greetings,
Part 8 of the EVMS core driver.
This header file defines some of the common functions used by the
EVMS core to perform bio splitting. The remaining bio-splitting code
is in services.c. It would be our hope that this code might be taken
out of EVMS in the future and turned into a common kernel service.
The general idea behind this approach is for each plugin to determine
if a bio spans one of its internal boundaries (e.g. a request crosses
the boundary of an LVM PE or an MD chunk). If so, the plugin calls the
core biosplit code with the desired bio and boundary offset and gets
two bio's back. The first one can then be processed immediately. The
second one must then be checked again for further boundary conditions,
and possibly split again. After all necessary splits have taken place
and all portions driven to the devices, the core code handles the
callbacks and completes the original bio when all the split portions
are done.
Kevin Corry
corryk@us.ibm.com
http://evms.sourceforge.net/
diff -Naur linux-2.5.41/include/linux/evms_biosplit.h linux-2.5.41-evms/include/linux/evms_biosplit.h
--- linux-2.5.41/include/linux/evms_biosplit.h Wed Dec 31 18:00:00 1969
+++ linux-2.5.41-evms/include/linux/evms_biosplit.h Thu Oct 10 11:20:31 2002
@@ -0,0 +1,143 @@
+/*
+ *
+ *
+ * Copyright (c) International Business Machines Corp., 2000 - 2002
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ */
+/*
+ *
+ * BIO splitting header file
+ *
+ * This is temporarily placed here until a common generic solution
+ * is available.
+ *
+ */
+
+#include <linux/mempool.h>
+
+static mempool_t *my_bio_split_pool, *my_bio_pool;
+static kmem_cache_t *my_bio_split_slab, *my_bio_pool_slab;
+
+/**
+ * slab_pool_alloc
+ * @gfp_mask: GFP allocation flag
+ * @data: mempool prototype required fields
+ *
+ * mempool allocate function
+ **/
+static void *
+slab_pool_alloc(int gfp_mask, void *data)
+{
+ return kmem_cache_alloc(data, gfp_mask);
+}
+
+/**
+ * slab_pool_free
+ * @ptr: mempool prototype required fields
+ * @data: mempool prototype required fields
+ *
+ * mempool free function
+ **/
+static void
+slab_pool_free(void *ptr, void *data)
+{
+ kmem_cache_free(data, ptr);
+}
+
+/** bio_cache_ctor - initializes bio elements
+ * @foo: ptr to element
+ * @cachep: ptr to slab cache
+ * @flags: slab flags
+ *
+ * this function initializes the bi_io_vec field in the
+ * bio's allocates from our private bio pool.
+ **/
+#define EVMS_BIO_VEC_SIZE (sizeof(struct bio_vec) * (BIO_MAX_PAGES+1))
+static void bio_cache_ctor(void * foo, kmem_cache_t * cachep, unsigned long flags)
+{
+ if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+ SLAB_CTOR_CONSTRUCTOR) {
+ struct bio *bio = (struct bio *)foo;
+ memset(bio, 0, (sizeof(*bio) + EVMS_BIO_VEC_SIZE));
+ bio->bi_io_vec = (struct bio_vec *)((char *)bio + sizeof(*bio));
+ }
+}
+
+static int
+bio_split_setup(char * split_name, char * bio_name)
+{
+ /* initialize MY bio split record pool */
+ my_bio_split_slab = kmem_cache_create(split_name,
+ sizeof
+ (struct bio_split_cb),
+ 0, SLAB_HWCACHE_ALIGN,
+ NULL, NULL);
+ if (!my_bio_split_slab) {
+ LOG_ERROR("error(%d): unable to create %s cache.\n",
+ -ENOMEM, split_name);
+ return -ENOMEM;
+ }
+ my_bio_split_pool = mempool_create(256,
+ slab_pool_alloc,
+ slab_pool_free,
+ my_bio_split_slab);
+ if (!my_bio_split_pool) {
+ LOG_ERROR("error(%d): unable to create %s pool.",
+ -ENOMEM, split_name);
+ return -ENOMEM;
+ }
+
+ /* initialize MY bio pool */
+ my_bio_pool_slab = kmem_cache_create(bio_name,
+ (sizeof (struct bio) +
+ EVMS_BIO_VEC_SIZE),
+ 0, SLAB_HWCACHE_ALIGN,
+ bio_cache_ctor, NULL);
+ if (!my_bio_pool_slab) {
+ LOG_ERROR("error(%d): unable to create %s cache.\n",
+ -ENOMEM, split_name);
+ return -ENOMEM;
+ }
+ my_bio_pool = mempool_create(256,
+ slab_pool_alloc,
+ slab_pool_free,
+ my_bio_pool_slab);
+ if (!my_bio_pool) {
+ LOG_ERROR("error(%d): unable to create %s pool.",
+ -ENOMEM, split_name);
+ return -ENOMEM;
+ }
+ return 0;
+}
+
+static void
+bio_split_remove(void)
+{
+ if (my_bio_pool) {
+ mempool_destroy(my_bio_pool);
+ }
+ if (my_bio_pool_slab) {
+ kmem_cache_destroy(my_bio_pool_slab);
+ }
+ if (my_bio_split_pool) {
+ mempool_destroy(my_bio_split_pool);
+ }
+ if (my_bio_split_slab) {
+ kmem_cache_destroy(my_bio_split_slab);
+ }
+}
Ðë9\b
next prev parent reply other threads:[~2002-10-10 20:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-10 19:30 [PATCH] EVMS core (0/9) Kevin Corry
2002-10-10 19:35 ` [PATCH] EVMS core (1/9) evms.c Kevin Corry
2002-10-10 19:35 ` [PATCH] EVMS core (2/9) services.c Kevin Corry
2002-10-10 19:35 ` [PATCH] EVMS core (3/9) discover.c Kevin Corry
2002-10-10 19:37 ` [PATCH] EVMS core (4/9) passthru.c Kevin Corry
2002-10-10 19:37 ` [PATCH] EVMS core (5/9) evms_core.h Kevin Corry
2002-10-10 19:37 ` [PATCH] EVMS core (6/9) evms.h Kevin Corry
2002-10-10 19:39 ` [PATCH] EVMS core (7/9) evms_ioctl.h Kevin Corry
2002-10-10 19:39 ` Kevin Corry [this message]
2002-10-10 19:39 ` [PATCH] EVMS core (9/9) misc Kevin Corry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0210101439280A.17770@boiler \
--to=corryk@us.ibm.com \
--cc=evms-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox