From: Busby Subject: Re: [PATCH v6 1/4] dm-replicator: documentation and module registry Date: Tue, 9 Feb 2010 09:48:30 +0800 Message-ID: References: <1261151073-25962-1-git-send-email-heinzm@redhat.com> <1261151073-25962-2-git-send-email-heinzm@redhat.com> <1262979877.27554.40.camel@o> Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8715731182062541392==" Return-path: In-Reply-To: <1262979877.27554.40.camel@o> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: heinzm@redhat.com, device-mapper development List-Id: dm-devel.ids --===============8715731182062541392== Content-Type: multipart/alternative; boundary=0050450294e3693b80047f211d74 --0050450294e3693b80047f211d74 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable Hi , I have some questions about this replicator module after deployed on my systems: 1.when the connection to the RD failed at the moment reading or writin= g data to the D_link, the D_link will fail? can't D_link & LD be well in this situation? (one LD and one RD, yes, RD can be RDs such as RAID1, however, all of the RDs disconnected, the D_link also will fail?it will affect on th= e user's applications, in gernal speaking, RD can be fail, but the LD (D_link for user )should be ok at this situation. ) 2.Any deals with the data initiation of the LD and RD in this repl module, not using 'dd' cmds. is there any interface to do it in the architecture design of this system (roadmap)? 3.While doing the repl, sometime, the RD or LD failed, is there any function to resync th RD and LD when the LD or RD system come back and then continue to do the repl? 4.Any design when LD fails, the LD come back, the RD to restore the LD= ? not use 'dd' cmd. (as 3rd question said, but this situation just take attention to the restore repl from the RD.) I am very interest in this repl module, sorry for asking so many questions. DRBD of HA feild is a good tool for HA, but not for repl. Is there other idea of replication design in Linux system? Thank you very much. Regards, Busby 2010/1/9 Heinz Mauelshagen > On Thu, 2010-01-07 at 18:18 +0800, =D5=C5=D3=EE wrote: > > Is there any command-line example to explain how to use this patch? > > Look at Documentation/device-mapper/replicator.txt and at comments above > replicator_ctr() and _replicator_dev_ctr() in dm-repl.c for mapping > table syntax and examples. > > > I have compiled it and loaded the modules, the '' > > target parameters in both replicator ant replicator-dev targets means > > what? > > replicator doesn't provide a direct mapping of its own, so is > arbitrary and shal be 0. > > > how can I construct these target? > > See documentation hints above. > > > I haven't read the source code in detail till now, sorry. > > You will now ;-) > > Regards, > Heinz > > > > > > > 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 > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > +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} > > + > > + =3D "ringbuffer" is currently the only > > available type > > +<#replog_params> =3D # of args following this one intended for > > the replog (2 or 4) > > + =3D [auto/create/open > > ] > > + =3D device path of replication log (REPLOG) > > backing store > > + =3D offset to REPLOG header > > + create =3D 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 =3D The replication log must be initialized > > and valid or > > + the constructor will fail. > > + auto =3D If a valid replication log header is > > found on the > > + replication device, this will behave > > like 'open'. > > + Otherwise, this option behaves like > > 'create'. > > + > > + =3D "blockdev" is currently the only available > > type > > +<#slink_params> =3D 1/2/4 > > + =3D [ [ > > ]] > > + =3D 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. > > + =3D 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. > > + =3D This field is used to specify how fa= r > > 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} > > + > > + =3D device previously constructed via > > "replication" target > > + =3D 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). > > + =3D This number identifies the site/locatio= n > > 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> =3D '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'.) > > + =3D 'dev_path' (Again, since "blockdev" is > > the only > > + 'slink_type' available, the only > > allowable argument here > > + is the path to the device.) > > + =3D 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> =3D The number of arguments required for a > > particular log > > + type - 'nolog' =3D 0, 'core' =3D 1/2, 'di= sk' > > =3D 2/3. > > + =3D 'nolog' =3D> ~no arguments~ > > + 'core' =3D> [sync | nosync= ] > > + 'disk' =3D> > > [sync | nosync] > > + =3D This sets the granularity at which > > the dirty log > > + tracks what areas of the device is > > in-sync. > > + [sync | nosync] =3D 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) +=3D > > dm-snapshot.o > > obj-$(CONFIG_DM_MIRROR) +=3D dm-mirror.o > > dm-log.o dm-region-hash.o > > obj-$(CONFIG_DM_LOG_USERSPACE) +=3D dm-log-userspace.o > > obj-$(CONFIG_DM_ZERO) +=3D dm-zero.o > > +obj-$(CONFIG_DM_REPLICATOR) +=3D dm-log.o dm-registry.o > > > > quiet_cmd_unroll =3D UNROLL $@ > > cmd_unroll =3D $(AWK) -f$(srctree)/$(src)/unroll.awk -vN= =3D > > $(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 =3D "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 =3D 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 =3D type, *tt; > > + > > + if (unlikely(class >=3D num_classes)) > > + return -EINVAL; > > + > > + tt =3D 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 =3D 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 =3D type; > > + > > + if (unlikely(class >=3D 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 =3D 0, count =3D 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 =3D 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++] =3D 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 =3D DM_REGISTRY_CLASS_END; > > + > > + n =3D num_classes; > > + _classes =3D kmalloc(n * sizeof(*_classes), GFP_KERNEL)= ; > > + if (!_classes) { > > + DMERR("Failed to allocate classes registry"); > > + return -ENOMEM; > > + } > > + > > + _locks =3D kmalloc(n * sizeof(*_locks), GFP_KERNEL); > > + if (!_locks) { > > + DMERR("Failed to allocate classes locks"); > > + kfree(_classes); > > + _classes =3D 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 =3D NULL; > > + kfree(_locks); > > + _locks =3D 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 =3D simple_strtol(str, NULL, 0); > > + 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/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 =3D 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 > > > > -- > > dm-devel mailing list > > dm-devel@redhat.com > > https://www.redhat.com/mailman/listinfo/dm-devel > > -- > dm-devel mailing list > dm-devel@redhat.com > https://www.redhat.com/mailman/listinfo/dm-devel > --0050450294e3693b80047f211d74 Content-Type: text/html; charset=GB2312 Content-Transfer-Encoding: quoted-printable
Hi ,
    I have some questions about this replicator module = after deployed on my systems:
    1.when the connection to the  RD failed a= t the moment reading or writing data to the D_link, the D_link will fa= il? can't D_link & LD be well in this situation? (one LD = and one RD, yes, RD can be RDs such as RAID1, however, all of the RDs disco= nnected, the D_link also will fail?it will affect on the user's applica= tions, in gernal speaking, RD can be fail, but the LD (D_link for user )sho= uld be ok at this situation. )
    2.Any deals with the data initiation of the LD= and RD in this repl module, not using 'dd' cmds. is there any inte= rface to do it in the architecture design of this system (roadmap)?&nb= sp;
    3.While doing the repl, sometime, the RD or LD fa= iled, is there any function to resync th RD and LD when the LD or RD s= ystem come back and then continue to do the repl?
    4.Any design when LD fails, the LD come back, =  the RD to restore the LD? not use 'dd' cmd. (as 3rd question = said, but this situation just take attention to the restore repl from the R= D.)
     I am very interest in this repl module, sorry= for asking so many questions.
     DRBD of HA feild is a good tool for HA, but n= ot for repl. Is there other idea of replication design in Linux system= ?
     Thank you very much. 
 
 Regards,
 Busby
2010/1/9 Heinz Mauelshagen <= ;heinzm@redhat.com>
On Thu, 2010-01-07 at 18:18 +0800, =D5=C5=D3=EE wrote:> Is there any command-line example to explain how to use this  pa= tch?

Look at Documentation/device-mapper/replicator.txt and at= comments above
replicator_ctr() and _replicator_dev_ctr() in dm-repl.c for mapping
tabl= e syntax and examples.

> I have compiled it and loaded the modules, the &= #39;<start><length>'
> target parameters in both repl= icator ant replicator-dev targets means
> what?

replicat= or doesn't provide a direct mapping of its own, so <length> is arbitrary and <start> shal be 0.

> how can I construct these target?

S= ee documentation hints above.

> I haven't read the source code in detail til= l now, sorry.

You will now ;-)

