diff options
author | mjacob <mjacob@FreeBSD.org> | 2007-02-27 04:01:58 +0000 |
---|---|---|
committer | mjacob <mjacob@FreeBSD.org> | 2007-02-27 04:01:58 +0000 |
commit | 05b92097cb751ac3e6ba126eed272f954f9c7210 (patch) | |
tree | 3740487c6f9b60010343610543a779a7e9a63d31 /sys/geom/multipath/g_multipath.h | |
parent | 502eb2ec0e1f3a8e4b78b14ccfaad6822c33bbb6 (diff) | |
download | FreeBSD-src-05b92097cb751ac3e6ba126eed272f954f9c7210.zip FreeBSD-src-05b92097cb751ac3e6ba126eed272f954f9c7210.tar.gz |
First cut at GEOM based multipath. This is an active/passive{/passive...}
arrangement that has no intrinsic internal knowledge of whether devices
it is given are truly multipath devices. As such, this is a simplistic
approach, but still a useful one.
The basic approach is to (at present- this will change soon) use camcontrol
to find likely identical devices and and label the trailing sector of the
first one. This label contains both a full UUID and a name. The name is
what is presented in /dev/multipath, but the UUID is used as a true
distinguishor at g_taste time, thus making sure we don't have chaos
on a shared SAN where everyone names their data multipath as "Fred".
The first of N identical devices (and N *may* be 1!) becomes the active
path until a BIO request is failed with EIO or ENXIO. When this occurs,
the active disk is ripped away and the next in a list is picked to
(retry and) continue with.
During g_taste events new disks that meet the match criteria for existing
multipath geoms get added to the tail end of the list.
Thus, this active/passive setup actually does work for devices which
go away and come back, as do (now) mpt(4) and isp(4) SAN based disks.
There is still a lot to do to improve this- like about 5 of the 12
recommendations I've received about it, but it's been functional enough
for a while that it deserves a broader test base.
Reviewed by: pjd
Sponsored by: IronPort Systems
MFC: 2 months
Diffstat (limited to 'sys/geom/multipath/g_multipath.h')
-rw-r--r-- | sys/geom/multipath/g_multipath.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/sys/geom/multipath/g_multipath.h b/sys/geom/multipath/g_multipath.h new file mode 100644 index 0000000..22d6157 --- /dev/null +++ b/sys/geom/multipath/g_multipath.h @@ -0,0 +1,99 @@ +/*- + * Copyright (c) 2006-2007 Matthew Jacob <mjacob@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ +/* + * Based upon work by Pawel Jakub Dawidek <pjd@FreeBSD.org> for all of the + * fine geom examples, and by Poul Henning Kamp <phk@FreeBSD.org> for GEOM + * itself, all of which is most gratefully acknowledged. + */ + +#ifndef _G_MULTIPATH_H_ +#define _G_MULTIPATH_H_ + +#define G_MULTIPATH_CLASS_NAME "MULTIPATH" +#define G_MULTIPATH_VERSION 1 +#define G_MULTIPATH_MAGIC "GEOM::MULTIPATH" + +#include <sys/endian.h> + +#ifdef _KERNEL + +struct g_multipath_softc { + struct g_provider * pp; + struct g_consumer * cp_active; + char sc_name[16]; + char sc_uuid[40]; +}; +#endif /* _KERNEL */ + +struct g_multipath_metadata { + char md_magic[16]; /* Magic Value */ + char md_uuid[40]; /* more magic */ + char md_name[16]; /* a friendly name */ + uint32_t md_version; /* version */ + uint32_t md_sectorsize; /* sectorsize of provider */ + uint64_t md_size; /* absolute size of provider */ +}; + +static __inline void +multipath_metadata_encode(const struct g_multipath_metadata *, u_char *); + +static __inline void +multipath_metadata_decode(u_char *, struct g_multipath_metadata *); + +static __inline void +multipath_metadata_encode(const struct g_multipath_metadata *md, u_char *data) +{ + bcopy(md->md_magic, data, sizeof(md->md_magic)); + data += sizeof(md->md_magic); + bcopy(md->md_uuid, data, sizeof(md->md_uuid)); + data += sizeof(md->md_uuid); + bcopy(md->md_name, data, sizeof(md->md_name)); + data += sizeof(md->md_name); + le32enc(data, md->md_version); + data += sizeof(md->md_version); + le32enc(data, md->md_sectorsize); + data += sizeof(md->md_sectorsize); + le64enc(data, md->md_size); +} + +static __inline void +multipath_metadata_decode(u_char *data, struct g_multipath_metadata *md) +{ + bcopy(data, md->md_magic, sizeof(md->md_magic)); + data += sizeof(md->md_magic); + bcopy(data, md->md_uuid, sizeof(md->md_uuid)); + data += sizeof(md->md_uuid); + bcopy(data, md->md_name, sizeof(md->md_name)); + data += sizeof(md->md_name); + md->md_version = le32dec(data); + data += sizeof(md->md_version); + md->md_sectorsize = le32dec(data); + data += sizeof(md->md_sectorsize); + md->md_size = le64dec(data); +} +#endif /* _G_MULTIPATH_H_ */ |