From: =?GB2312?B?1cXT7g==?= Subject: Re: [PATCH v6 1/4] dm-replicator: documentation and module registry Date: Thu, 7 Jan 2010 18:18:10 +0800 Message-ID: References: <1261151073-25962-1-git-send-email-heinzm@redhat.com> <1261151073-25962-2-git-send-email-heinzm@redhat.com> Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0765147422350775691==" Return-path: In-Reply-To: <1261151073-25962-2-git-send-email-heinzm@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: device-mapper development List-Id: dm-devel.ids --===============0765147422350775691== Content-Type: multipart/alternative; boundary=00504502b46855211d047c9063b6 --00504502b46855211d047c9063b6 Content-Type: text/plain; charset=ISO-8859-1 Is there any command-line example to explain how to use this patch? I have compiled it and loaded the modules, the '' target parameters in both replicator ant replicator-dev targets means what? how can I construct these target? I haven't read the source code in detail till now, sorry. 2009/12/18 > From: Heinz Mauelshagen > > The dm-registry module is a general purpose registry for modules. > > The remote replicator utilizes it to register its ringbuffer log and > site link handlers in order to avoid duplicating registry code and logic. > > > Signed-off-by: Heinz Mauelshagen > Reviewed-by: Jon Brassow > Tested-by: Jon Brassow > --- > Documentation/device-mapper/replicator.txt | 203 > +++++++++++++++++++++++++ > drivers/md/Kconfig | 8 + > drivers/md/Makefile | 1 + > drivers/md/dm-registry.c | 224 > ++++++++++++++++++++++++++++ > drivers/md/dm-registry.h | 38 +++++ > 5 files changed, 474 insertions(+), 0 deletions(-) > create mode 100644 Documentation/device-mapper/replicator.txt > create mode 100644 drivers/md/dm-registry.c > create mode 100644 drivers/md/dm-registry.h > > diff --git 2.6.33-rc1.orig/Documentation/device-mapper/replicator.txt > 2.6.33-rc1/Documentation/device-mapper/replicator.txt > new file mode 100644 > index 0000000..1d408a6 > --- /dev/null > +++ 2.6.33-rc1/Documentation/device-mapper/replicator.txt > @@ -0,0 +1,203 @@ > +dm-replicator > +============= > + > +Device-mapper replicator is designed to enable redundant copies of > +storage devices to be made - preferentially, to remote locations. > +RAID1 (aka mirroring) is often used to maintain redundant copies of > +storage for fault tolerance purposes. Unlike RAID1, which often > +assumes similar device characteristics, dm-replicator is designed to > +handle devices with different latency and bandwidth characteristics > +which are often the result of the geograhic disparity of multi-site > +architectures. Simply put, you might choose RAID1 to protect from > +a single device failure, but you would choose remote replication > +via dm-replicator for protection against a site failure. > + > +dm-replicator works by first sending write requests to the "replicator > +log". Not to be confused with the device-mapper dirty log, this > +replicator log behaves similarly to that of a journal. Write requests > +go to this log first and then are copied to all the replicate devices > +at their various locations. Requests are cleared from the log once all > +replicate devices confirm the data is received/copied. This architecture > +allows dm-replicator to be flexible in terms of device characteristics. > +If one device should fall behind the others - perhaps due to high latency > - > +the slack is picked up by the log. The user has a great deal of > +flexibility in specifying to what degree a particular site is allowed to > +fall behind - if at all. > + > +Device-Mapper's dm-replicator has two targets, "replicator" and > +"replicator-dev". The "replicator" target is used to setup the > +aforementioned log and allow the specification of site link properties. > +Through the "replicator" target, the user might specify that writes > +that are copied to the local site must happen synchronously (i.e the > +writes are complete only after they have passed through the log device > +and have landed on the local site's disk). They may also specify that > +a remote link should asynchronously complete writes, but that the remote > +link should never fall more than 100MB behind in terms of processing. > +Again, the "replicator" target is used to define the replicator log and > +the characteristics of each site link. > + > +The "replicator-dev" target is used to define the devices used and > +associate them with a particular replicator log. You might think of > +this stage in a similar way to setting up RAID1 (mirroring). You > +define a set of devices which will be copies of each other, but > +access the device through the mirror virtual device which takes care > +of the copying. The user accessible replicator device is analogous > +to the mirror virtual device, while the set of devices being copied > +to are analogous to the mirror images (sometimes called 'legs'). > +When creating a replicator device via the "replicator-dev" target, > +it must be associated with the replicator log (created with the > +aforementioned "replicator" target). When each redundant device > +is specified as part of the replicator device, it is associated with > +a site link whose properties were defined when the "replicator" > +target was created. > + > +The user can go farther than simply replicating one device. They > +can continue to add replicator devices - associating them with a > +particular replicator log. Writes that go through the replicator > +log are guarenteed to have their write ordering preserved. So, if > +you associate more than one replicator device to a particular > +replicator log, you are preserving write ordering across multiple > +devices. This might be useful if you had a database that spanned > +multiple disks and write ordering must be preserved or any transaction > +accounting scheme would be foiled. (You can imagine this like > +preserving write ordering across a number of mirrored devices, where > +each mirror has images/legs in different geographic locations.) > + > +dm-replicator has a modular architecture. Future implementations for > +the replicator log and site link modules are allowed. The current > +replication log is ringbuffer - utilized to store all writes being > +subject to replication and enforce write ordering. The current site > +link code is based on accessing block devices (iSCSI, FC, etc) and > +does device recovery including (initial) resynchronization. > + > + > +Picture of a 2 site configuration with 3 local devices (LDs) in a > +primary site being resycnhronied to 3 remotes sites with 3 remote > +devices (RDs) each via site links (SLINK) 1-2 with site link 0 > +as a special case to handle the local devices: > + > + | > + Local (primary) site | Remote sites > + -------------------- | ------------ > + | > + D1 D2 Dn | > + | | | | > + +---+- ... -+ | > + | | > + REPLOG-----------------+- SLINK1 ------------+ > + | | | | > + SLINK0 (special case) | | | > + | | | | > + +-----+ ... + | | +----+- ... -+ > + | | | | | | | | > + LD1 LD2 LDn | | RD1 RD2 RDn > + | | > + +-- SLINK2------------+ > + | | | > + | | +----+- ... -+ > + | | | | | > + | | RD1 RD2 RDn > + | | > + | | > + | | > + +- SLINKm ------------+ > + | | > + | +----+- ... -+ > + | | | | > + | RD1 RD2 RDn > + > + > + > + > +The following are descriptions of the device-mapper tables used to > +construct the "replicator" and "replicator-dev" targets. > + > +"replicator" target parameters: > +------------------------------- > + replicator \ > + <#replog_params> \ > + [ <#slink_params_0> ]{1..N} > + > + = "ringbuffer" is currently the only available type > +<#replog_params> = # of args following this one intended for the replog (2 > or 4) > + = [auto/create/open ] > + = device path of replication log (REPLOG) backing store > + = offset to REPLOG header > + create = The replication log will be initialized if not active > + and sized to "size". (If already active, the create > + will fail.) Size is always in sectors. > + open = The replication log must be initialized and valid or > + the constructor will fail. > + auto = If a valid replication log header is found on the > + replication device, this will behave like 'open'. > + Otherwise, this option behaves like 'create'. > + > + = "blockdev" is currently the only available type > +<#slink_params> = 1/2/4 > + = [ [ ]] > + = This is a unique number that is used to identify a > + particular site/location. '0' is always used to > + identify the local site, while increasing integers > + are used to identify remote sites. > + = The policy can be either 'sync' or 'async'. > + 'sync' means write requests will not return until > + the data is on the storage device. 'async' allows > + a device to "fall behind"; that is, outstanding > + write requests are waiting in the replication log > + to be processed for this site, but it is not > delaying > + the writes of other sites. > + = This field is used to specify how far the user is > + willing to allow write requests to this specific > site > + to "fall behind" in processing before switching to > + a 'sync' policy. This "fall behind" threshhold > can > + be specified in three ways: ios, size, or timeout. > + 'ios' is the number of pending I/Os allowed (e.g. > + "ios 10000"). 'size' is the amount of pending > data > + allowed (e.g. "size 200m"). Size labels include: > + s (sectors), k, m, g, t, p, and e. 'timeout' is > + the amount of time allowed for writes to be > + outstanding. Time labels include: s, m, h, and d. > + > + > +"replicator-dev" target parameters: > +----------------------------------- > +start> replicator-dev > + \ > + [ <#dev_params> > + <#dlog_params> ]{1..N} > + > + = device previously constructed via "replication" > target > + = An integer that is used to 'tag' write requests as > + belonging to a particular set of devices - > specifically, > + the devices that follow this argument (i.e. the site > + link devices). > + = This number identifies the site/location where the > next > + device to be specified comes from. It is exactly the > + same number used to identify the site/location (and > its > + policies) in the "replicator" target. Interestingly, > + while one might normally expect a "dev_type" argument > + here, it can be deduced from the site link number and > + the 'slink_type' given in the "replication" target. > +<#dev_params> = '1' (The number of allowed parameters actually > depends > + on the 'slink_type' given in the "replication" > target. > + Since our only option there is "blockdev", the only > + allowable number here is currently '1'.) > + = 'dev_path' (Again, since "blockdev" is the only > + 'slink_type' available, the only allowable argument > here > + is the path to the device.) > + = Not to be confused with the "replicator log", this is > + the type of dirty log associated with this particular > + device. Dirty logs are used for synchronization, > during > + initialization or fall behind conditions, to bring > devices > + into a coherent state with its peers - analogous to > + rebuilding a RAID1 (mirror) device. Available dirty > + log types include: 'nolog', 'core', and 'disk' > +<#dlog_params> = The number of arguments required for a particular log > + type - 'nolog' = 0, 'core' = 1/2, 'disk' = 2/3. > + = 'nolog' => ~no arguments~ > + 'core' => [sync | nosync] > + 'disk' => [sync | > nosync] > + = This sets the granularity at which the dirty log > + tracks what areas of the device is in-sync. > + [sync | nosync] = Optionally specify whether the sync should be > forced > + or avoided initially. > diff --git 2.6.33-rc1.orig/drivers/md/Kconfig 2.6.33-rc1/drivers/md/Kconfig > index acb3a4e..62c9766 100644 > --- 2.6.33-rc1.orig/drivers/md/Kconfig > +++ 2.6.33-rc1/drivers/md/Kconfig > @@ -313,6 +313,14 @@ config DM_DELAY > > If unsure, say N. > > +config DM_REPLICATOR > + tristate "Replication target (EXPERIMENTAL)" > + depends on BLK_DEV_DM && EXPERIMENTAL > + ---help--- > + A target that supports replication of local devices to remote > sites. > + > + If unsure, say N. > + > config DM_UEVENT > bool "DM uevents (EXPERIMENTAL)" > depends on BLK_DEV_DM && EXPERIMENTAL > diff --git 2.6.33-rc1.orig/drivers/md/Makefile > 2.6.33-rc1/drivers/md/Makefile > index e355e7f..be05b39 100644 > --- 2.6.33-rc1.orig/drivers/md/Makefile > +++ 2.6.33-rc1/drivers/md/Makefile > @@ -44,6 +44,7 @@ obj-$(CONFIG_DM_SNAPSHOT) += dm-snapshot.o > obj-$(CONFIG_DM_MIRROR) += dm-mirror.o dm-log.o > dm-region-hash.o > obj-$(CONFIG_DM_LOG_USERSPACE) += dm-log-userspace.o > obj-$(CONFIG_DM_ZERO) += dm-zero.o > +obj-$(CONFIG_DM_REPLICATOR) += dm-log.o dm-registry.o > > quiet_cmd_unroll = UNROLL $@ > cmd_unroll = $(AWK) -f$(srctree)/$(src)/unroll.awk -vN=$(UNROLL) \ > diff --git 2.6.33-rc1.orig/drivers/md/dm-registry.c > 2.6.33-rc1/drivers/md/dm-registry.c > new file mode 100644 > index 0000000..fb8abbf > --- /dev/null > +++ 2.6.33-rc1/drivers/md/dm-registry.c > @@ -0,0 +1,224 @@ > +/* > + * Copyright (C) 2009 Red Hat, Inc. All rights reserved. > + * > + * Module Author: Heinz Mauelshagen (heinzm@redhat.com) > + * > + * Generic registry for arbitrary structures > + * (needs dm_registry_type structure upfront each registered structure). > + * > + * This file is released under the GPL. > + * > + * FIXME: use as registry for e.g. dirty log types as well. > + */ > + > +#include > +#include > +#include > + > +#include "dm-registry.h" > + > +#define DM_MSG_PREFIX "dm-registry" > + > +static const char *version = "0.001"; > + > +/* Sizable class registry. */ > +static unsigned num_classes; > +static struct list_head *_classes; > +static rwlock_t *_locks; > + > +void * > +dm_get_type(const char *type_name, enum dm_registry_class class) > +{ > + struct dm_registry_type *t; > + > + read_lock(_locks + class); > + list_for_each_entry(t, _classes + class, list) { > + if (!strcmp(type_name, t->name)) { > + if (!t->use_count && !try_module_get(t->module)) { > + read_unlock(_locks + class); > + return ERR_PTR(-ENOMEM); > + } > + > + t->use_count++; > + read_unlock(_locks + class); > + return t; > + } > + } > + > + read_unlock(_locks + class); > + return ERR_PTR(-ENOENT); > +} > +EXPORT_SYMBOL(dm_get_type); > + > +void > +dm_put_type(void *type, enum dm_registry_class class) > +{ > + struct dm_registry_type *t = type; > + > + read_lock(_locks + class); > + if (!--t->use_count) > + module_put(t->module); > + > + read_unlock(_locks + class); > +} > +EXPORT_SYMBOL(dm_put_type); > + > +/* Add a type to the registry. */ > +int > +dm_register_type(void *type, enum dm_registry_class class) > +{ > + struct dm_registry_type *t = type, *tt; > + > + if (unlikely(class >= num_classes)) > + return -EINVAL; > + > + tt = dm_get_type(t->name, class); > + if (unlikely(!IS_ERR(tt))) { > + dm_put_type(t, class); > + return -EEXIST; > + } > + > + write_lock(_locks + class); > + t->use_count = 0; > + list_add(&t->list, _classes + class); > + write_unlock(_locks + class); > + > + return 0; > +} > +EXPORT_SYMBOL(dm_register_type); > + > +/* Remove a type from the registry. */ > +int > +dm_unregister_type(void *type, enum dm_registry_class class) > +{ > + struct dm_registry_type *t = type; > + > + if (unlikely(class >= num_classes)) { > + DMERR("Attempt to unregister invalid class"); > + return -EINVAL; > + } > + > + write_lock(_locks + class); > + > + if (unlikely(t->use_count)) { > + write_unlock(_locks + class); > + DMWARN("Attempt to unregister a type that is still in > use"); > + return -ETXTBSY; > + } else > + list_del(&t->list); > + > + write_unlock(_locks + class); > + return 0; > +} > +EXPORT_SYMBOL(dm_unregister_type); > + > +/* > + * Return kmalloc'ed NULL terminated pointer > + * array of all type names of the given class. > + * > + * Caller has to kfree the array!. > + */ > +const char **dm_types_list(enum dm_registry_class class) > +{ > + unsigned i = 0, count = 0; > + const char **r; > + struct dm_registry_type *t; > + > + /* First count the registered types in the class. */ > + read_lock(_locks + class); > + list_for_each_entry(t, _classes + class, list) > + count++; > + read_unlock(_locks + class); > + > + /* None registered in this class. */ > + if (!count) > + return NULL; > + > + /* One member more for array NULL termination. */ > + r = kzalloc((count + 1) * sizeof(*r), GFP_KERNEL); > + if (!r) > + return ERR_PTR(-ENOMEM); > + > + /* > + * Go with the counted ones. > + * Any new added ones after we counted will be ignored! > + */ > + read_lock(_locks + class); > + list_for_each_entry(t, _classes + class, list) { > + r[i++] = t->name; > + if (!--count) > + break; > + } > + read_unlock(_locks + class); > + > + return r; > +} > +EXPORT_SYMBOL(dm_types_list); > + > +int __init > +dm_registry_init(void) > +{ > + unsigned n; > + > + BUG_ON(_classes); > + BUG_ON(_locks); > + > + /* Module parameter given ? */ > + if (!num_classes) > + num_classes = DM_REGISTRY_CLASS_END; > + > + n = num_classes; > + _classes = kmalloc(n * sizeof(*_classes), GFP_KERNEL); > + if (!_classes) { > + DMERR("Failed to allocate classes registry"); > + return -ENOMEM; > + } > + > + _locks = kmalloc(n * sizeof(*_locks), GFP_KERNEL); > + if (!_locks) { > + DMERR("Failed to allocate classes locks"); > + kfree(_classes); > + _classes = NULL; > + return -ENOMEM; > + } > + > + while (n--) { > + INIT_LIST_HEAD(_classes + n); > + rwlock_init(_locks + n); > + } > + > + DMINFO("initialized %s for max %u classes", version, num_classes); > + return 0; > +} > + > +void __exit > +dm_registry_exit(void) > +{ > + BUG_ON(!_classes); > + BUG_ON(!_locks); > + > + kfree(_classes); > + _classes = NULL; > + kfree(_locks); > + _locks = NULL; > + DMINFO("exit %s", version); > +} > + > +/* Module hooks */ > +module_init(dm_registry_init); > +module_exit(dm_registry_exit); > +module_param(num_classes, uint, 0); > +MODULE_PARM_DESC(num_classes, "Maximum number of classes"); > +MODULE_DESCRIPTION(DM_NAME "device-mapper registry"); > +MODULE_AUTHOR("Heinz Mauelshagen "); > +MODULE_LICENSE("GPL"); > + > +#ifndef MODULE > +static int __init num_classes_setup(char *str) > +{ > + num_classes = simple_strtol(str, NULL, 0); > + return num_classes ? 1 : 0; > +} > + > +__setup("num_classes=", num_classes_setup); > +#endif > diff --git 2.6.33-rc1.orig/drivers/md/dm-registry.h > 2.6.33-rc1/drivers/md/dm-registry.h > new file mode 100644 > index 0000000..1cb0ce8 > --- /dev/null > +++ 2.6.33-rc1/drivers/md/dm-registry.h > @@ -0,0 +1,38 @@ > +/* > + * Copyright (C) 2009 Red Hat, Inc. All rights reserved. > + * > + * Module Author: Heinz Mauelshagen (heinzm@redhat.com) > + * > + * Generic registry for arbitrary structures. > + * (needs dm_registry_type structure upfront each registered structure). > + * > + * This file is released under the GPL. > + */ > + > +#include "dm.h" > + > +#ifndef DM_REGISTRY_H > +#define DM_REGISTRY_H > + > +enum dm_registry_class { > + DM_REPLOG = 0, > + DM_SLINK, > + DM_LOG, > + DM_REGION_HASH, > + DM_REGISTRY_CLASS_END, > +}; > + > +struct dm_registry_type { > + struct list_head list; /* Linked list of types in this class. */ > + const char *name; > + struct module *module; > + unsigned int use_count; > +}; > + > +void *dm_get_type(const char *type_name, enum dm_registry_class class); > +void dm_put_type(void *type, enum dm_registry_class class); > +int dm_register_type(void *type, enum dm_registry_class class); > +int dm_unregister_type(void *type, enum dm_registry_class class); > +const char **dm_types_list(enum dm_registry_class class); > + > +#endif > -- > 1.6.2.5 > > -- > dm-devel mailing list > dm-devel@redhat.com > https://www.redhat.com/mailman/listinfo/dm-devel > --00504502b46855211d047c9063b6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Is there any command-line example to explain how to use this=A0 patch?=
I have compiled it and loaded the modules,=A0the '<start><= ;length>' target parameters in both replicator ant replicator-dev ta= rgets means what?
how can I construct these target?
I haven't read the source code=A0in detail till now, sorry.=A0
=
2009/12/18 <heinzm@redhat.com>
From: Heinz Mauelshagen <heinzm@redhat.com>

