/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _RDC_IO_H
#define _RDC_IO_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef DS_DDICT
#define bool_t int
#endif
/*
* Definitions for kstats
*/
/*
* Queue types
*/
#ifdef _KERNEL
extern nstset_t *_rdc_ioset;
extern nstset_t *_rdc_flset;
#ifdef DEBUG
extern int RDC_MAX_SYNC_THREADS;
extern int rdc_maxthreads_last;
int num_sync_threads;
#else
#endif
#ifdef DEBUG
#define RDC_AVAIL_THR_TUNE(n) \
do { \
if (rdc_maxthreads_last < RDC_MAX_SYNC_THREADS) { \
(void) nst_add_thread(n.rdc_syncset, \
} \
if (rdc_maxthreads_last > RDC_MAX_SYNC_THREADS) { \
(void) nst_del_thread(n.rdc_syncset, \
} \
if (n.avail_thr < 0) { \
n.avail_thr = 0; \
} \
} while (0);
#else
#define RDC_AVAIL_THR_TUNE(n) \
do { \
if (n.avail_thr < 0) \
n.avail_thr = 0; \
} while (0);
#endif
typedef struct syncloop_info {
int active_thr;
} sync_info_t;
/*
* Static server information
*/
typedef struct servinfo {
} rdc_srv_t;
/*
* Interface structure, including health monitoring.
*/
typedef struct rdc_if_s {
} rdc_if_t;
typedef struct rdc_aio_s {
int flag;
int iostatus;
int index;
} rdc_aio_t;
/* values for (rdc_aio_t *)->iostatus */
enum {
};
typedef struct netqueue {
} net_queue;
/*
* Bitmap header structures.
* These must be fixed size in all data models.
* If we ever support little-endian machines (eg. Intel) we will need
* to add byte-swapping logic.
*/
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
#endif /* _KERNEL */
#ifdef _KERNEL
typedef struct aio_buf_s {
} aio_buf_t;
typedef struct rdc_thrsync {
int threads;
int complete;
typedef struct sync_status_s {
int offset;
typedef struct rdc_syncthr {
/*
* RDC buffer header
*/
typedef struct rdc_buf_s {
} rdc_buf_t;
(((h)->rdc_flags & RDC_ASYNC_VEC) == 0))
#define RDC_HANDLE_LIMITS(h, p, l) \
(((h)->sb_user & RDC_DISKQUE) || \
((p) >= (h)->sb_pos) && \
#define RDC_DSET_LIMITS(d, p, l) \
(((p) >= (d)->pos) && \
/*
* RDC device info structures
*/
typedef struct _rdc_info_dev_s {
typedef struct rdc_info_dev_s {
typedef struct rdc_path_s {
} rdc_path_t;
/*
* Values for id_flag
*/
/*
* value for diskio.seq.
*/
typedef struct rdc_sleepq {
} rdc_sleepq_t;
/*
* RDC group structure
*/
typedef struct rdc_group {
int count;
int rdc_writer;
int unregistering;
/*
* Dual use, the outgoing sequence number on the client.
* The next expected sequence number on the server.
* Protected by the ra_queue lock.
*/
/*
* Dual use, the last acknowledged sequence number.
* Used to ensure that the queue doesn't overflow on server
* and to stall transmissions on the client.
* Protected by the ra_queue lock.
*/
} rdc_group_t;
/* group state */
/*
* These flags are used in the
* aux_state field, and are used to track:
* AUXSYNCIP: When the code has a sync thread running, used instead
* of the RC_SYNCING flag which gets cleared before the sync thread
* terminates.
* AUXWRITE: Set when rdc_sync_write_thr is running, so the rdc_unintercept
* code can wait until a one-to-many write has actually terminated.
*/
/*
* RDC kernel-private information
*/
typedef struct rdc_k_info {
int type_flag;
int spare1;
volatile int sync_done;
unsigned char *dcio_bitmap;
int bitmap_write;
int closing;
int b_ref;
} rdc_k_info_t;
/*
* flags for _rdc_rsrv_devs()
*/
/*
* which device(s) to reserve - integer bitmap.
*/
/*
* device usage after reserve - integer flag.
*/
/*
* Utility macro for nsc_*() io function returns.
*/
/*
* RDC file descriptor structure
*/
typedef struct rdc_fd_s {
} rdc_fd_t;
/*
* fd and rsrv macros
*/
typedef struct rdc_host_u {
char *nodename;
int netaddr;
} rdc_host_t;
/*
* Reply from remote read
* - convenience defines for the client side code.
* - keep this in sync with the readres structure in rdc_prot.h/.x
*/
/*
* Flags for remote read rpc
*
* _START must be a unique rpc, _DATA and _END may be OR-d together.
*/
/*
* Flags for remote write rpc
*/
/*
* macro used to determine if the incomming sq, with sequence
* value x, should be placed before the sq with sequence value y.
* This has to account for integer wrap. We account for integer
* wrap by checking if the difference between x and y is within
* half of the maximum integer value (RDC_MAXINT) or not.
*/
((x > y) && ((x - y) > RDC_RANGE)) ? 1 : 0)
#endif /* _KERNEL */
/*
* RDC user-visible information
*/
/*
* RDC flags for set state / set cd RPC.
* Must remain compatible with rdc RPC protocol version v3.
*/
/*
* In kernel type flags (krdc->type_flag).
*/
/* the one corresponding to the current set, */
/* to prevent recursion in the case where */
/* the request was initiated from the remote */
/* node. */
#ifdef _KERNEL
/*
* Functions, vars
*/
typedef struct {
int event;
int ack;
extern rdc_sync_event_t rdc_sync_event;
extern clock_t rdc_sync_event_timeout;
extern kmutex_t rdc_sync_mutex;
extern rdc_u_info_t *rdc_u_info;
extern rdc_k_info_t *rdc_k_info;
extern int rdc_max_sets;
extern unsigned long rdc_async_timeout;
extern int rdc_self_host();
extern void rdc_sleepqdiscard(rdc_group_t *);
#ifdef DEBUG
extern void rdc_stallzero(int);
#endif
struct rdc_net_dataitem {
void *dptr;
};
struct rdc_net_dataset {
int id;
int inuse;
int delpend;
int nitems;
};
#endif /* _KERNEL */
/*
* These next two defines are the default value of the async queue size
* They have been calculated to be 8MB of data with an average of
* 2K IO size
*/
(RPC_MAXDATASIZE - 8192))
#define ATM_NONE 0
/* right now we can only trace 1m or less writes to the bitmap (32 bits wide) */
#if defined(_KERNEL)
/* kstat interface */
/*
* Per module kstats
* only one instance
*/
typedef struct {
/*
* Per set kstats
* one instance per configured set
*/
typedef struct {
#endif /* _KERNEL */
#ifndef _SunOS_5_6 /* i.e. 2.7+ */
typedef int xdr_t;
#else /* i.e. 2.6- */
typedef unsigned long rpcprog_t;
typedef unsigned long rpcvers_t;
typedef unsigned long rpcproc_t;
typedef unsigned long rpcprot_t;
typedef unsigned long rpcport_t;
#endif /* _SunOS_5_6 */
#ifdef _KERNEL
extern nsc_size_t MAX_RDC_FBAS;
extern volatile int net_exit;
extern int rdc_max_qitems; /* max # of items on async q */
extern int rdc_asyncthr; /* # of async threads */
#ifdef DEBUG
extern kmutex_t rdc_cntlock;
extern int rdc_datasetcnt;
#endif
/*
* Macro to keep tabs on dataset memory usage.
*/
#ifdef DEBUG
#define RDC_DSMEMUSE(x) \
rdc_datasetcnt += (x);\
#else
#define RDC_DSMEMUSE(x)
#endif
extern kmutex_t rdc_ping_lock;
extern rdc_if_t *rdc_if_top;
nsc_buf_t *);
extern int rdc_net_state(int, int);
extern int rdc_net_getbmap(int, int);
extern int rdc_net_getsize(int, uint64_t *);
int, netwriteres *);
int);
rdc_k_info_t *);
extern int rdc_start_server(struct rdc_svc_args *, int);
extern int rdc_net_getstate(rdc_k_info_t *, int *, int *, int *, int);
extern kmutex_t rdc_conf_lock;
extern kmutex_t rdc_many_lock;
extern int rdc_drain_queue(int);
extern int flush_group_queue(int);
extern void rdc_dev_close(rdc_k_info_t *);
extern int rdc_dev_open(rdc_set_t *, int);
extern void rdc_get_details(rdc_k_info_t *);
extern int rdc_lookup_bitmap(char *);
extern int rdc_lookup_enabled(char *, int);
extern int rdc_lookup_byaddr(rdc_set_t *);
extern int rdc_lookup_byname(rdc_set_t *);
extern int rdc_intercept(rdc_k_info_t *);
extern int rdc_unintercept(rdc_k_info_t *);
extern int _rdc_rsrv_devs(rdc_k_info_t *, int, int);
extern void _rdc_rlse_devs(rdc_k_info_t *, int);
extern void _rdc_unload(void);
extern int _rdc_load(void);
extern int _rdc_configure(void);
extern void _rdc_deconfigure(void);
extern void _rdc_async_throttle(rdc_k_info_t *, long);
extern int rdc_writer(int);
extern int rdc_dump_alloc_bufs_cd(int);
extern void rdc_dump_alloc_bufs(rdc_if_t *);
extern int rdc_check_secondary(rdc_if_t *, int);
extern void rdc_dump_queue(int);
int);
extern void rdc_remove_from_if(rdc_if_t *);
extern void rdc_print_svinfo(rdc_srv_t *, char *);
struct knetconfig *);
extern void rdc_destroy_svinfo(rdc_srv_t *);
extern void init_rdc_netbuf(struct netbuf *);
extern void free_rdc_netbuf(struct netbuf *);
extern int rdc_netbuf_toint(struct netbuf *);
extern struct netbuf *rdc_int_tonetbuf(int);
extern int rdc_resume2(rdc_k_info_t *);
extern void rdc_set_flags(rdc_u_info_t *, int);
extern void rdc_clr_flags(rdc_u_info_t *, int);
extern int rdc_get_vflags(rdc_u_info_t *);
extern void rdc_set_mflags(rdc_u_info_t *, int);
extern void rdc_clr_mflags(rdc_u_info_t *, int);
extern int rdc_get_mflags(rdc_u_info_t *);
extern void rdc_set_flags_log(rdc_u_info_t *, int, char *);
extern int _rdc_config(void *, int, spcs_s_info_t, int *);
extern void rdc_many_enter(rdc_k_info_t *);
extern void rdc_many_exit(rdc_k_info_t *);
extern void rdc_group_enter(rdc_k_info_t *);
extern void rdc_group_exit(rdc_k_info_t *);
extern int _rdc_sync_event_wait(void *, void *, int, spcs_s_info_t, int *);
extern int _rdc_sync_event_notify(int, char *, char *);
extern int _rdc_link_down(void *, int, spcs_s_info_t, int *);
extern void rdc_delgroup(rdc_group_t *);
extern int rdc_bitmapset(int, char *, char *, void *, int, nsc_off_t, int);
extern rdc_net_dataset_t *rdc_net_add_set(int);
extern rdc_net_dataset_t *rdc_net_get_set(int, int);
extern void rdc_net_put_set(int, rdc_net_dataset_t *);
extern void rdc_net_del_set(int, rdc_net_dataset_t *);
extern int rdc_lookup_configured(char *path);
extern void rdc_dump_dsets(int);
extern void set_busy(rdc_k_info_t *);
extern void wakeup_busy(rdc_k_info_t *);
#ifdef DEBUG
extern int rdc_async6(void *, int mode, int *);
extern int rdc_readgen(void *, int, int *);
#endif
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _RDC_IO_H */