fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _RDC_IO_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _RDC_IO_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DS_DDICT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define bool_t int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_prot.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_ioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Definitions for kstats
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_MAXSETS "maxsets"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_MAXFBAS "maxfbas"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_RPC_TIMEOUT "rpc_timeout"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_HEALTH_THRES "health_thres"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_BITMAP_WRITES "bitmap_writes"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_CLNT_COTS_CALLS "clnt_cots_calls"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_CLNT_CLTS_CALLS "clnt_clts_calls"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_SVC_COTS_CALLS "svc_cots_calls"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_SVC_CLTS_CALLS "svc_clts_calls"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MKSTAT_BITMAP_REF_DELAY "bitmap_ref_delay"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_FLAGS "flags"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_SYNCFLAGS "syncflags"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_BMPFLAGS "bmpflags"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_SYNCPOS "syncpos"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_VOLSIZE "volsize"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_BITSSET "bitsset"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_AUTOSYNC "autosync"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_MAXQFBAS "maxqfbas"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_MAXQITEMS "maxqitems"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_FILE "primary_vol"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_SECFILE "secondary_vol"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_BITMAP "bitmap"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_PRIMARY_HOST "primary_host"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_SECONDARY_HOST "secondary_host"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_TYPE_FLAG "type_flag"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_BMP_SIZE "bmp_size"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_DISK_STATUS "disk_status"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_IF_DOWN "if_down"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_IF_RPC_VERSION "if_rpc_version"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_ASYNC_THROTTLE_DELAY "async_throttle_delay"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_ASYNC_BLOCK_HWM "async_block_hwm"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_ASYNC_ITEM_HWM "async_item_hwm"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_QUEUE_TYPE "async_queue_type"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_ASYNC_ITEMS "async_queue_items"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IKSTAT_ASYNC_BLOCKS "async_queue_blocks"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Queue types
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_DISKQUE 0X01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MEMQUE 0x02
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_NOQUE -1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_ACTIVE 0x1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_INACTIVE 0x2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _KERNEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nstset_t *_rdc_ioset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nstset_t *_rdc_flset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int RDC_MAX_SYNC_THREADS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_maxthreads_last;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint num_sync_threads;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MAX_SYNC_THREADS 8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_AVAIL_THR_TUNE(n) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_maxthreads_last < RDC_MAX_SYNC_THREADS) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) nst_add_thread(n.rdc_syncset, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_MAX_SYNC_THREADS - rdc_maxthreads_last);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_maxthreads_last > RDC_MAX_SYNC_THREADS) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) nst_del_thread(n.rdc_syncset, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_maxthreads_last - RDC_MAX_SYNC_THREADS); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n.avail_thr = RDC_MAX_SYNC_THREADS - n.active_thr; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n.avail_thr < 0) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n.avail_thr = 0; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_maxthreads_last = RDC_MAX_SYNC_THREADS; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_sync_threads = nst_nthread(n.rdc_syncset); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_AVAIL_THR_TUNE(n) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n.avail_thr = RDC_MAX_SYNC_THREADS - n.active_thr; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n.avail_thr < 0) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n.avail_thr = 0; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct syncloop_info {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int active_thr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int avail_thr; /* should be MAX_RDC_SYNC_THREADS - active */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nstset_t *rdc_syncset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} sync_info_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesync_info_t sync_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Static server information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct servinfo {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct knetconfig *ri_knconf; /* bound TLI fd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct netbuf ri_addr; /* server's address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sec_data *ri_secdata; /* sec data for rpcsec module */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ri_hostname; /* server's hostname */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ri_hostnamelen; /* server's hostname length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_srv_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interface structure, including health monitoring.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_if_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_if_s *next; /* chain pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct netbuf ifaddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct netbuf r_ifaddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_srv_t *srv; /* servinfo of server end */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int if_down; /* i/f is down (set on primary) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int isprimary; /* this end is a primary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int issecondary; /* this end is a secondary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rpcvers_t rpc_version; /* RPC protocol version in use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int no_ping; /* set on secondary to hold off RPCs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int old_pulse; /* previous (current) pulse value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int new_pulse; /* new (incoming) pulse value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int deadness; /* how close to death are we? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int exiting; /* daemon exit flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte time_t last; /* time of last ping */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_if_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_aio_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_aio_s *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_buf_t *handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_buf_t *qhandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t pos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t qpos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t orig_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int iostatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t seq; /* sequence on async Q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_aio_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* values for (rdc_aio_t *)->iostatus */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteenum {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IO_NONE = 0, /* not used */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IO_INIT, /* io started */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IO_DONE, /* io done successfully */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IO_FAILED, /* io failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IO_DISCARDED, /* io discarded */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IO_CANCELLED /* group_log in progress */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MAX_QBLOCKS 16384 /* 8MB temporary q for diskq to flush to */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_LOW_QBLOCKS 13927 /* roughly 85% of queue full */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_HALF_MQUEUE 8192 /* half of the memory queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct netqueue {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_aio_t *net_qhead;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_aio_t *net_qtail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t net_qlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int hwmhit; /* queue full hit? reset after hwm */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int qfill_sleeping; /* waiting for work? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int qfflags; /* diskq/memq flusher flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t qfcv; /* for timed waits */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile nsc_size_t blocks; /* number of FBAs in q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uint64_t nitems; /* number of items in q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int inflbls; /* number of inflight blocks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int inflitems; /* number of inflight items */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t nitems_hwm; /* highest items on queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t blocks_hwm; /* highest blocks on queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte long throttle_delay; /* Number of times we delayed x 2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} net_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bitmap header structures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These must be fixed size in all data models.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we ever support little-endian machines (eg. Intel) we will need
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to add byte-swapping logic.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t magic;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t serial_mode;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t use_mirror;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t mirror_down;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t sync_needed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char bitmapname[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char filename[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t volume_failed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_headerv2_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_HDR_V2 0x52444302 /* RDC2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_SYNC 0x1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_REV_SYNC 0x2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_FULL_SYNC 0x3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_FAILED 0x1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_COMPLETED 0x2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char file[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char bitmap[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_hdr_addr_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t magic;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_hdr_addr_t primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_hdr_addr_t secondary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t autosync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t maxqfbas;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t maxqitems;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t syshostid; /* for cluster bitmaps */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_headerv3_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_HDR_V3 0x52444303 /* RDC3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t magic;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_hdr_addr_t primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_hdr_addr_t secondary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t autosync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t maxqfbas;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t maxqitems;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t syshostid; /* for cluster bitmaps */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t asyncthr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_headerv4_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_HDR_V4 0x52444304 /* RDC4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t magic;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_hdr_addr_t primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_hdr_addr_t secondary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t autosync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int64_t maxqfbas;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int64_t maxqitems;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t syshostid; /* for cluster bitmaps */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t asyncthr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t refcntsize; /* size in bytes of each refcount */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_headerv5_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_HDR_V5 0x52444305 /* RDC5 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef rdc_headerv5_t rdc_header_t; /* Current header type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_HDR_MAGIC RDC_HDR_V5 /* Current header magic number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_BITMAP_FBA 1 /* Offset at which the bitmap starts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_BITREF_FBA(krdc) (RDC_BITMAP_FBA + FBA_LEN(krdc->bitmap_size))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _KERNEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_FUTILE_ATTEMPTS 50
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct aio_buf_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct aio_buf_s *next; /* next aio_buf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_buf_t *rdc_abufp; /* actual anon buf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int kindex; /* index we are attached to */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} aio_buf_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_thrsync {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int threads;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int complete;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t cv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_thrsync_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct sync_status_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sync_status_s *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} sync_status_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_syncthr {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_k_info *krdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_status_t *status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_syncthr_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC buffer header
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_buf_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_buf_t rdc_bufh; /* exported buffer header */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_buf_t *rdc_bufp; /* underlying buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aio_buf_t *rdc_anon; /* ANON async buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_fd_s *rdc_fd; /* back link */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t rdc_vsize; /* size of allocated nsc_vec_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rdc_flags; /* flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t aio_lock; /* lock for rdc_anon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_thrsync_t rdc_sync; /* for thread syncronization */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_buf_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_VEC_ALLOC 0x1 /* local kmem vector for remote io */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_ALLOC 0x2 /* rdc_bufp is nsc_buf_alloc'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_ASYNC_VEC 0x4 /* Keep tmp handle for async flusher */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_REMOTE_BUF 0x8 /* buffer alloc'd for remote io only */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_NULL_BUF 0x10 /* tell diskq to only store io_hdr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_ASYNC_BUF 0x20 /* this buf is to an async vol */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_NULLBUFREAD 0x0f000000 /* read because RDC_NULL_BUF detected */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define BUF_IS_ASYNC(h) (((h) != NULL) && (h)->rdc_flags & RDC_ASYNC_BUF)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_REMOTE(h) (((h) != NULL) && ((h)->rdc_flags & RDC_REMOTE_BUF) && \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((h)->rdc_flags & RDC_ASYNC_VEC) == 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* check a handle against a supplied pos/len pair */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_HANDLE_LIMITS(h, p, l) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((h)->sb_user & RDC_DISKQUE) || \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((p) >= (h)->sb_pos) && \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((p) + (l)) <= ((h)->sb_pos + (h)->sb_len)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* check a dset against a supplied pos/len pair */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_DSET_LIMITS(d, p, l) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((p) >= (d)->pos) && \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((p) + (l)) <= ((d)->pos + (d)->fbalen)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC device info structures
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _rdc_info_dev_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_fd_t *bi_fd; /* file descriptor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_iodev_t *bi_iodev; /* I/O device structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_k_info *bi_krdc; /* back link */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bi_rsrv; /* Count of reserves held */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bi_orsrv; /* Reserves for other io provider */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bi_failed; /* Count of failed (faked) reserves */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bi_ofailed; /* Other io provider failed reserves */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bi_flag; /* Reserve flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} _rdc_info_dev_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_info_dev_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_info_dev_s *id_next; /* forward link */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _rdc_info_dev_t id_cache_dev; /* cached device info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _rdc_info_dev_t id_raw_dev; /* raw device info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t id_rlock; /* reserve/release lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t id_rcv; /* nsc_release pending cv */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int id_sets; /* # of sets referencing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int id_release; /* # of pending nsc_releases */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int id_flag; /* flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_info_dev_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_path_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_path_t *rp_tok; /* nsc_register_path token */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rp_ref; /* # of rdc_fd_t's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_path_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Values for id_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_ID_CLOSING 0x1 /* device is closing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_diskq.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * value for diskio.seq.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_NOSEQ (0) /* ignore sequence */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_NEWSEQ (1) /* start of sequence */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_sleepq {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_sleepq *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t seq; /* sequence in queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int idx; /* idx number of request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pindex; /* primary host set index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sindex; /* secondary host set index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t qpos; /* offset on primary's queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int nocache; /* cache flag to alloc_buf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_sleepq_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC group structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_group {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rdc_writer;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int unregistering;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte net_queue ra_queue; /* io todo async queues */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t iowaitcv; /* wait for flusher */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t unregistercv; /* wait for unregister */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rdc_thrnum; /* number of threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rdc_addthrnum; /* number threads added to thr set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t addthrnumlk; /* lock for above */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_sleepq_t *sleepq; /* head of waiting tasks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dual use, the outgoing sequence number on the client.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The next expected sequence number on the server.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Protected by the ra_queue lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t seq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dual use, the last acknowledged sequence number.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Used to ensure that the queue doesn't overflow on server
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and to stall transmissions on the client.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Protected by the ra_queue lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t seqack;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int asyncstall; /* count of asleep threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int asyncdis; /* discard stalled output */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t asyncqcv; /* output stall here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flags; /* memory or disk. status etc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte disk_queue diskq; /* disk queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_fd_t *diskqfd; /* diskq handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_path_t *q_tok; /* q registration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int diskqrsrv; /* reserve count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t diskqmutex; /* enables/disables/reserves */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t synccount; /* number of group members syncing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_group_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* group state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_DISKQ_KILL 0x01 /* a force kill of diskq pending */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IS_DISKQ(grp) (grp->flags & RDC_DISKQUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IS_MEMQ(grp) (grp->flags & RDC_MEMQUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These flags are used in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * aux_state field, and are used to track:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * AUXSYNCIP: When the code has a sync thread running, used instead
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of the RC_SYNCING flag which gets cleared before the sync thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * terminates.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * AUXWRITE: Set when rdc_sync_write_thr is running, so the rdc_unintercept
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * code can wait until a one-to-many write has actually terminated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_AUXSYNCIP 0x01 /* a sync is in progress */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_AUXWRITE 0x02 /* I've got a write in progress */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC kernel-private information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_k_info {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int index; /* Index into array */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int remote_index; /* -1 means unknown */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int type_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rpc_version; /* RPC version this set supps */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int spare1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t syncbitpos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t syncbitmutex; /* lock for syncbitpos */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int busy_count; /* ioctls in progress */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int sync_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int aux_state; /* syncing ,don't disable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_thrsync_t syncs; /* _rdc_sync thread tracking */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_info_dev_t *devices;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_iodev_t *iodev; /* I/O device structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_path_t cache_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_path_t raw_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_if_t *intf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_srv_t *lsrv; /* list of servinfo */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t maxfbas; /* returned from nsc_maxfbas */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *dcio_bitmap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *bitmap_ref; /* Incore bitmap bit ref */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_group *group;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t bitmap_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bmaprsrv; /* bitmap reserve count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bitmap_write;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_fd_t *bitmapfd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_fd_t *remote_fd; /* FCAL direct io */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int disk_status; /* set to halt sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int closing;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_path_t *b_tok; /* Bitmap registration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int b_ref;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t dc_sleep;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t bmapmutex; /* mutex for bitmap ops */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t busycv; /* wait for ioctl to complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t closingcv; /* unregister_path/close */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t haltcv; /* wait for sync to halt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t synccv; /* wait for sync to halt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_net_dataset *net_dataset; /* replaces hnds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int64_t io_time; /* moved from cd_info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_k_info *many_next; /* 1-to-many circular list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_k_info *multi_next; /* to multihop krdc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_k_info *group_next; /* group circular list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *io_kstats; /* io kstat */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *bmp_kstats; /* bitmap io kstat */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *set_kstats; /* set kstat */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t kstat_mutex; /* mutex for kstats */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t bmp_kstat_mutex; /* mutex for kstats */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct bm_ref_ops *bm_refs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_k_info_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define c_fd devices->id_cache_dev.bi_fd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define c_rsrv devices->id_cache_dev.bi_rsrv
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define c_failed devices->id_cache_dev.bi_failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define c_flag devices->id_cache_dev.bi_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define c_tok cache_path.rp_tok
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define c_ref cache_path.rp_ref
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define r_fd devices->id_raw_dev.bi_fd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define r_rsrv devices->id_raw_dev.bi_rsrv
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define r_failed devices->id_raw_dev.bi_failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define r_flag devices->id_raw_dev.bi_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define r_tok raw_path.rp_tok
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define r_ref raw_path.rp_ref
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags for _rdc_rsrv_devs()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which device(s) to reserve - integer bitmap.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_CACHE 0x1 /* data device in cache mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RAW 0x2 /* data device in raw mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_BMP 0x4 /* bitmap device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_QUE 0x8 /* diskq device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * device usage after reserve - integer flag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_INTERNAL 0x1 /* reserve for rdc internal purposes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_EXTERNAL 0x2 /* reserve in response to io provider Attach */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Utility macro for nsc_*() io function returns.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_SUCCESS(rc) (((rc) == NSC_DONE) || ((rc) == NSC_HIT))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC file descriptor structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_fd_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_k_info_t *rdc_info; /* devices info structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rdc_type; /* open type, diskq or bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rdc_oflags; /* raw or cached open type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_fd_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fd and rsrv macros
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RSRV(bi) (((bi)->bi_rsrv > 0) || ((bi)->bi_failed > 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ORSRV(bi) (((bi)->bi_orsrv > 0) || ((bi)->bi_ofailed > 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RFAILED(bi) (((bi)->bi_failed > 0) || ((bi)->bi_ofailed > 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_RSRV(bi) (RSRV(bi) || ORSRV(bi))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_CRSRV(gcd) (IS_RSRV(&(gcd)->devices->id_cache_dev))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_RRSRV(gcd) (IS_RSRV(&(gcd)->devices->id_raw_dev))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_RFAILED(gcd) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (RFAILED(&(gcd)->devices->id_cache_dev) || \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RFAILED(&(gcd)->devices->id_raw_dev))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IS_BMP(rdc) ((rdc)->rdc_type == RDC_BMP)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IS_QUE(rdc) ((rdc)->rdc_type == RDC_QUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_IS_RAW(rdc) (((rdc)->rdc_oflags & NSC_CACHE) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_U_FD(gcd) (IS_CRSRV(gcd) ? (gcd)->c_fd : (gcd)->r_fd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_FD(rdc) (RDC_U_FD(rdc->rdc_info))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_host_u {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *nodename;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int netaddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct netbuf *naddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_host_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reply from remote read
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - convenience defines for the client side code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - keep this in sync with the readres structure in rdc_prot.h/.x
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define rdcrdresult readres
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define rr_status status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define rr_ok readres_u.reply
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define rr_bufsize rr_ok.data.data_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define rr_data rr_ok.data.data_val
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Flags for remote read rpc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _START must be a unique rpc, _DATA and _END may be OR-d together.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RREAD_DATA 0x1 /* Intermediate rpc with data payload */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RREAD_START 0x2 /* Setup rpc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RREAD_END 0x4 /* End rpc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RREAD_FAIL 0x8 /* Primary is failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Flags for remote write rpc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RWRITE_FAIL 0x8 /* Primary is failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * macro used to determine if the incomming sq, with sequence
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * value x, should be placed before the sq with sequence value y.
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins * This has to account for integer wrap. We account for integer
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins * wrap by checking if the difference between x and y is within
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins * half of the maximum integer value (RDC_MAXINT) or not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins#define RDC_BITSPERBYTE 8
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins#define RDC_BITS(type) (RDC_BITSPERBYTE * (long)sizeof (type))
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins#define RDC_HIBITI ((unsigned)1 << (RDC_BITS(int) - 1))
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins#define RDC_MAXINT ((int)(~RDC_HIBITI))
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins#define RDC_RANGE ((RDC_MAXINT / 2) -1)
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins#define RDC_INFRONT(x, y) (((x < y) && ((y - x) < RDC_RANGE)) ? 1 : \
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins ((x > y) && ((x - y) > RDC_RANGE)) ? 1 : 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC user-visible information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef rdc_set_t rdc_u_info_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC flags for set state / set cd RPC.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must remain compatible with rdc RPC protocol version v3.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CCIO_NONE 0x0000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CCIO_ENABLE 0x0008
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CCIO_SLAVE 0x0010
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CCIO_DONE 0x0020
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CCIO_ENABLELOG 0x0100
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CCIO_RSYNC 0x0400
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CCIO_REMOTE 0x2000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * In kernel type flags (krdc->type_flag).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_CONFIGURED 0x1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_DISABLEPEND 0x2 /* Suspend/Disable is in progress */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_ASYNCMODE 0x4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RESUMEPEND 0x8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RESPONSIBLE 0x10
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_BUSYWAIT 0x20
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_UNREGISTER 0x40 /* Unregister is in progress */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_QDISABLEPEND 0x100 /* Q Suspend/Disable is in progress */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_ENABLED(urdc) ((IS_CONFIGURED(&rdc_k_info[(urdc)->index]) && \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rdc_get_vflags(urdc) & RDC_ENABLED)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_CONFIGURED(krdc) ((krdc)->type_flag & RDC_CONFIGURED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_MANY(krdc) ((krdc)->many_next != (krdc))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_MULTI(krdc) ((krdc)->multi_next != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_VALID_INDEX(index) ((index) >= 0 && (index) < rdc_max_sets && \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IS_CONFIGURED(&rdc_k_info[(index)]))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_NOFLUSH 0 /* Do not do a flush when starting logging */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_NOREMOTE 0 /* Do no remote logging notifications */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_FLUSH 1 /* Do a flush when starting logging */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_ALLREMOTE 2 /* Notify all remote group members */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_OTHERREMOTE 4 /* Notify all remote group members except */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the one corresponding to the current set, */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* to prevent recursion in the case where */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the request was initiated from the remote */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* node. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_FORCE_GROUP 8 /* set all group memebers logging regardless */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _KERNEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Functions, vars
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_SYNC_EVENT_TIMEOUT (60 * HZ)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t lbolt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int event;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ack;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int daemon_waiting; /* Daemon waiting in ioctl */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int kernel_waiting; /* Kernel waiting for daemon to reply */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char master[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char group[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t cv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t done_cv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_sync_event_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern rdc_sync_event_t rdc_sync_event;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern clock_t rdc_sync_event_timeout;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern kmutex_t rdc_sync_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern rdc_u_info_t *rdc_u_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern rdc_k_info_t *rdc_k_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_max_sets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern unsigned long rdc_async_timeout;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_self_host();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint64_t mirror_getsize(int index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_sleepqdiscard(rdc_group_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_stallzero(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct rdc_net_dataitem {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *dptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len; /* byte count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mlen; /* actual malloced size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_net_dataitem *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_net_dataitem rdc_net_dataitem_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct rdc_net_dataset {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int inuse;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int delpend;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int nitems;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t pos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t fbalen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_net_dataitem_t *head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_net_dataitem_t *tail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rdc_net_dataset *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct rdc_net_dataset rdc_net_dataset_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_TCP_DEV "/dev/tcp"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_VERS_MIN RDC_VERSION5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_VERS_MAX RDC_VERSION7
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_HEALTH_THRESHOLD 20
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MIN_HEALTH_THRES 5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SNDR_MAXTHREADS 16
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These next two defines are the default value of the async queue size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * They have been calculated to be 8MB of data with an average of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2K IO size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MAXTHRES_QUEUE 16384 /* max # of fbas on async q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MAX_QITEMS 4096 /* max # of items on async q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_ASYNCTHR 2 /* number of async threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_RPC_MAX (RDC_MAXDATA + sizeof (net_data5) +\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (RPC_MAXDATASIZE - 8192))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ATM_NONE 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ATM_INIT 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ATM_EXIT 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_CLNT_TMOUT 16
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define BMAP_BLKSIZE 1024
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define BMAP_BLKSIZEV7 RDC_MAXDATA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* right now we can only trace 1m or less writes to the bitmap (32 bits wide) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_MAX_MAXFBAS 2048
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(_KERNEL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* kstat interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Per module kstats
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only one instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_maxsets; /* Max # of sndr sets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_maxfbas; /* Max # of FBAS from nsctl */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_rpc_timeout; /* global RPC timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_health_thres; /* Health thread timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_bitmap_writes; /* True for bitmap writes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_clnt_cots_calls; /* # of clnt COTS calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_clnt_clts_calls; /* # of clnt CLTS calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_svc_cots_calls; /* # of server COTS calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_svc_clts_calls; /* # of server CLTS calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t m_bitmap_ref_delay; /* # of bitmap ref overflows */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} sndr_m_stats_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Per set kstats
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one instance per configured set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_flags; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_syncflags; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_bmpflags; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_syncpos; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_volsize; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_bits_set; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_autosync; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_maxqfbas; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_maxqitems; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_primary_vol; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_secondary_vol; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_bitmap; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_primary_intf; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_secondary_intf; /* from rdc_set_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_type_flag; /* from rdc_k_info_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_bitmap_size; /* from rdc_k_info_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_disk_status; /* from rdc_k_info_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_if_if_down; /* from rdc_if_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_if_rpc_version; /* from rdc_if_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_aqueue_blk_hwm; /* from rdc_k_info_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_aqueue_itm_hwm; /* from rdc_k_info_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_aqueue_throttle; /* from rdc_k_info_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_aqueue_items;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_aqueue_blocks;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t s_aqueue_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} rdc_info_stats_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _SunOS_5_6 /* i.e. 2.7+ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef int xdr_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* i.e. 2.6- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef unsigned long rpcprog_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef unsigned long rpcvers_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef unsigned long rpcproc_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef unsigned long rpcprot_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef unsigned long rpcport_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SunOS_5_6 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _KERNEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nsc_size_t MAX_RDC_FBAS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern volatile int net_exit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nsc_size_t rdc_maxthres_queue; /* max # of fbas on async q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_max_qitems; /* max # of items on async q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_asyncthr; /* # of async threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern kmutex_t rdc_cntlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_datasetcnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Macro to keep tabs on dataset memory usage.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_DSMEMUSE(x) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&rdc_cntlock);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_datasetcnt += (x);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&rdc_cntlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_DSMEMUSE(x)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern kmutex_t rdc_ping_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern rdc_if_t *rdc_if_top;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_enqueue_write(rdc_k_info_t *, nsc_off_t, nsc_size_t, int,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_buf_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_net_state(int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_net_getbmap(int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_net_getsize(int, uint64_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_net_write(int, int, nsc_buf_t *, nsc_off_t, nsc_size_t, uint_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int, netwriteres *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_net_read(int, int, nsc_buf_t *, nsc_off_t, nsc_size_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_remote_read(rdc_k_info_t *, nsc_buf_t *, nsc_off_t, nsc_size_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_multi_write(nsc_buf_t *, nsc_off_t, nsc_size_t, int,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_start_server(struct rdc_svc_args *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern aio_buf_t *rdc_aio_buf_get(rdc_buf_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_aio_buf_del(rdc_buf_t *, rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern aio_buf_t *rdc_aio_buf_add(int, rdc_buf_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_net_getstate(rdc_k_info_t *, int *, int *, int *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern kmutex_t rdc_conf_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern kmutex_t rdc_many_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_drain_queue(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int flush_group_queue(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_dev_close(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_dev_open(rdc_set_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_get_details(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_lookup_bitmap(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_lookup_enabled(char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_lookup_byaddr(rdc_set_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_lookup_byname(rdc_set_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_intercept(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_unintercept(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_rsrv_devs(rdc_k_info_t *, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _rdc_rlse_devs(rdc_k_info_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _rdc_unload(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_load(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_configure(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _rdc_deconfigure(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _rdc_async_throttle(rdc_k_info_t *, long);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_writer(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_dump_alloc_bufs_cd(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_dump_alloc_bufs(rdc_if_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_check_secondary(rdc_if_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_dump_queue(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_isactive_if(struct netbuf *, struct netbuf *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern rdc_if_t *rdc_add_to_if(rdc_srv_t *, struct netbuf *, struct netbuf *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_remove_from_if(rdc_if_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_set_if_vers(rdc_u_info_t *, rpcvers_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_print_svinfo(rdc_srv_t *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern rdc_srv_t *rdc_create_svinfo(char *, struct netbuf *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct knetconfig *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_destroy_svinfo(rdc_srv_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void init_rdc_netbuf(struct netbuf *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void free_rdc_netbuf(struct netbuf *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void dup_rdc_netbuf(const struct netbuf *, struct netbuf *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_netbuf_toint(struct netbuf *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern struct netbuf *rdc_int_tonetbuf(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_lor(const uchar_t *, uchar_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_resume2(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_set_flags(rdc_u_info_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_clr_flags(rdc_u_info_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_get_vflags(rdc_u_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_set_mflags(rdc_u_info_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_clr_mflags(rdc_u_info_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_get_mflags(rdc_u_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_set_flags_log(rdc_u_info_t *, int, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_group_log(rdc_k_info_t *krdc, int flush, char *why);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_config(void *, int, spcs_s_info_t, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_many_enter(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_many_exit(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_group_enter(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_group_exit(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_sync_event_wait(void *, void *, int, spcs_s_info_t, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_sync_event_notify(int, char *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _rdc_link_down(void *, int, spcs_s_info_t, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_delgroup(rdc_group_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_write_bitmap_fba(rdc_k_info_t *, nsc_off_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_bitmapset(int, char *, char *, void *, int, nsc_off_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern rdc_net_dataset_t *rdc_net_add_set(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern rdc_net_dataset_t *rdc_net_get_set(int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_net_put_set(int, rdc_net_dataset_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_net_del_set(int, rdc_net_dataset_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_net_free_set(rdc_k_info_t *, rdc_net_dataset_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_lookup_byhostdev(char *intf, char *file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_lookup_configured(char *path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void rdc_dump_dsets(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void set_busy(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void wakeup_busy(rdc_k_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_async6(void *, int mode, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rdc_readgen(void *, int, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _RDC_IO_H */