The dm-re= gistry module is a general purpose registry for modules.

The remote replicator utilizes it to register its ringbuffer log andsite link handlers in order to avoid duplicating registry code and logic.<= br>

Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Reviewed-by: Jon Brassow <jbrasso= w@redhat.com>
Tested-by: Jon Brassow <jbrassow@redhat.com>
---
=A0Documentation/devic= e-mapper/replicator.txt | =A0203 +++++++++++++++++++++++++
=A0drivers/md/Kconfig =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0= =A08 +
=A0drivers/md/Makefile =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0| =A0 =A01 +
=A0drivers/md/dm-registry.c =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 | =A0224 ++++++++++++++++++++++++++++
=A0drivers/md/dm-regis= try.h =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 38 +++++
=A05 files changed, 474 insertions(+), 0 deletions(-)
=A0create mode 100= 644 Documentation/device-mapper/replicator.txt
=A0create mode 100644 dri= vers/md/dm-registry.c
=A0create mode 100644 drivers/md/dm-registry.h
=
diff --git 2.6.33-rc1.orig/Documentation/device-mapper/replicator.txt 2.6.3= 3-rc1/Documentation/device-mapper/replicator.txt
new file mode 100644index 0000000..1d408a6
--- /dev/null
+++ 2.6.33-rc1/Documentation/de= vice-mapper/replicator.txt
@@ -0,0 +1,203 @@
+dm-replicator
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D
+
+Device-mapper replicator is designed to enable redundant co= pies of
+storage devices to be made - preferentially, to remote location= s.
+RAID1 (aka mirroring) is often used to maintain redundant copies of<= br> +storage for fault tolerance purposes. =A0Unlike RAID1, which often
+ass= umes similar device characteristics, dm-replicator is designed to
+handl= e devices with different latency and bandwidth characteristics
+which ar= e often the result of the geograhic disparity of multi-site
+architectures. =A0Simply put, you might choose RAID1 to protect from
+a= single device failure, but you would choose remote replication
+via dm-= replicator for protection against a site failure.
+
+dm-replicator wo= rks by first sending write requests to the "replicator
+log". =A0Not to be confused with the device-mapper dirty log, this+replicator log behaves similarly to that of a journal. =A0Write requests<= br>+go to this log first and then are copied to all the replicate devices +at their various locations. =A0Requests are cleared from the log once all<= br>+replicate devices confirm the data is received/copied. =A0This architec= ture
+allows dm-replicator to be flexible in terms of device characteris= tics.
+If one device should fall behind the others - perhaps due to high latency = -
+the slack is picked up by the log. =A0The user has a great deal of+flexibility in specifying to what degree a particular site is allowed to<= br> +fall behind - if at all.
+
+Device-Mapper's dm-replicator has tw= o targets, "replicator" and
+"replicator-dev". =A0Th= e "replicator" target is used to setup the
+aforementioned log= and allow the specification of site link properties.
+Through the "replicator" target, the user might specify that wri= tes
+that are copied to the local site must happen synchronously (i.e th= e
+writes are complete only after they have passed through the log devic= e
+and have landed on the local site's disk). =A0They may also specify th= at
+a remote link should asynchronously complete writes, but that the re= mote
+link should never fall more than 100MB behind in terms of processi= ng.
+Again, the "replicator" target is used to define the replicator = log and
+the characteristics of each site link.
+
+The "repli= cator-dev" target is used to define the devices used and
+associate= them with a particular replicator log. =A0You might think of
+this stage in a similar way to setting up RAID1 (mirroring). =A0You
+de= fine a set of devices which will be copies of each other, but
+access th= e device through the mirror virtual device which takes care
+of the copy= ing. =A0The user accessible replicator device is analogous
+to the mirror virtual device, while the set of devices being copied
+to= are analogous to the mirror images (sometimes called 'legs').
+= When creating a replicator device via the "replicator-dev" target= ,
+it must be associated with the replicator log (created with the
+aforem= entioned "replicator" target). =A0When each redundant device
+= is specified as part of the replicator device, it is associated with
+a = site link whose properties were defined when the "replicator"
+target was created.
+
+The user can go farther than simply replicati= ng one device. =A0They
+can continue to add replicator devices - associa= ting them with a
+particular replicator log. =A0Writes that go through t= he replicator
+log are guarenteed to have their write ordering preserved. =A0So, if
+y= ou associate more than one replicator device to a particular
+replicator= log, you are preserving write ordering across multiple
+devices. =A0Thi= s might be useful if you had a database that spanned
+multiple disks and write ordering must be preserved or any transaction
= +accounting scheme would be foiled. =A0(You can imagine this like
+prese= rving write ordering across a number of mirrored devices, where
+each mi= rror has images/legs in different geographic locations.)
+
+dm-replicator has a modular architecture. =A0Future implementations f= or
+the replicator log and site link modules are allowed. =A0The current=
+replication log is ringbuffer - utilized to store all writes being
+subject to replication and enforce write ordering. =A0The current site
= +link code is based on accessing block devices (iSCSI, FC, etc) and
+doe= s device recovery including (initial) resynchronization.
+
+
+Pict= ure of a 2 site configuration with 3 local devices (LDs) in a
+primary site being resycnhronied to 3 remotes sites with 3 remote
+devi= ces (RDs) each via site links (SLINK) 1-2 with site link 0
+as a special= case to handle the local devices:
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
+ =A0 =A0Local (primary) site =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A0= =A0Remote sites
+ =A0 =A0-------------------- =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 | =A0 =A0 =A0------------
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
+ =A0 =A0D1 =A0 D2= =A0 =A0 Dn =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
+ =A0 =A0 | =A0 | =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 |
+ =A0 =A0 +---+- ... -+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 |
+ =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 |
+ =A0 =A0 =A0 REPLOG-----------------+- SLINK1= ------------+
+ =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0| =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0|
+ =A0 =A0 =A0 SLINK0 (special case) =A0| =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 = =A0 =A0|
+ =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| = =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0|
+ =A0 =A0 +-----+ =A0 ... =A0+= =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0| =A0 +----+- ... -+
+ =A0 =A0= | =A0 =A0 | =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0| = =A0 | =A0 =A0| =A0 =A0 =A0 |
+ =A0 =A0LD1 =A0 LD2 =A0 =A0 =A0LDn =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 = =A0| =A0RD1 =A0RD2 =A0 =A0 RDn
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 =A0|
+ =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0+-- SLINK2------------+
+ =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 = =A0| =A0 =A0 =A0 =A0|
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 = =A0 =A0 =A0| =A0 +----+- ... -+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 =A0| =A0 | =A0 =A0| =A0 =A0 = =A0 |
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0= =A0 =A0 =A0 =A0 =A0| =A0RD1 =A0RD2 =A0 =A0 RDn
+ =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 =A0|
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 = =A0 =A0 =A0|
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0| =A0 =A0 =A0 =A0 =A0 =A0|
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0+- SLINKm ------------+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0|=
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 | =A0 +----+- ... -+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 | =A0 | =A0 =A0| =A0 =A0 =A0 |
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0RD1 =A0RD2 = =A0 =A0 RDn
+
+
+
+
+The following are descriptions of the d= evice-mapper tables used to
+construct the "replicator" and "replicator-dev" target= s.
+
+"replicator" target parameters:
+-----------------= --------------
+<start> <length> replicator \
+ =A0 =A0 = =A0 <replog_type> <#replog_params> <replog_params> \
+ =A0 =A0 =A0 [<slink_type_0> <#slink_params_0> <slink_param= s_0>]{1..N}
+
+<replog_type> =A0 =A0=3D "ringbuffer&quo= t; is currently the only available type
+<#replog_params> =3D # of= args following this one intended for the replog (2 or 4)
+<replog_params> =A0=3D <dev_path> <dev_start> [auto/crea= te/open <size>]
+ =A0 =A0 =A0 <dev_path> =A0=3D device path = of replication log (REPLOG) backing store
+ =A0 =A0 =A0 <dev_start>= ; =3D offset to REPLOG header
+ =A0 =A0 =A0 create =A0 =A0 =A0=3D The replication log will be initialized= if not active
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 and sized to &q= uot;size". =A0(If already active, the create
+ =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 will fail.) =A0Size is always in sectors.
+ =A0 =A0 =A0 open =A0 =A0 =A0 =A0=3D The replication log must be initializ= ed and valid or
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 the constructo= r will fail.
+ =A0 =A0 =A0 auto =A0 =A0 =A0 =A0=3D If a valid replicatio= n log header is found on the
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 r= eplication device, this will behave like 'open'.
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Otherwise, this option behaves li= ke 'create'.
+
+<slink_type> =A0 =A0=3D "blockdev&= quot; is currently the only available type
+<#slink_params> =3D 1/= 2/4
+<slink_params> =A0=3D <slink_nr> [<slink_policy> = [<fall_behind> <N>]]
+ =A0 =A0 =A0 <slink_nr> =A0 =A0 =3D This is a unique number that is = used to identify a
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0part= icular site/location. =A0'0' is always used to
+ =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0identify the local site, while increasing i= ntegers
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0are used to identify remot= e sites.
+ =A0 =A0 =A0 <slink_policy> =3D The policy can be either= 'sync' or 'async'.
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0'sync' means write requests will not return until + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0the data is on the storage= device. =A0'async' allows
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0a device to "fall behind"; that is, outstanding
+ = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0write requests are waiting i= n the replication log
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0to be processed for this s= ite, but it is not delaying
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0the writes of other sites.
+ =A0 =A0 =A0 <fall_behind> =A0= =3D This field is used to specify how far the user is
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0willing to allow write req= uests to this specific site
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0to "fall behind" in processing before switching to
+ = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0a 'sync' policy. =A0= This "fall behind" threshhold can
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0be specified in three ways= : ios, size, or timeout.
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0'ios' is the number of pending I/Os allowed (e.g.
+ =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"ios 10000"). =A0'size= ' is the amount of pending data
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0allowed (e.g. "size 2= 00m"). =A0Size labels include:
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0s (sectors), k, m, g, t, p, and e. =A0'timeout' is+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0the amount of time allow= ed for writes to be
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0outstanding. =A0Time label= s include: s, m, h, and d.
+
+
+"replicator-dev" target = parameters:
+-----------------------------------
+start> <lengt= h> replicator-dev
+ =A0 =A0 =A0 <replicator_device> <dev_nr> \
+ =A0 =A0 =A0 [= <slink_nr> <#dev_params> <dev_params>
+ =A0 =A0 =A0 = =A0<dlog_type> <#dlog_params> <dlog_params>]{1..N}
++<replicator_device> =3D device previously constructed via "re= plication" target
+<dev_nr> =A0 =A0 =A0 =A0 =A0 =3D An integer that is used to 'tag= ' write requests as
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 belong= ing to a particular set of devices - specifically,
+ =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 the devices that follow this argument (i.e. the site + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 link devices).
+<slink_nr&g= t; =A0 =A0 =A0 =A0 =3D This number identifies the site/location where the n= ext
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 device to be specified com= es from. =A0It is exactly the
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = same number used to identify the site/location (and its
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 policies) in the "replicator= " target. =A0Interestingly,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 while one might normally expect a "dev_type" argument
+ = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 here, it can be deduced from the si= te link number and
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 the 'slink_type' given in= the "replication" target.
+<#dev_params> =A0 =A0 =A0=3D= '1' =A0(The number of allowed parameters actually depends
+ =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 on the 'slink_type' given in t= he "replication" target.
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Since our only option there is &q= uot;blockdev", the only
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 a= llowable number here is currently '1'.)
+<dev_params> =A0 = =A0 =A0 =3D 'dev_path' =A0(Again, since "blockdev" is the= only
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'slink_type' available, t= he only allowable argument here
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 is the path to the device.)
+<dlog_type> =A0 =A0 =A0 =A0=3D No= t to be confused with the "replicator log", this is
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 the type of dirty log associated = with this particular
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 device. = =A0Dirty logs are used for synchronization, during
+ =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 initialization or fall behind conditions, to bring dev= ices
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 into a coherent state with its pe= ers - analogous to
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rebuilding = a RAID1 (mirror) device. =A0Available dirty
+ =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 log types include: 'nolog', 'core', and = 9;disk'
+<#dlog_params> =A0 =A0 =3D The number of arguments required for a pa= rticular log
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 type - 'nolog= ' =3D 0, 'core' =3D 1/2, 'disk' =3D 2/3.
+<dlog_p= arams> =A0 =A0 =A0=3D 'nolog' =3D> ~no arguments~
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'core' =A0=3D> <reg= ion_size> [sync | nosync]
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &= #39;disk' =A0=3D> <dlog_dev_path> <region_size> [sync | = nosync]
+ =A0 =A0 =A0 <region_size> =A0 =3D This sets the granular= ity at which the dirty log
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 tracks what areas of the = device is in-sync.
+ =A0 =A0 =A0 [sync | nosync] =3D Optionally specify = whether the sync should be forced
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 or avoided initially.
diff --git 2.6.33-rc1.orig/drivers/md/= Kconfig 2.6.33-rc1/drivers/md/Kconfig
index acb3a4e..62c9766 100644
--- 2.6.33-rc1.orig/drivers/md/Kconfig
= +++ 2.6.33-rc1/drivers/md/Kconfig
@@ -313,6 +313,14 @@ config DM_DELAY
=A0 =A0 =A0 =A0If unsure, say N.

+config DM_REPLICATOR
+ = =A0 =A0 =A0 tristate "Replication target (EXPERIMENTAL)"
+ =A0 =A0 =A0 depends on BLK_DEV_DM && EXPERIMENTAL
+ =A0 =A0 = =A0 ---help---
+ =A0 =A0 =A0 A target that supports replication of local= devices to remote sites.
+
+ =A0 =A0 =A0 If unsure, say N.
+
= =A0config DM_UEVENT
=A0 =A0 =A0 =A0bool "DM uevents (EXPERIMENTAL)&= quot;
=A0 =A0 =A0 =A0depends on BLK_DEV_DM && EXPERIMENTAL
diff --git = 2.6.33-rc1.orig/drivers/md/Makefile 2.6.33-rc1/drivers/md/Makefile
index= e355e7f..be05b39 100644
--- 2.6.33-rc1.orig/drivers/md/Makefile
+++ = 2.6.33-rc1/drivers/md/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_DM_SNAPSHOT) =A0 =A0 +=3D dm-snapshot.o
= =A0obj-$(CONFIG_DM_MIRROR) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0+=3D dm-mirror.o = dm-log.o dm-region-hash.o
=A0obj-$(CONFIG_DM_LOG_USERSPACE) +=3D dm-log-= userspace.o
=A0obj-$(CONFIG_DM_ZERO) =A0 =A0 =A0 =A0 =A0+=3D dm-zero.o +obj-$(CONFIG_DM_REPLICATOR) =A0 =A0+=3D dm-log.o dm-registry.o

