freebsd-dev/sys/geom/multipath/g_multipath.h
Alexander Motin 0c883cef45 Major GEOM MULTIPATH class rewrite:
- Improved locking and destruction process to fix crashes.
 - Improved "automatic" configuration method to make it consistent and safe
by reading metadata back from all specified paths after writing to one.
 - Added provider size check to reduce chance of ordering conflict with
other GEOM classes.
 - Added "manual" configuration method without using on-disk metadata.
 - Added "add" and "remove" commands to allow manage paths manually.
 - Failed paths are no longer dropped from geom, but only marked as FAIL
and excluded from I/O operations.
 - Automatically restore failed paths when all others paths are marked
as failed, for example, because of device-caused (not transport) errors.
 - Added "fail" and "restore" commands to manually control FAIL flag.
 - geom is now destroyed on last path disconnection.
 - Added optional Active/Active mode support. Unlike Active/Passive
mode, load evenly distributed between all working paths. If supported by
the device, it allows to significantly improve performance, utilizing
bandwidth of all paths. It is controlled by -A option during creation.
Disabled by default now.
 - Improved `status` and `list` commands output.

Sponsored by:	iXsystems, inc.
MFC after:	1 month
2011-11-12 09:52:27 +00:00

110 lines
3.7 KiB
C

/*-
* 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 * sc_pp;
struct g_consumer * sc_active;
struct mtx sc_mtx;
char sc_name[16];
char sc_uuid[40];
int sc_opened;
int sc_stopping;
int sc_ndisks;
int sc_active_active; /* Active/Active mode */
};
#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 */
uint8_t md_active_active; /* Active/Active mode */
};
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);
data += sizeof(md->md_size);
*data = md->md_active_active;
}
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);
data += sizeof(md->md_size);
md->md_active_active = *data;
}
#endif /* _G_MULTIPATH_H_ */