fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kRPC Server for sndr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on 2.6 both dki_lock.h and rpc/types.h define bool_t so we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * define enum_t here as it is all we need from rpc/types.h
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * anyway and make it look like we included it. Yuck.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SunOS_2_6 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_sleepq(rdc_group_t *, rdc_sleepq_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_combywrite(rdc_k_info_t *, nsc_buf_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_writemaxfba(rdc_k_info_t *, rdc_u_info_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void rdc_setbitind(int *, net_pendvec_t *, rdc_net_dataset_t *, uint_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void rdc_dopending(rdc_group_t *, netwriteres *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic nsc_vec_t *rdc_dset2vec(rdc_net_dataset_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_combyread(rdc_k_info_t *, rdc_u_info_t *, nsc_buf_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_readmaxfba(int, nsc_off_t, nsc_size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_dsetcopy(rdc_net_dataset_t *, nsc_vec_t *, nsc_off_t, nsc_size_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* direction for dsetcopy() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define COPY_IN 1 /* copy data into the rpc buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define COPY_OUT 2 /* copy data out of the rpc buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_sync_event_notify(int operation, char *volume, char *group)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_sync_event.master, volume, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_sync_event.group, group, NSC_MAXPATH);
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni time = cv_reltimedwait_sig(&rdc_sync_event.done_cv,
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni &rdc_sync_event.mutex, rdc_sync_event_timeout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* signalled or timed out */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_sync_event_wait(void *arg0, void *arg1, int mode, spcs_s_info_t kstatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rdc_sync_event.lbolt - nsc_lbolt() < rdc_sync_event_timeout)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We haven't been away too long */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cv_wait_sig(&rdc_sync_event.cv, &rdc_sync_event.mutex) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_copyout(rdc_sync_event.master, arg0, NSC_MAXPATH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_copyout(rdc_sync_event.group, arg1, NSC_MAXPATH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_allow_sec_sync(rdc_u_info_t *urdc, int option)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Reverse sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reverse sync needed or in progress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Forward sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reverse syncing is bad, as that means that data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is already flowing to the target of the requested
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync operation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Clear "reverse sync needed" on all 1-many volumes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The data on them will be updated from the primary of this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * requested sync operation, so the aborted reverse sync need
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not be completed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_null
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Proc 0 Null action
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_read
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = SVC_GETARGS(xprt, xdr_rread, (char *)&diskio);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nocache = (diskio.flag & RDC_RREAD_FAIL) ? 0 : NSC_NOCACHE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((diskio.cd >= rdc_max_sets) || (diskio.cd < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_readres, (char *)&resp);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_read: EPROTO cd out or not enabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup rpc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = rdc_readmaxfba(diskio.cd, diskio.pos, diskio.len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!svc_sendreply(xprt, xdr_int, (char *)&st)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (st != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "has failed in cleanup");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* data rpc */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!r_net_read: received non-DATA rpc! flag %x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_readres, (char *)&resp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_readres, (char *)&resp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find place in vector */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IF the data is in a single sb_vec entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we can just point to that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we have to alloc a local buffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy the data in and the point to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the local buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buffer = kmem_alloc(resp.rr_bufsize, KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdc_dsetcopy(dset, vector, diskio.pos, diskio.len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = svc_sendreply(xprt, xdr_readres, (char *)&resp); /* send data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RPC reply failed, OR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Last RPC for this IO operation, OR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We are failing this IO operation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Do cleanup.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_read (v6)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = SVC_GETARGS(xprt, xdr_rread6, (char *)&diskio);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nocache = (diskio.flag & RDC_RREAD_FAIL) ? 0 : NSC_NOCACHE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((diskio.cd >= rdc_max_sets) || (diskio.cd < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_readres, (char *)&resp);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!r_net_read6: EPROTO cd out or not enabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup rpc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = rdc_readmaxfba(diskio.cd, diskio.pos, diskio.len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!svc_sendreply(xprt, xdr_int, (char *)&st)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (st != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "has failed in cleanup");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* data rpc */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!read6: received non-DATA rpc! flag %x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_readres, (char *)&resp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_readres, (char *)&resp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find place in vector */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IF the data is in a single sb_vec entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we can just point to that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we have to alloc a local buffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy the data in and the point to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the local buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buffer = kmem_alloc(resp.rr_bufsize, KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdc_dsetcopy(dset, vector, diskio.pos, diskio.len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = svc_sendreply(xprt, xdr_readres, (char *)&resp); /* send data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RPC reply failed, OR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Last RPC for this IO operation, OR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We are failing this IO operation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Do cleanup.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_write (Version 5)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 reply indicates error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * >0 reply indicates a net handle index
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * <0 reply indicates errno
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ret net handle index
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ret2 general error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ret3 multi-hop errors (never returned)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte diskio.data.data_val = kmem_alloc(RDC_MAXDATA, KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = SVC_GETARGS(xprt, xdr_net_data5, (char *)&diskio);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!r_net_write5:SVC_GETARGS failed: st %d", st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((diskio.cd >= rdc_max_sets) || (diskio.cd < 0)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!r_net_write6: EPROTO cd out or not enabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nocache = (diskio.flag & RDC_RWRITE_FAIL) ? 0 : NSC_NOCACHE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IS_ENABLED(urdc) || IS_STATE(urdc, RDC_LOGGING)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!r_net_write6: cd logging / not enabled (%x)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc = NULL; /* so we don't try to unqueue kstat entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* -1 index says allocate a buffer */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "failed to add dataset");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ditem = kmem_alloc(sizeof (rdc_net_dataitem_t), KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this is a single transfer, then we don't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * need to allocate any memory for the data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * just point the ditem data pointer to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * existing buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * So we don't free it twice.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate the memory for the complete
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy the data to the new buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(diskio.data.data_len == FBA_SIZE(diskio.nfba));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free the old data buffer.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_write5: net_get_set failed cd %d idx %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We have to copy the data from the rpc buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the data in ditem.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(diskio.data.data_val, (char *)ditem->dptr +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FBA_SIZE(diskio.sfba - diskio.pos), diskio.data.data_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret2 = rdc_writemaxfba(krdc, urdc, dset, diskio.seq, nocache);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(rdc_svcwrite5_err_ret2, int, ret2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = svc_sendreply(xprt, xdr_int, (char *)&ret2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On Error we must cleanup.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we have a handle, free it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we have a network handle, free it.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!r_net_write5 error case? st %x ret %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_write (Version 6)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * index 0 = error, or net handle index.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * result = 0 , ok.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * result = 1, pending write.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * result < 0 error, and is the -errno.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ret net handle index.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ret2 general error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte diskio.data.data_val = kmem_alloc(RDC_MAXDATA, KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = SVC_GETARGS(xprt, xdr_net_data6, (char *)&diskio);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_write6:SVC_GETARGS failed: st %d", st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((diskio.cd >= rdc_max_sets) || (diskio.cd < 0)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!r_net_write6: EPROTO cd out or not enabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nocache = (diskio.flag & RDC_RWRITE_FAIL) ? 0 : NSC_NOCACHE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IS_ENABLED(urdc) || IS_STATE(urdc, RDC_LOGGING)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_write6: cd logging or not enabled (%x)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc = NULL; /* so we don't try to unqueue kstat entry */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_write6: No group structure for set %s:%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc = NULL; /* so we don't try to unqueue kstat entry */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_write6: idx %d seq %u current seq %u pos %llu "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "len %d sfba %llu nfba %d endoblk %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* -1 index says allocate a net dataset */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_write6: failed to add dataset");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ditem = kmem_alloc(sizeof (rdc_net_dataitem_t), KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this is a single transfer, then we don't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * need to allocate any memory for the data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * just point the ditem data pointer to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * existing buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * So we don't free it twice.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate the memory for the complete
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy the data to the new buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(diskio.data.data_len == FBA_SIZE(diskio.nfba));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free the old data buffer.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_write6: net_get_set failed cd %d idx %d "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "packet sequence %u expected seq %u",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We have to copy the data from the rpc buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the data in ditem.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(diskio.data.data_val, (char *)ditem->dptr +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FBA_SIZE(diskio.sfba - diskio.pos), diskio.data.data_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * magic marker, start of sequence.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * see if some threads are stuck.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((diskio.seq != RDC_NOSEQ) && (diskio.seq != RDC_NEWSEQ)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * see if we are allowed through here to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * do the write, or if we have to q the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * request and send back a pending reply.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check that we have room.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * skip magic values.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "size %d exceeded seqack %u "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "this seq %u maxseq %u seq %u",
d5508a7fb37e6b070e142ee081bec69a3d20bd6cThomas Atkins DTRACE_PROBE2(qsize_exceeded, int, diskio.seq,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pending state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret2 = rdc_writemaxfba(krdc, urdc, dset, diskio.seq, nocache);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!r_net_write6: writemaxfba failed %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(rdc_svcwrite6_err_ret2, int, ret2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st = svc_sendreply(xprt, xdr_netwriteres, (char *)&netret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte netret.vecdata.vecdata_len * sizeof (net_pendvec_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On Error we must cleanup.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we have a handle, free it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we have a network handle, free it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we hold the main nsc buffer, free it.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!r_net_write6 error st %x ret %d seq %u",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_ping4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * received on the primary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = SVC_GETARGS(xprt, xdr_rdc_ping6, (char *)&ping);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update specified interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Update the rpc protocol version to use */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR: couldn't get ping4 arguments");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_ping7
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * received on the primary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = SVC_GETARGS(xprt, xdr_rdc_ping, (char *)&ping);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update specified interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Update the rpc protocol version to use */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR: couldn't get ping7 arguments");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_bmap (v5)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * WARNING acts as both client and server
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (b.cd >= 0 && b.cd < rdc_max_sets && IS_ENABLED(urdc) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_bmap (v6)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * WARNING acts as both client and server
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (b.cd >= 0 && b.cd < rdc_max_sets && IS_ENABLED(urdc) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the bitmap send has succeeded, clear it.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!Bitmap clear in r_net_bmap6");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_bdata
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We have to convert it to the internal form here,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * net_data6, when we know that we will have to convert
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it back to the v5 variant for transmission.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bd.data.data_val = kmem_alloc(BMAP_BLKSIZE, KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = SVC_GETARGS(xprt, xdr_net_bdata, (char *)&bd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bd.cd >= 0 && bd.cd < rdc_max_sets && IS_ENABLED(urdc) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_bdata v6
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * just allocate the bigger block, regardless of < V7
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bd.size will dictate how much we lor into our bitmap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the other option would be write r_net_bdata7 that is identical
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to this function, but a V7 alloc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bd.data.data_val = kmem_alloc(BMAP_BLKSIZEV7, KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = SVC_GETARGS(xprt, xdr_net_bdata6, (char *)&bd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bd.cd >= 0 && bd.cd < rdc_max_sets && IS_ENABLED(urdc) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Write the merged bitmap.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret == 0) && bd.endoblk && (krdc->bitmap_write > 0)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!r_net_bdata6: Written bitmap for %s:%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_getsize (v5)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_getsize (v6)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * small change in semantics here, as we can't return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -1 over the wire anymore.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_u_longlong_t, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_state4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = SVC_GETARGS(xprt, xdr_set_state4, (char *)&state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(state.rnetaddr, rdc_set.secondary.addr.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.primary.file, state.pfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.secondary.file, state.sfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_state: no index or disable pending");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!r_net_state: set not enabled ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!r_net_state: no valid svp\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_state: no valid krdc %p\n", (void*)krdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!r_net_state: disable pending");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(urdc->primary.addr), &(urdc->secondary.addr), 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(urdc->secondary.addr), &(urdc->primary.addr), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mark that the bitmap needs clearing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Starting forward sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mark that the bitmap needs clearing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Starting reverse sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync completed OK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_clr_flags(urdc, RDC_SYNCING | RDC_SYNC_NEEDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_clr_mflags(urdc, RDC_SLAVE | RDC_RSYNC_NEEDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync aborted or logging started */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rev_sync) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if volume is mounted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (done) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * special case...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if this set is in a group, then sndrsyncd will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make sure that all sets in the group are REP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before updating the config to "update", telling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndrsyncd that it is ok to take anther snapshot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on a following sync. The important part about
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the whole thing is that syncd needs kernel stats.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * however, this thread must set the set busy to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * avoid disables. since this is the only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync_event_notify() that will cause a status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * call back into the kernel, and we will not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * accessing the group structure, we have to wakeup now
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_group_log(krdc, RDC_NOFLUSH | RDC_OTHERREMOTE,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "Sync aborted or logging started");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = SVC_GETARGS(xprt, xdr_set_state, (char *)&state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(state.netaddr.buf, rdc_set.primary.addr.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(state.rnetaddr.buf, rdc_set.secondary.addr.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.primary.file, state.pfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.secondary.file, state.sfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_state: no index or disable pending");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!r_net_state: set not enabled ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!r_net_state: no valid svp\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!r_net_state: no valid krdc %p\n", (void*)krdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!r_net_state: disable pending");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(urdc->primary.addr), &(urdc->secondary.addr), 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(urdc->secondary.addr), &(urdc->primary.addr), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mark that the bitmap needs clearing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Starting forward sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mark that the bitmap needs clearing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Starting reverse sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync completed OK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_clr_flags(urdc, RDC_SYNCING | RDC_SYNC_NEEDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_clr_mflags(urdc, RDC_SLAVE | RDC_RSYNC_NEEDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync aborted or logging started */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rev_sync) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if volume is mounted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (done) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * special case...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if this set is in a group, then sndrsyncd will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make sure that all sets in the group are REP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before updating the config to "update", telling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndrsyncd that it is ok to take anther snapshot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on a following sync. The important part about
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the whole thing is that syncd needs kernel stats.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * however, this thread must set the set busy to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * avoid disables. since this is the only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync_event_notify() that will cause a status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * call back into the kernel, and we will not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * accessing the group structure, we have to wakeup now
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_group_log(krdc, RDC_NOFLUSH | RDC_OTHERREMOTE,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "Sync aborted or logging started");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_getstate4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return our state to client
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forter_net_getstate4(SVCXPRT *xprt, struct svc_req *req)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = SVC_GETARGS(xprt, xdr_set_state4, (char *)&state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(state.rnetaddr, rdc_set.secondary.addr.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.primary.file, state.pfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.secondary.file, state.sfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * r_net_getstate7
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return our state to client
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forter_net_getstate7(SVCXPRT *xprt, struct svc_req *req)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = SVC_GETARGS(xprt, xdr_set_state, (char *)&state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(state.netaddr.buf, rdc_set.primary.addr.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(state.rnetaddr.buf, rdc_set.secondary.addr.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * strncpy(rdc_set.primary.file, state.pfile, RDC_MAXNAMLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * strncpy(rdc_set.secondary.file, state.sfile, RDC_MAXNAMLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(state.pfile, rdc_set.primary.file, RDC_MAXNAMLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(state.sfile, rdc_set.secondary.file, RDC_MAXNAMLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) svc_sendreply(xprt, xdr_int, (char *)&ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy from/to a dset/vector combination to a network xdr buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_dsetcopy(rdc_net_dataset_t *dset, nsc_vec_t *invec, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t fba_len, char *bdata, int blen, int dir)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!rdc: dsetcopy: parameters failed bdata %p, dset %p "
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "invec %p", (void *)bdata, (void *)dset, (void *)invec);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!rdc: dsetcopy: params failed fba_len %" NSC_SZFMT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " fba_pos %" NSC_SZFMT ", dir %d", fba_len, fba_pos, dir);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte data = (uchar_t *)bdata; /* pointer to data in rpc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = FBA_SIZE(fba_len); /* length of this transfer in bytes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fpos = fba_pos; /* start fba offset within buffer */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc: dsetcopy: len = 0");
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc:dsetcopy: len %d != blen %d", len, blen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* should never happen */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!rdc: dsetcopy: handle limits pos %" NSC_SZFMT " (%"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NSC_SZFMT ") len %" NSC_SZFMT " (%" NSC_SZFMT ")",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana fba_pos, dset->pos, fba_len, dset->fbalen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find starting position in vector */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sv_addr) /* end of vec - how did this happen? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* goto next vector */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_start_server
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Starts the kRPC server for rdc. Uses tli file descriptor passed down
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from user level rdc server.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns: 0 or errno (NOT unistat!).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_start_server(struct rdc_svc_args *args, int mode)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_start_server fd %d, fp %p", args->fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate a new sleepq element.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sq = kmem_alloc(sizeof (rdc_sleepq_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free memory/resources used by a sleepq element.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * skip down the sleep q and insert the sleep request
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in ascending order. Return 0 on success, 1 on failure.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_sleepq: Attempt to "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Attempt to add duplicate "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * run down the sleep q and discard all the sleepq elements.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * split any write requests down to maxfba sized chunks.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_writemaxfba(rdc_k_info_t *krdc, rdc_u_info_t *urdc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_net_dataset_t *dset, uint_t seq, int nocache)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while ((ret == EINTR) && (eintr_count < MAX_EINTR_COUNT));
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_writemaxfba: reserve devs "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Perhaps we should cache mfba.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_writemaxfba: msc_maxfbas failed %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* should never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * also need to trim down the vector
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (len > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "nsc_alloc (d1) buf failed %d at "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "svc write failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This string is used in the ZatoIchi MASNDR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tests, if you change this, update the test.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_combywrite(rdc_k_info_t *krdc, nsc_buf_t *handle)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Handle multihop I/O even on error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Find a target primary that is enabled,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * taking account of the fact that this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * could be a multihop secondary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * connected to a 1-to-many primary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* CSTYLED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* normal case - local io first */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = nsc_write(handle, handle->sb_pos, handle->sb_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte multiret = _rdc_multi_write(handle, handle->sb_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "rdc_multi_write failed "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "status %d ret %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reverse sync in progress and so we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * need to do the local io after the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (multihop) secondary io.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * no multihop and this is the only io
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = nsc_write(handle, handle->sb_pos, handle->sb_len, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set the pos and len values in the piggyback reply.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_setbitind(int *pendcnt, net_pendvec_t *pvec, rdc_net_dataset_t *dset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Enters with group->ra_queue.net_qlock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Tries to construct the return status data for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * all the pending requests in the sleepq that it can
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_dopending(rdc_group_t *group, netwriteres *netretp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * now look at the Q of pending tasks, attempt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to write any that have been waiting for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * me to complete my write, and piggyback
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * their results in my reply, by setiing pendcnt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the number of extra requests sucessfully
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * processed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (group->sleepq && group->sleepq->seq == group->seq) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!pending: %s:%s rdc_net_get_set "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as we failed to get the pointer, there
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is no point expecting the cleanup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * code in rdc_delsleepq() to get it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = rdc_writemaxfba(krdc, urdc, dset, sq->seq, sq->nocache);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!dopending: Write of pending "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "asynchronous task failed, with "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sequence number %u for SNDR set %s:%s",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!packing pend, count %d", pendcnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(pendvec, netretp->vecdata.vecdata_val, vecsz);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Take the dset and allocate and fill in the vector.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vecret = kmem_alloc((dset->nitems + 1) * sizeof (nsc_vec_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_DSMEMUSE((dset->nitems + 1) * sizeof (nsc_vec_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Null terminate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the list and count matches.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Split the local read into maxfba sized chunks.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns 0 on an error, or a valid idx on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_readmaxfba(int cd, nsc_off_t pos, nsc_size_t fbalen, int nocache)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while ((ret == EINTR) && (eintr_count < MAX_EINTR_COUNT));
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!readmaxfba: reserve failed on set %s:%s %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create a dataset that we can hang all the buffers from.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!readmaxfba: Unable to allocate dset on set "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s:%s", urdc->secondary.intf, urdc->secondary.file);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!readmaxfba: msc_maxfbas failed on set %s:%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%d", urdc->secondary.intf, urdc->secondary.file, ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (fbaleft > 0) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!readmaxfba: alloc failed on set"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ditem = kmem_alloc(sizeof (rdc_net_dataitem_t), KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * construct a vector list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * place on linked list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * now its linked, clear this so its not freed twice.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * all the reads have worked, store the results.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * perform both a local read, and if multihop, a remote read.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return 0 on success, or errno on failure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_combyread(rdc_k_info_t *krdc, rdc_u_info_t *urdc, nsc_buf_t *handle)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = nsc_read(handle, handle->sb_pos, handle->sb_len, NSC_READ);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!combyread: read failed on set %s:%s %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->secondary.intf, urdc->secondary.file, ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "comby read failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_MULTI(krdc) && (ktmp = krdc->multi_next) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = _rdc_remote_read(ktmp, handle, handle->sb_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set NSC_MIXED so
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that the cache will throw away this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buffer when we free it since we have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * combined data from multiple sources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * into a single buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Currently we don't use the cache for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data volumes, so comment this out.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handle->sb_flag |= NSC_MIXED;
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!combyread: remote read failed on "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * remove and free all the collected dsets for this set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for the dset to be in use, the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * service routine r_net_write6() must
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be active with it. It will free
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it eventually.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_PANIC, "Bad flag value passed to rdc_stallzero");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC protocol version 5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PROC Idempotent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC protocol version 6
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PROC Idempotent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC protocol version 7
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PROC Idempotent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { rdc_disptab5, sizeof (rdc_disptab5) / sizeof (*rdc_disptab5) },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { rdc_disptab6, sizeof (rdc_disptab6) / sizeof (*rdc_disptab6) },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { rdc_disptab7, sizeof (rdc_disptab7) / sizeof (*rdc_disptab7) }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we're decoding and the caller has already allocated a buffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * throw away maxlen, since it doesn't apply to the caller's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buffer. xdr_bytes will return an error if the buffer isn't big
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xdrs->x_op == XDR_DECODE && objp->buf != NULL) {