=A0q= uiet_cmd_unroll =3D UNROLL =A0$@
=A0 =A0 =A0 cmd_unroll =3D $(AWK) -f$(s= rctree)/$(src)/unroll.awk -vN=3D$(UNROLL) \
diff --git 2.6.33-rc1.orig/d= rivers/md/dm-registry.c 2.6.33-rc1/drivers/md/dm-registry.c
new file mode 100644
index 0000000..fb8abbf
--- /dev/null
+++ 2.6.= 33-rc1/drivers/md/dm-registry.c
@@ -0,0 +1,224 @@
+/*
+ * Copyrigh= t (C) 2009 Red Hat, Inc. All rights reserved.
+ *
+ * Module Author: = Heinz Mauelshagen (heinzm@redhat.com)
+ *
+ * Generic registry for arbitrary structures
+ * (needs dm_regis= try_type structure upfront each registered structure).
+ *
+ * This f= ile is released under the GPL.
+ *
+ * FIXME: use as registry for e.g= . dirty log types as well.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h= >
+#include <linux/moduleparam.h>
+
+#include "dm-re= gistry.h"
+
+#define =A0 =A0 =A0 =A0DM_MSG_PREFIX =A0 "dm-r= egistry"
+
+static const char *version =3D "0.001";
+
+/* Sizable= class registry. */
+static unsigned num_classes;
+static struct list= _head *_classes;
+static rwlock_t *_locks;
+
+void *
+dm_get_ty= pe(const char *type_name, enum dm_registry_class class)
+{
+ =A0 =A0 =A0 struct dm_registry_type *t;
+
+ =A0 =A0 =A0 read_= lock(_locks + class);
+ =A0 =A0 =A0 list_for_each_entry(t, _classes + cl= ass, list) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!strcmp(type_name, t->= name)) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!t->use_co= unt && !try_module_get(t->module)) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 read_unlock(_= locks + class);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 return ERR_PTR(-ENOMEM);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 }
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t->use_c= ount++;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 read_unlock(_locks= + class);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return t;
+ =A0 =A0 =A0 = =A0 =A0 =A0 =A0 }
+ =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 read_unlock(_loc= ks + class);
+ =A0 =A0 =A0 return ERR_PTR(-ENOENT);
+}
+EXPORT_SYM= BOL(dm_get_type);
+
+void
+dm_put_type(void *type, enum dm_registr= y_class class)
+{
+ =A0 =A0 =A0 struct dm_registry_type *t =3D type;
+
+ =A0 =A0 = =A0 read_lock(_locks + class);
+ =A0 =A0 =A0 if (!--t->use_count)
= + =A0 =A0 =A0 =A0 =A0 =A0 =A0 module_put(t->module);
+
+ =A0 =A0 = =A0 read_unlock(_locks + class);
+}
+EXPORT_SYMBOL(dm_put_type);
+
+/* Add a type to the registry. */
= +int
+dm_register_type(void *type, enum dm_registry_class class)
+{+ =A0 =A0 =A0 struct dm_registry_type *t =3D type, *tt;
+
+ =A0 =A0= =A0 if (unlikely(class >=3D num_classes))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
+
+ =A0 =A0 =A0 tt =3D = dm_get_type(t->name, class);
+ =A0 =A0 =A0 if (unlikely(!IS_ERR(tt)))= {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 dm_put_type(t, class);
+ =A0 =A0 =A0= =A0 =A0 =A0 =A0 return -EEXIST;
+ =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 write_lock(_locks + class);
+ =A0 =A0 =A0 t->use_count = =3D 0;
+ =A0 =A0 =A0 list_add(&t->list, _classes + class);
+ = =A0 =A0 =A0 write_unlock(_locks + class);
+
+ =A0 =A0 =A0 return 0;+}
+EXPORT_SYMBOL(dm_register_type);
+
+/* Remove a type from the registry. */
+int
+dm_unregister_type= (void *type, enum dm_registry_class class)
+{
+ =A0 =A0 =A0 struct dm= _registry_type *t =3D type;
+
+ =A0 =A0 =A0 if (unlikely(class >= =3D num_classes)) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 DMERR("Attempt to unregister invalid cla= ss");
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
+ =A0 =A0 = =A0 }
+
+ =A0 =A0 =A0 write_lock(_locks + class);
+
+ =A0 =A0 = =A0 if (unlikely(t->use_count)) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 write= _unlock(_locks + class);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 DMWARN("Attempt to unregister a type tha= t is still in use");
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ETXTBSY;=
+ =A0 =A0 =A0 } else
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 list_del(&t-&= gt;list);
+
+ =A0 =A0 =A0 write_unlock(_locks + class);
+ =A0 =A0 =A0 return 0;
+}
+EXPORT_SYMBOL(dm_unregister_type);
++/*
+ * Return kmalloc'ed NULL terminated pointer
+ * array of = all type names of the given class.
+ *
+ * Caller has to kfree the ar= ray!.
+ */
+const char **dm_types_list(enum dm_registry_class class)
+{
= + =A0 =A0 =A0 unsigned i =3D 0, count =3D 0;
+ =A0 =A0 =A0 const char **= r;
+ =A0 =A0 =A0 struct dm_registry_type *t;
+
+ =A0 =A0 =A0 /* Fi= rst count the registered types in the class. */
+ =A0 =A0 =A0 read_lock(_locks + class);
+ =A0 =A0 =A0 list_for_each_ent= ry(t, _classes + class, list)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 count++;
= + =A0 =A0 =A0 read_unlock(_locks + class);
+
+ =A0 =A0 =A0 /* None re= gistered in this class. */
+ =A0 =A0 =A0 if (!count)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return NULL;
+
+ =A0 =A0 =A0 /* One mem= ber more for array NULL termination. */
+ =A0 =A0 =A0 r =3D kzalloc((cou= nt + 1) * sizeof(*r), GFP_KERNEL);
+ =A0 =A0 =A0 if (!r)
+ =A0 =A0 = =A0 =A0 =A0 =A0 =A0 return ERR_PTR(-ENOMEM);
+
+ =A0 =A0 =A0 /*
+ =A0 =A0 =A0 =A0* Go with the counted ones.
+ = =A0 =A0 =A0 =A0* Any new added ones after we counted will be ignored!
+ = =A0 =A0 =A0 =A0*/
+ =A0 =A0 =A0 read_lock(_locks + class);
+ =A0 =A0 = =A0 list_for_each_entry(t, _classes + class, list) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 r[i++] =3D t->name;
+ =A0 =A0 =A0 =A0 = =A0 =A0 =A0 if (!--count)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = break;
+ =A0 =A0 =A0 }
+ =A0 =A0 =A0 read_unlock(_locks + class);
= +
+ =A0 =A0 =A0 return r;
+}
+EXPORT_SYMBOL(dm_types_list);
+
+int __init
+dm_registry_init(void)
+{
+ =A0 =A0 =A0 unsigned= n;
+
+ =A0 =A0 =A0 BUG_ON(_classes);
+ =A0 =A0 =A0 BUG_ON(_locks)= ;
+
+ =A0 =A0 =A0 /* Module parameter given ? */
+ =A0 =A0 =A0 if = (!num_classes)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 num_classes =3D DM_REGISTRY= _CLASS_END;
+
+ =A0 =A0 =A0 n =3D num_classes;
+ =A0 =A0 =A0 _classes =3D kmalloc= (n * sizeof(*_classes), GFP_KERNEL);
+ =A0 =A0 =A0 if (!_classes) {
+= =A0 =A0 =A0 =A0 =A0 =A0 =A0 DMERR("Failed to allocate classes registr= y");
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM;
+ =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 _locks =3D kmalloc(n * sizeof(*_locks= ), GFP_KERNEL);
+ =A0 =A0 =A0 if (!_locks) {
+ =A0 =A0 =A0 =A0 =A0 = =A0 =A0 DMERR("Failed to allocate classes locks");
+ =A0 =A0 = =A0 =A0 =A0 =A0 =A0 kfree(_classes);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 _clas= ses =3D NULL;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM;
+ =A0 =A0 =A0 }
+
+ = =A0 =A0 =A0 while (n--) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 INIT_LIST_HEAD(_= classes + n);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 rwlock_init(_locks + n);
= + =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 DMINFO("initialized %s for max %= u classes", version, num_classes);
+ =A0 =A0 =A0 return 0;
+}
+
+void __exit
+dm_registry_exit(voi= d)
+{
+ =A0 =A0 =A0 BUG_ON(!_classes);
+ =A0 =A0 =A0 BUG_ON(!_lock= s);
+
+ =A0 =A0 =A0 kfree(_classes);
+ =A0 =A0 =A0 _classes =3D NU= LL;
+ =A0 =A0 =A0 kfree(_locks);
+ =A0 =A0 =A0 _locks =3D NULL;
+ =A0 =A0 =A0 DMINFO("exit %s",= version);
+}
+
+/* Module hooks */
+module_init(dm_registry_in= it);
+module_exit(dm_registry_exit);
+module_param(num_classes, uint,= 0);
+MODULE_PARM_DESC(num_classes, "Maximum number of classes"= ;);
+MODULE_DESCRIPTION(DM_NAME "device-mapper registry");
+MODULE= _AUTHOR("Heinz Mauelshagen <
he= inzm@redhat.com>");
+MODULE_LICENSE("GPL");
+ +#ifndef MODULE
+static int __init num_classes_setup(char *str)
+{+ =A0 =A0 =A0 num_classes =3D simple_strtol(str, NULL, 0);
+ =A0 =A0 = =A0 return num_classes ? 1 : 0;
+}
+
+__setup("num_classes=3D= ", num_classes_setup);
+#endif
diff --git 2.6.33-rc1.orig/drivers/md/dm-registry.h 2.6.33-rc1/d= rivers/md/dm-registry.h
new file mode 100644
index 0000000..1cb0ce8--- /dev/null
+++ 2.6.33-rc1/drivers/md/dm-registry.h
@@ -0,0 +1,38= @@
+/*
+ * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+ *
= + * Module Author: Heinz Mauelshagen (= heinzm@redhat.com)
+ *
+ * Generic registry for arbitrary structu= res.
+ * (needs dm_registry_type structure upfront each registered structure).+ *
+ * This file is released under the GPL.
+ */
+
+#include= "dm.h"
+
+#ifndef DM_REGISTRY_H
+#define DM_REGISTRY_H<= br> +
+enum dm_registry_class {
+ =A0 =A0 =A0 DM_REPLOG =3D 0,
+ =A0 = =A0 =A0 DM_SLINK,
+ =A0 =A0 =A0 DM_LOG,
+ =A0 =A0 =A0 DM_REGION_HASH,=
+ =A0 =A0 =A0 DM_REGISTRY_CLASS_END,
+};
+
+struct dm_registry= _type {
+ =A0 =A0 =A0 struct list_head list; =A0/* Linked list of types = in this class. */
+ =A0 =A0 =A0 const char *name;
+ =A0 =A0 =A0 struct module *module;
= + =A0 =A0 =A0 unsigned int use_count;
+};
+
+void *dm_get_type(con= st char *type_name, enum dm_registry_class class);
+void dm_put_type(voi= d *type, enum dm_registry_class class);
+int dm_register_type(void *type, enum dm_registry_class class);
+int dm= _unregister_type(void *type, enum dm_registry_class class);
+const char = **dm_types_list(enum dm_registry_class class);
+
+#endif
--
1.6.2.5

--
dm-devel mailing list
dm-devel@redhat.com
https://ww= w.redhat.com/mailman/listinfo/dm-devel

--00504502b46855211d047c9063b6-- --===============0765147422350775691== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============0765147422350775691==--