Regards,
Heinz

>
>
> 2009/12/18 <heinzm@redhat.com>
>       =   From: Heinz Mauelshagen <hei= nzm@redhat.com>
>
>         The dm-registry module is a genera= l purpose registry for
>         modules.
>=
>         The remote replicator utilizes it to r= egister its ringbuffer
>         log and
> =         site link handlers in order to avoid duplicatin= g registry code
>         and logic.
>
>
>   =       Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
>       =   Reviewed-by: Jon Brassow <= jbrassow@redhat.com>
>         Tested-by: Jon Brassow <jbrassow@redhat.com>
>     &= nbsp;   ---
>          Documentation/de= vice-mapper/replicator.txt |  203
>         = +++++++++++++++++++++++++
>          drivers/md/Kconfig     &nb= sp;                   |  =  8 +
>          drivers/md/Makefile &n= bsp;                     =  |    1 +
>          drivers/= md/dm-registry.c                 &n= bsp; |  224
>         ++++++++++++++++++++++= ++++++
>          drivers/md/dm-registry.h   &nbs= p;               |   38 +++++
&g= t;          5 files changed, 474 insertions(+), 0 = deletions(-)
>          create mode 100644 D= ocumentation/device-mapper/replicator.txt
>       &nbs= p;  create mode 100644 drivers/md/dm-registry.c
>          create mode 100644 drivers/md/dm-reg= istry.h
>
>         diff --git
> &nbs= p;       2.6.33-rc1.orig/Documentation/device-mapper/replica= tor.txt
>         2.6.33-rc1/Documentation/device= -mapper/replicator.txt
>         new file mode 100644
>    =     index 0000000..1d408a6
>         -= -- /dev/null
>         +++ 2.6.33-rc1/Documentati= on/device-mapper/replicator.txt
>         @@ -0,0= +1,203 @@
>         +dm-replicator
>         +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D>         +
>         +D= evice-mapper replicator is designed to enable redundant
>   &nbs= p;     copies of
>         +storage dev= ices to be made - preferentially, to remote
>         locations.
>       &n= bsp; +RAID1 (aka mirroring) is often used to maintain redundant
> &nb= sp;       copies of
>         +sto= rage for fault tolerance purposes.  Unlike RAID1, which
>  =       often
>         +assumes similar device characteristics, d= m-replicator is
>         designed to
> &nb= sp;       +handle devices with different latency and bandwid= th
>         characteristics
>    = ;     +which are often the result of the geograhic disparity of >         multi-site
>       &n= bsp; +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<= br>>         "replicator
>     =     +log".  Not to be confused with the device-mapper d= irty log,
>         this
>         += replicator log behaves similarly to that of a journal.  Write
> =         requests
>         +g= o to this log first and then are copied to all the replicate
>  =       devices
>         +at their various locations.  Request= s are cleared from the
>         log once all
= >         +replicate devices confirm the data is rec= eived/copied.  This
>         architecture>         +allows dm-replicator to be flexible in = terms of device
>         characteristics.
>     &nb= sp;   +If one device should fall behind the others - perhaps due to>         high latency -
>     &nbs= p;   +the slack is picked up by the log.  The user has a great de= al
>         of
>         +fl= exibility in specifying to what degree a particular site is
>   =       allowed to
>         +fall b= ehind - if at all.
>         +
>   &nb= sp;     +Device-Mapper's dm-replicator has two targets, "= ;replicator"
>         and
>         +&= quot;replicator-dev".  The "replicator" target is used = to setup
>         the
>     &nbs= p;   +aforementioned log and allow the specification of site link
&= gt;         properties.
>         +Through the "replicator" target= , the user might specify that
>         writes>         +that are copied to the local site must h= appen synchronously
>         (i.e the
> &n= bsp;       +writes are complete only after they have passed = through the
>         log device
>       &n= bsp; +and have landed on the local site's disk).  They may also>         specify that
>      =   +a remote link should asynchronously complete writes, but that
&= gt;         the remote
>         +link should never fall more than 100MB be= hind in terms of
>         processing.
> &n= bsp;       +Again, the "replicator" target is used= to define the
>         replicator log and
&g= t;         +the characteristics of each site link.
>         +
>         +The= "replicator-dev" target is used to define the devices
> &n= bsp;       used and
>         +ass= ociate them with a particular replicator log.  You might
>  = ;       think of
>         +this stage in a similar way to setting up= RAID1 (mirroring).
>          You
> &= nbsp;       +define a set of devices which will be copies of= each other,
>         but
>     =     +access the device through the mirror virtual device which >         takes care
>       &n= bsp; +of the copying.  The user accessible replicator device is
>= ;         analogous
>        = +to the mirror virtual device, while the set of devices being
> &nbs= p;       copied
>         +to are analogous to the mirror images (so= metimes called
>         'legs').
>=         +When creating a replicator device via the &qu= ot;replicator-dev"
>         target,
>=         +it must be associated with the replicator log= (created with
>         the
>         +a= forementioned "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.
>     &n= bsp;   +
>         +The user can go farther = than simply replicating one device.
>          They
>       &n= bsp; +can continue to add replicator devices - associating them
> &nb= sp;       with a
>         +partic= ular replicator log.  Writes that go through the
>    =     replicator
>         +log are guar= enteed to have their write ordering preserved.
>          So, if
>       =   +you associate more than one replicator device to a particular
&g= t;         +replicator log, you are preserving write or= dering across
>         multiple
>   &= nbsp;     +devices.  This might be useful if you had a datab= ase that
>         spanned
>        = ; +multiple disks and write ordering must be preserved or any
>  = ;       transaction
>         +acc= ounting scheme would be foiled.  (You can imagine this
>   =       like
>         +preserving write ordering across a number= of mirrored
>         devices, where
> &nb= sp;       +each mirror has images/legs in different geograph= ic
>         locations.)
>     &n= bsp;   +
>         +dm-replicator has a modu= lar architecture.  Future
>         implementations for
>     =     +the replicator log and site link modules are allowed.  = The
>         current
>      = ;   +replication log is ringbuffer - utilized to store all writes
&= gt;         being
>         +subject to replication and enforce write = ordering.  The
>         current site
>= ;         +link code is based on accessing block device= s (iSCSI, FC,
>         etc) and
>   &= nbsp;     +does device recovery including (initial) resynchroniza= tion.
>         +
>         +>         +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
>   &n= bsp;     +as a special case to handle the local devices:
> =         +
>         +   =                      = ;                   |
>         +    Local (primary) site  =                 |     &n= bsp;Remote
>         sites
>     =     +    --------------------       &nbs= p;           |
>        =  ------------
>         +     &nb= sp;                     &= nbsp;               |
>         +    D1   D2     = Dn                     &n= bsp;   |
>         +     |   = |       |               &= nbsp;         |
>         + &= nbsp;   +---+- ... -+              =           |
>         +=         |             &n= bsp;                   |
>         +       REPLOG-------------= ----+- SLINK1 ------------+
>         +   &n= bsp;     |                = ;    |            |     &= nbsp;  |
>         +       SL= INK0 (special case)  |            | &nbs= p;      |
>         +    = ;     |                 &= nbsp;  |            |     &nbs= p;  |
>         +     +-----+   ...  +=         |            | &= nbsp; +----+- ... -+
>         +     | =     |        |         | =            |   |    |   &= nbsp;   |
>         +    LD1  = ; LD2      LDn        |     &n= bsp;      |  RD1  RD2
>         RDn
>         + =                      = ;        |            |>         +           &nb= sp;                  +-- SLINK= 2------------+
>         +       &= nbsp;                    =  |            |       &n= bsp;|
>         +            = ;                  |   &n= bsp;        |   +----+- ... -+
>   &nbs= p;     +                 =              |       &nbs= p;    |   |    |       |
> &n= bsp;       +              = ;                |     &n= bsp;      |  RD1  RD2
>         RDn
>         + =                      = ;        |            |>         +           &nb= sp;                  |   =          |
>         + &= nbsp;                    =        |            |>         +           &nbs= p;                  +- SLINKm = ------------+
>         +            = ;                     &nb= sp;         |        |
> &nbs= p;       +               =                      = ;       |   +----+- ... -+
>      =   +                   &n= bsp;                     =   |   |    |       |
>         +            = ;                     &nb= sp;         |  RD1  RD2
>    =     RDn
>         +
>   &nb= sp;     +
>         +
>   &n= bsp;     +
>         +The following are= descriptions of the device-mapper tables
>         used to
>        = ; +construct the "replicator" and "replicator-dev" targ= ets.
>         +
>       &nb= sp; +"replicator" target parameters:
>      =   +-------------------------------
>         +<start> <length> replicator \=
>         +       <replog_type= > <#replog_params> <replog_params> \
>     &= nbsp;   +       [<slink_type_0> <#slink_params= _0>
>         <slink_params_0>]{1..N} >         +
>         +<= ;replog_type>    =3D "ringbuffer" is currently the o= nly
>         available type
>    = ;     +<#replog_params> =3D # of args following this one in= tended for
>         the replog (2 or 4)
>         +<replog_params>  =3D <dev_p= ath> <dev_start> [auto/create/open
>       &n= bsp; <size>]
>         +     &nbs= p; <dev_path>  =3D device path of replication log (REPLOG)
&g= t;         backing store
>         +       <dev_start> = =3D offset to REPLOG header
>         +   &n= bsp;   create      =3D The replication log will be init= ialized
>         if not active
>   &n= bsp;     +                = ;     and sized to "size".  (If already
>         active, the create
>     &= nbsp;   +                 &nbs= p;   will fail.)  Size is always in sectors.
>    = ;     +       open        =3D = The replication log must be initialized
>        = and valid or
>         +       &n= bsp;             the constructor will fail. >         +       auto     =    =3D If a valid replication log header is
>    =     found on the
>         +   &n= bsp;                 replication de= vice, this will behave
>         like 'open&#= 39;.
>         +         &nbs= p;           Otherwise, this option behaves like >         'create'.
>     &n= bsp;   +
>         +<slink_type>  = ;  =3D "blockdev" is currently the only available
> &n= bsp;       type
>         +<#sl= ink_params> =3D 1/2/4
>         +<slink_par= ams>  =3D <slink_nr> [<slink_policy> [<fall_behind&g= t;
>         <N>]]
>       &= nbsp; +       <slink_nr>     =3D This is a u= nique number that is used
>         to identify a=
>         +           &= nbsp;            particular site/location. &n= bsp;'0' is
>         always used to
>      = ;   +                   &= nbsp;    identify the local site, while
>     &nb= sp;   increasing integers
>         +  =                     &nbs= p;are used to identify remote sites.
>         + =       <slink_policy> =3D The policy can be either '= ;sync' or
>         'async'.
>     &nb= sp;   +                  =      'sync' means write requests will not
> &= nbsp;       return until
>        = +                     &n= bsp;  the data is on the storage device.
>          'async' allows
>  = ;       +               &= nbsp;        a device to "fall behind"; that = is,
>         outstanding
>     &= nbsp;   +                 &nbs= p;      write requests are waiting in the
>         replication log
>     &nbs= p;   +                   =      to be processed for this site, but it
>   &n= bsp;     is not delaying
>         + &n= bsp;                     =  the writes of other sites.
>         + &nbs= p;     <fall_behind>  =3D This field is used to specif= y how far
>         the user is
>       &= nbsp; +                   &nbs= p;    willing to allow write requests to
>     &n= bsp;   this specific site
>         +  =                     &nbs= p;to "fall behind" in processing before
>         switching to
>       =   +                   &nb= sp;    a 'sync' policy.  This "fall behind"= ;
>         threshhold can
>     =     +                 &nb= sp;      be specified in three ways: ios,
>         size, or timeout.
>     &n= bsp;   +                  = ;      'ios' is the number of pending I/Os
> &= nbsp;       allowed (e.g.
>        = ; +                     &= nbsp;  "ios 10000").  'size' is the amount
>         of pending data
>     &nbs= p;   +                   =      allowed (e.g. "size 200m").  Size
>= ;         labels include:
>       =   +                   &nb= sp;    s (sectors), k, m, g, t, p, and e.
>          'timeout' is
>   =       +               &nb= sp;        the amount of time allowed for writes
>= ;         to be
>         + &= nbsp;                    =  outstanding.  Time labels include: s,
>     &nb= sp;   m, h, and d.
>         +
>         +>         +"replicator-dev" target parame= ters:
>         +--------------------------------= ---
>         +start> <length> replicato= r-dev
>         +       <replic= ator_device> <dev_nr> \
>         +       [<slink_nr> &= lt;#dev_params> <dev_params>
>         +=        <dlog_type> <#dlog_params> <dlog= _params>]{1..N}
>         +
>   &nb= sp;     +<replicator_device> =3D device previously construc= ted via
>         "replication" target
> &nb= sp;       +<dev_nr>          = =3D An integer that is used to 'tag' write
>     &= nbsp;   requests as
>         +    = ;                 belonging to a pa= rticular set of devices
>         - specifically,
>     &nbs= p;   +                   =   the devices that follow this argument
>       &= nbsp; (i.e. the site
>         +     &n= bsp;               link devices).
>= ;         +<slink_nr>        = =3D This number identifies the site/location
>         where the next
>      = ;   +                   &= nbsp; device to be specified comes from.  It
>     &nb= sp;   is exactly the
>         +   &nbs= p;                 same number used= to identify the
>         site/location (and its=
>         +            = ;         policies) in the "replicator" targe= t.
>          Interestingly,
>   =       +               &nb= sp;     while one might normally expect a
>     &= nbsp;   "dev_type" argument
>         +            = ;         here, it can be deduced from the site
>=         link number and
>       &= nbsp; +                   &nbs= p; the 'slink_type' given in the
>        = ; "replication" target.
>         +<#dev_params>      = =3D '1'  (The number of allowed parameters
>   &nbs= p;     actually depends
>         + &nb= sp;                   on the &= #39;slink_type' given in the
>         "= replication" target.
>         +            = ;         Since our only option there is
>  =       "blockdev", the only
>     =     +                 &nb= sp;   allowable number here is currently '1'.)
>   =       +<dev_params>       =3D 'dev_= path'  (Again, since "blockdev" is
>         the only
>       &nbs= p; +                     = 'slink_type' available, the only
>        = ; allowable argument here
>         +   &nbs= p;                 is the path to t= he device.)
>         +<dlog_type>   &= nbsp;    =3D Not to be confused with the "replicator
>         log", this is
>     &= nbsp;   +                 &nbs= p;   the type of dirty log associated with
>      = ;   this particular
>         +    = ;                 device.  Dir= ty logs are used for
>         synchronization, d= uring
>         +            = ;         initialization or fall behind
>   =       conditions, to bring devices
>     &nb= sp;   +                  =   into a coherent state with its peers -
>      =   analogous to
>         +     &n= bsp;               rebuilding a RAID1 (m= irror) device.
>          Available dirty
>    = ;     +                 &= nbsp;   log types include: 'nolog', 'core', and
>= ;         'disk'
>       &= nbsp; +<#dlog_params>     =3D The number of arguments requi= red for a
>         particular log
>      = ;   +                   &= nbsp; type - 'nolog' =3D 0, 'core' =3D 1/2, 'disk'<= br>>         =3D 2/3.
>       &= nbsp; +<dlog_params>      =3D 'nolog' =3D> = ~no arguments~
>         +            = ;         'core'  =3D> <region_size&= gt; [sync | nosync]
>         +     &nb= sp;               'disk'  = =3D> <dlog_dev_path> <region_size>
>     &nb= sp;   [sync | nosync]
>         +       <region_size>=   =3D This sets the granularity at which
>      =   the dirty log
>         +     &= nbsp;                   tracks= what areas of the device is
>         in-sync.>         +       [sync | nosync] = =3D Optionally specify whether the sync
>         should be forced
>     &nb= sp;   +                  =       or avoided initially.
>       &n= bsp; diff --git 2.6.33-rc1.orig/drivers/md/Kconfig
>     &n= bsp;   2.6.33-rc1/drivers/md/Kconfig
>       &nbs= p; 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 "Repl= ication target (EXPERIMENTAL)"
>         + &= nbsp;     depends on BLK_DEV_DM && EXPERIMENTAL
> &= nbsp;       +       ---help---
>  =       +       A target that supports replica= tion of local devices to
>         remote sites.
>      =   +
>         +       If uns= ure, say N.
>         +
>     &nb= sp;    config DM_UEVENT
>          = ;      bool "DM uevents (EXPERIMENTAL)"
> &n= bsp;              depends on BLK_DEV_DM = && EXPERIMENTAL
>         diff --git 2.6.33-rc1.orig/drivers/md/Make= file
>         2.6.33-rc1/drivers/md/Makefile
= >         index e355e7f..be05b39 100644
> &nbs= p;       --- 2.6.33-rc1.orig/drivers/md/Makefile
> &nb= sp;       +++ 2.6.33-rc1/drivers/md/Makefile
>         @@ -44,6 +44,7 @@ obj-$(CONFIG_DM_SNAPSHOT= )     +=3D
>         dm-snapshot.o
&= gt;          obj-$(CONFIG_DM_MIRROR)    =            +=3D dm-mirror.o
>   &= nbsp;     dm-log.o dm-region-hash.o
>       =    obj-$(CONFIG_DM_LOG_USERSPACE) +=3D dm-log-userspace.o
>          obj-$(CONFIG_DM_ZERO)     =      +=3D dm-zero.o
>         +obj= -$(CONFIG_DM_REPLICATOR)    +=3D dm-log.o dm-registry.o
>>          quiet_cmd_unroll =3D UNROLL  = $@
>               cmd_unroll =3D = $(AWK) -f$(srctree)/$(src)/unroll.awk -vN=3D
>         $(UNROLL) \
>       &= nbsp; diff --git 2.6.33-rc1.orig/drivers/md/dm-registry.c
>   &n= bsp;     2.6.33-rc1/drivers/md/dm-registry.c
>    = ;     new file mode 100644
>         in= dex 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)
>   &nbs= p;     + *
>         + * Generic regist= ry for arbitrary structures
>         + * (needs = dm_registry_type structure upfront each registered
>         structure).
>       &= nbsp; + *
>         + * This file is released und= er the GPL.
>         + *
>     &= nbsp;   + * FIXME: use as registry for e.g. dirty log types as well.>         + */
>         +
>         +#in= clude <linux/init.h>
>         +#include &l= t;linux/module.h>
>         +#include <linu= x/moduleparam.h>
>         +
>   &n= bsp;     +#include "dm-registry.h"
>         +
>         +#de= fine        DM_MSG_PREFIX   "dm-registry"= ;
>         +
>        = +static const char *version =3D "0.001";
>     &= nbsp;   +
>         +/* Sizable class regist= ry. */
>         +static unsigned num_classes;
> &nbs= p;       +static struct list_head *_classes;
>   =       +static rwlock_t *_locks;
>      =   +
>         +void *
>    =     +dm_get_type(const char *type_name, enum dm_registry_class >         class)
>        = +{
>         +       struct dm_re= gistry_type *t;
>         +
>    =     +       read_lock(_locks + class);
> &n= bsp;       +       list_for_each_entry(t, _cl= asses + class, list) {
>         +            = ;   if (!strcmp(type_name, t->name)) {
>      =   +                   &n= bsp;   if (!t->use_count && !
>       =   try_module_get(t->module)) {
>         = +                     &nb= sp;         read_unlock(_locks + class);
>         +            = ;                   return ERR= _PTR(-ENOMEM);
>         +       &= nbsp;               }
>   &nb= sp;     +
>         +     &nb= sp;                 t->use_count= ++;
>         +          = ;             read_unlock(_locks + class); >         +            = ;           return t;
>      =   +               }
>  =       +       }
>      =   +
>         +       read_u= nlock(_locks + class);
>         +     =   return ERR_PTR(-ENOENT);
>         +}
>         +EX= PORT_SYMBOL(dm_get_type);
>         +
> &nb= sp;       +void
>         +dm_put_= type(void *type, enum dm_registry_class class)
>      =   +{
>         +       struc= t dm_registry_type *t =3D type;
>         +
>         + &n= bsp;     read_lock(_locks + class);
>       =   +       if (!--t->use_count)
>    =     +               module_pu= t(t->module);
>         +
>    = ;     +       read_unlock(_locks + class);
>         +}
>         +EX= PORT_SYMBOL(dm_put_type);
>         +
> &nb= sp;       +/* Add a type to the registry. */
>   =       +int
>         +dm_register_= type(void *type, enum dm_registry_class class)
>         +{
>         + &= nbsp;     struct dm_registry_type *t =3D type, *tt;
>  = ;       +
>         +    = ;   if (unlikely(class >=3D num_classes))
>     &nb= sp;   +               return -EINVA= L;
>         +
>         +       tt =3D dm_get_type(= t->name, class);
>         +     &nb= sp; if (unlikely(!IS_ERR(tt))) {
>         + &nbs= p;             dm_put_type(t, class);
>=         +             &n= bsp; return -EEXIST;
>         +     &n= bsp; }
>         +
>         + &n= bsp;     write_lock(_locks + class);
>      =   +       t->use_count =3D 0;
>    =     +       list_add(&t->list, _classes + = class);
>         +       write_un= lock(_locks + class);
>         +
>         + &n= bsp;     return 0;
>         +}
>=         +EXPORT_SYMBOL(dm_register_type);
> &nbs= p;       +
>         +/* Remove a = type from the registry. */
>         +int
>=         +dm_unregister_type(void *type, enum dm_regist= ry_class class)
>         +{
>         + &= nbsp;     struct dm_registry_type *t =3D type;
>   &nb= sp;     +
>         +     &nb= sp; if (unlikely(class >=3D num_classes)) {
>      =   +               DMERR("Atte= mpt to unregister invalid class");
>         +            = ;   return -EINVAL;
>         +    = ;   }
>         +
>     &nbs= p;   +       write_lock(_locks + class);
>  =       +
>         +    =   if (unlikely(t->use_count)) {
>        = ; +               write_unlock(_locks + = class);
>         +            = ;   DMWARN("Attempt to unregister a type that is
>   &= nbsp;     still in use");
>        = ; +               return -ETXTBSY;
&g= t;         +       } else
>  =       +               li= st_del(&t->list);
>         +
>         + &n= bsp;     write_unlock(_locks + class);
>     &nbs= p;   +       return 0;
>       &nb= sp; +}
>         +EXPORT_SYMBOL(dm_unregister_typ= e);
>         +
>       &nbs= p; +/*
>         + * Return kmalloc'ed NULL t= erminated pointer
>         + * array of all type names of the given c= lass.
>         + *
>       =   + * Caller has to kfree the array!.
>       &nb= sp; + */
>         +const char **dm_types_list(en= um dm_registry_class class)
>         +{
>         + &= nbsp;     unsigned i =3D 0, count =3D 0;
>     &n= bsp;   +       const char **r;
>     &n= bsp;   +       struct dm_registry_type *t;
> &nbs= p;       +
>         +   &nbs= p;   /* 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)
>         +       &n= bsp;       return NULL;
>         = +
>         +       /* One member = more for array NULL termination. */
>         +       r =3D kzalloc((coun= t + 1) * sizeof(*r), GFP_KERNEL);
>         + &nb= sp;     if (!r)
>         +   &nbs= p;           return ERR_PTR(-ENOMEM);
> &nbs= p;       +
>         +   &nbs= p;   /*
>         +       &nb= sp;* Go with the counted ones.
>         +        * Any new add= ed ones after we counted will be
>         ignore= d!
>         +        */
&= gt;         +       read_lock(_locks + c= lass);
>         +       list_for_= each_entry(t, _classes + class, list) {
>         +            = ;   r[i++] =3D t->name;
>         +  = ;             if (!--count)
>   &n= bsp;     +                = ;       break;
>         +   =     }
>         +       = read_unlock(_locks + class);
>         +
>         + &n= bsp;     return r;
>         +}
>=         +EXPORT_SYMBOL(dm_types_list);
>   =       +
>         +int __init
&= gt;         +dm_registry_init(void)
>   &nbs= p;     +{
>         +       unsigned n;
>=         +
>         +  =     BUG_ON(_classes);
>         + &nbs= p;     BUG_ON(_locks);
>         +
&= gt;         +       /* Module parameter = given ? */
>         +       if (!= num_classes)
>         +            = ;   num_classes =3D DM_REGISTRY_CLASS_END;
>      = ;   +
>         +       n =3D= num_classes;
>         +       _c= lasses =3D kmalloc(n * sizeof(*_classes), GFP_KERNEL);
>    = ;     +       if (!_classes) {
>         +            = ;   DMERR("Failed to allocate classes registry");
> &n= bsp;       +              = ; return -ENOMEM;
>         +      = ; }
>         +
>       &nbs= p; +       _locks =3D kmalloc(n * sizeof(*_locks), GFP_KERNE= L);
>         +       if (!_locks) {
&= gt;         +            =   DMERR("Failed to allocate classes locks");
>  =       +               kf= ree(_classes);
>         +       &= nbsp;       _classes =3D NULL;
>         +            = ;   return -ENOMEM;
>         +    = ;   }
>         +
>     &nbs= p;   +       while (n--) {
>      =   +               INIT_LIST_HEAD(_= classes + n);
>         +       &n= bsp;       rwlock_init(_locks + n);
>         +       }
>   &n= bsp;     +
>         +     &n= bsp; DMINFO("initialized %s for max %u classes", version,
>=         num_classes);
>       &nb= sp; +       return 0;
>         +}=
>         +
>         +void __exit
>       =   +dm_registry_exit(void)
>         +{
&g= t;         +       BUG_ON(!_classes);>         +       BUG_ON(!_locks);>         +
>         + =       kfree(_classes);
>         +       _classes =3D NULL;<= br>>         +       kfree(_locks);>         +       _locks =3D NULL;<= br>>         +       DMINFO("exi= t %s", version);
>         +}
>  =       +
>         +/* Module hook= s */
>         +module_init(dm_registry_init);
> &n= bsp;       +module_exit(dm_registry_exit);
>   &n= bsp;     +module_param(num_classes, uint, 0);
>   &nbs= p;     +MODULE_PARM_DESC(num_classes, "Maximum number of cla= sses");
>         +MODULE_DESCRIPTION(DM_NAME "device-m= apper registry");
>         +MODULE_AUTHOR(&= quot;Heinz Mauelshagen <heinzm@redh= at.com>");
>         +MODULE_LICENSE(= "GPL");
>         +
>         +#if= ndef MODULE
>         +static int __init num_clas= ses_setup(char *str)
>         +{
>   =       +       num_classes =3D simple_strtol(s= tr, NULL, 0);
>         +       re= turn 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/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 @@
> =         +/*
>         + * Cop= yright (C) 2009 Red Hat, Inc. All rights reserved.
>         + *
>         + = * Module Author: Heinz Mauelshagen (he= inzm@redhat.com)
>         + *
>  =       + * Generic registry for arbitrary structures.
>= ;         + * (needs dm_registry_type structure upfront= each registered
>         structure).
>       &= nbsp; + *
>         + * This file is released und= er the GPL.
>         + */
>     =     +
>         +#include "dm.h&qu= ot;
>         +
>       &nbs= p; +#ifndef DM_REGISTRY_H
>         +#define DM_REGISTRY_H
>   &nbs= p;     +
>         +enum dm_registry_cl= ass {
>         +       DM_REPLOG = =3D 0,
>         +       DM_SLINK,=
>         +       DM_LOG,
>=         +       DM_REGION_HASH,
>         +       DM_REGISTRY_CLASS_E= ND,
>         +};
>       &n= bsp; +
>         +struct dm_registry_type {
&g= t;         +       struct list_head list= ;  /* Linked list of types in
>         this= class. */
>         +       const char *name;>         +       struct module *mo= dule;
>         +       unsigned i= nt use_count;
>         +};
>    =     +
>         +void *dm_get_type(con= st char *type_name, enum
>         dm_registry_class class);
>   &= nbsp;     +void dm_put_type(void *type, enum dm_registry_class cl= ass);
>         +int dm_register_type(void *type,= enum dm_registry_class
>         class);
>=         +int dm_unregister_type(void *type, enum dm_re= gistry_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.re= dhat.com/mailman/listinfo/dm-devel
>
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.co= m/mailman/listinfo/dm-devel

--
dm-devel mailing list
d= m-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-de= vel

--0050450294e3693b80047f211d74-- --===============8715731182062541392== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============8715731182062541392==--