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 * 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_5_6 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_conf_lock is used as a global device configuration lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It is also used by enable/resume and disable/suspend code to ensure that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the transition of an rdc set between configured and unconfigured is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * krdc->group->lock is used to protect state changes of a configured rdc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set (e.g. changes to urdc->flags), such as enabled to disabled and vice
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_many_lock is also used to protect changes in group membership. A group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * linked list cannot change while this lock is held. The many list and the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * multi-hop list are both protected by rdc_many_lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortekmutex_t rdc_many_lock; /* Many/multi-list lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic kmutex_t rdc_net_hnd_id_lock; /* Network handle id lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_size_t rdc_maxthres_queue = RDC_MAXTHRES_QUEUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Forward declare all statics that are used before defined
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to enforce parameter checking
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Some (if not all) of these could be removed if the code were reordered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_installbitmap(int, void *, int, nsc_off_t, int, int *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid rdc_init_diskq_header(rdc_group_t *grp, dqheader *header);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid rdc_fail_diskq(rdc_k_info_t *krdc, int wait, int dolog);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint rdc_stamp_diskq(rdc_k_info_t *krdc, int rsrvd, int flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RDC threadset tunables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint rdc_threads = 64; /* default number of threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint rdc_threads_inc = 8; /* increment for changing the size of the set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Private threadset manipulation variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hysteresis for threadset resizing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_sets_active; /* number of sets currently enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_thread_deconfigure - rdc is being deconfigured, stop any
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * thread activity.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Inherently single-threaded by the Solaris module unloading code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_thread_configure - rdc is being configured, initialize the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * threads we need for flushing aync volumes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called with rdc_conf_lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((_rdc_ioset = nst_init("rdc_thr", rdc_threads)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((_rdc_flset = nst_init("rdc_flushthr", 2)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nst_init("rdc_syncthr", RDC_MAX_SYNC_THREADS)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_thread_tune - called to tune the size of the rdc threadset.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called from the config code when an rdc_set has been enabled or disabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 'sets' is the increment to the number of active rdc_sets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called with rdc_conf_lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte change += nst_add_thread(_rdc_ioset, rdc_threads_inc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (nthreads - (rdc_threads_inc + rdc_threads_hysteresis))) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte change -= nst_del_thread(_rdc_ioset, rdc_threads_inc);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "nsets %d, nthreads %d, nthreads change %d",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana rdc_sets_active, nst_nthread(_rdc_ioset), change);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _rdc_unload() - cache is being unloaded,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * deallocate any dual copy structures allocated during cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_max_sets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(rdc_k_info, sizeof (*rdc_k_info) * rdc_max_sets);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(rdc_u_info, sizeof (*rdc_u_info) * rdc_max_sets);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _rdc_load() - rdc is being loaded, Allocate anything
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that will be needed while the cache is loaded but doesn't really
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * depend on configuration parameters.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&rdc_ping_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&net_blk_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&rdc_conf_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&rdc_many_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&rdc_net_hnd_id_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&rdc_clnt_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&sync_info.lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&rdc_cntlock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* following case for partial installs that may fail */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_k_info = kmem_zalloc(sizeof (*rdc_k_info) * rdc_max_sets, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_u_info = kmem_zalloc(sizeof (*rdc_u_info) * rdc_max_sets, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(rdc_k_info, sizeof (*rdc_k_info) * rdc_max_sets);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_max_sets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&krdc->dc_sleep, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&krdc->bmapmutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&krdc->kstat_mutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&krdc->bmp_kstat_mutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&krdc->syncbitmutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&krdc->closingcv, NULL, CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_volume_update = nsc_register_svc("RDCVolumeUpdated",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _rdc_configure() - cache is being configured.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize dual copy structures
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _rdc_deconfigure - rdc is being deconfigured, shut down any
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dual copy operations and return to an unconfigured state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Lock primitives, containing checks that lock ordering isn't broken
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Suspend and disable operations use this function to wait until it is safe
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to do continue, without trashing data structures used by other ioctls.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Other ioctls use this function to hold off disable and suspend.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Other ioctls use this function to allow disable and suspend to continue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove the rdc set from its group, and destroy the group if no longer in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lock queue while looking at thrnum
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((group->rdc_thrnum == 0) && (group->count == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Assure the we've stopped and the flusher thread has not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fallen back to sleep
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (krdc->group->ra_queue.qfill_sleeping != RDC_QFILL_DEAD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (krdc->group->ra_queue.qfflags & RDC_QFILLSTOP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Always clear the group field.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * no, you need it set in rdc_flush_memq().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to call rdc_group_log()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * krdc->group = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take this rdc structure off the group list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; p->group_next != krdc; p = p->group_next)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add the rdc set to its group, setting up a new group if it's the first one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadd_to_group(rdc_k_info_t *krdc, int options, int cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Look for matching group name, primary host name and secondary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(utmp->primary.intf, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Same group name, different primary interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(utmp->secondary.intf, urdc->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Same group name, different secondary interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Group already exists, so add this set to the group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must be same mode as existing group members */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must be same mode as existing group members */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cannont reconfigure existing group into new queue this way */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !RDC_IS_DISKQ(ktmp->group) && urdc->disk_queue[0] != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->autosync = utmp->autosync; /* Same as rest */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->disk_queue, utmp->disk_queue, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This must be a new group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Tune the thread set by one for each thread created
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trc = nst_create(_rdc_ioset, rdc_qfiller_thr, (void *)krdc, NST_SLEEP);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!unable to create queue filler daemon");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX check here for resume or enable and act accordingly */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc == RDC_EQNOADD) && (cmd != RDC_CMD_ENABLE)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!disk queue %s enable failed,"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " enabling memory queue",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Move the set to a new group if possible
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Look for matching group name, primary host name and secondary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IS_DISKQ(old_group)) { /* can't keep your own queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(tmpq, urdc->disk_queue, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(urdc->disk_queue, sizeof (urdc->disk_queue));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(utmp->primary.intf, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(utmp->secondary.intf, urdc->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Group already exists, so add this set to the group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must be same mode as existing group members */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must be same mode as existing group members */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(urdc->disk_queue, sizeof (urdc->disk_queue));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->disk_queue, utmp->disk_queue, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This must be a new group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trc = nst_create(_rdc_ioset, rdc_qfiller_thr, (void *)krdc, NST_SLEEP);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!unable to create queue filler daemon");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!old_group->rdc_writer && old_group->count == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Group now empty, so destroy */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Assure the we've stopped and the flusher thread has not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fallen back to sleep
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (old_group->ra_queue.qfill_sleeping != RDC_QFILL_DEAD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (old_group->ra_queue.qfflags & RDC_QFILLSTOP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take this rdc structure off the old group list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (ktmp = next; ktmp->group_next != krdc; ktmp = ktmp->group_next)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Leave existing group status alone */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->disk_queue, tmpq, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set flags for an rdc set, setting the group flags as necessary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE2(rdc_set_flags, int, krdc->index, int, flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* normal volume flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync state flags that are protected by a different lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bmap state flags that are protected by a different lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Clear flags for an rdc set, clearing the group flags as necessary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE2(rdc_clr_flags, int, krdc->index, int, flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* normal volume flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync state flags that are protected by a different lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bmap state flags that are protected by a different lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the flags for an rdc set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (urdc->flags | urdc->sync_flags | urdc->bmap_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialise flags for an rdc set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set flags for a many group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_flags(urdc, flags); /* set flags on local urdc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (krdc = krdc->many_next; krdc != this; krdc = krdc->many_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Clear flags for a many group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_clr_flags(urdc, flags); /* clear flags on local urdc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We must maintain the mflags based on the set of flags for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * all the urdc's that are chained up.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First look through all the urdc's and remove bits from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the 'flags' variable that are in use elsewhere.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (krdc = krdc->many_next; krdc != this; krdc = krdc->many_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now clear flags as necessary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_flags_log(rdc_u_info_t *urdc, int flags, char *why)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE2(rdc_set_flags_log, int, urdc->index, int, flags);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!sndr: %s:%s entered logging mode: %s",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana urdc->secondary.intf, urdc->secondary.file, why);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!sndr: %s:%s volume failed: %s",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana urdc->secondary.intf, urdc->secondary.file, why);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!sndr: %s:%s bitmap failed: %s",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana urdc->secondary.intf, urdc->secondary.file, why);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_lor(source, dest, len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * logically OR memory pointed to by source and dest, copying result into dest.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_lor(const uchar_t *source, uchar_t *dest, int len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < len; i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) spcs_s_inttostring(status, tmp1, sizeof (tmp1), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EGETSIZE, urdc->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (remote_size < (unsigned long long)urdc->volume_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cheat, and covert to int, until we have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * spcs_s_unsignedlonginttostring().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) spcs_s_inttostring(status, tmp2, sizeof (tmp2), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ESIZE, urdc->primary.intf,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR received update request for %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* don't understand what the client intends to do */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * warn II that this volume is in use by sndr so
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * II can validate the sizes of the master vs shadow
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and avoid trouble later down the line with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * size mis-matches between urdc->volume_size and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * what is returned from nsc_partsize() which may
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be the size of the master when replicating the shadow
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR refused update request for %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 1->many - all must be logging */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_MANY(krdc) && IS_STATE(urdc, RDC_PRIMARY)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR allowed update request for %s", update->volume);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bd.size = min(krdc->bitmap_size, (nsc_size_t)update->size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_MANY(krdc) && IS_STATE(urdc, RDC_PRIMARY)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* II (or something else) has updated us, so no need for a sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_get_vflags(urdc) & (RDC_SYNC_NEEDED | RDC_RSYNC_NEEDED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_clr_flags(urdc, RDC_SYNC_NEEDED | RDC_RSYNC_NEEDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_check()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 0 if the set is configured, enabled and the supplied
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * addressing information matches the in-kernel config, otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->primary.file, rdc_set->primary.file,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_check: primary file mismatch %s vs %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcmp(urdc->primary.addr.buf, rdc_set->primary.addr.buf,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_check: primary address mismatch for %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->secondary.file, rdc_set->secondary.file,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_check: secondary file mismatch %s vs %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcmp(urdc->secondary.addr.buf, rdc_set->secondary.addr.buf,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_check: secondary addr mismatch for %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Lookup enabled sets for a bitmap match
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Translate a pathname to index into rdc_k_info[].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns first match that is enabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_lookup_enabled(char *pathname, int allow_disabling)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (allow_disabling == 0 && krdc->type_flag & RDC_UNREGISTER)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* None found, or only a disabling one found, so try again */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Translate a pathname to index into rdc_k_info[].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns first match that is configured.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Used by enable & resume code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called with rdc_conf_lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Looks up a configured set with matching secondary interface:volume
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to check for illegal many-to-one volume configs. To be used during
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enable and resume processing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called with rdc_conf_lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set->secondary.intf, MAX_RDC_HOST_SIZE) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Looks up an rdc set to check if it is already configured, to be used from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * functions called from the config ioctl where the interface names can be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * used for comparison.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called with rdc_conf_lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->primary.file, rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->primary.intf, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->secondary.file, rdc_set->secondary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->secondary.intf, rdc_set->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Looks up a secondary hostname and device, to be used from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * functions called from the config ioctl where the interface names can be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * used for comparison.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called with rdc_conf_lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Looks up an rdc set to see if it is currently enabled, to be used on the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * server so that the interface addresses must be used for comparison, as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the interface names may differ from those used on the client.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(urdc->primary.file, rdc_set->primary.file) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(urdc->secondary.file, rdc_set->secondary.file) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(urdc->primary.addr.buf, rdc_set->primary.addr.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(urdc->secondary.addr.buf, rdc_set->secondary.addr.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return index of first multihop or 1-to-many
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Behavior controlled by setting ismany.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ismany TRUE (one-to-many)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ismany FALSE (multihops)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_lookup_multimany(rdc_k_info_t *krdc, const int ismany)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this host is the primary of the krdc set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1-many sets are linked by primary :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * look for matching primary on this host
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * multihop sets link primary to secondary :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * look for matching secondary on this host
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this host is the secondary of the krdc set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1-many sets are linked by primary, so if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this host is the secondary of the set this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cannot require 1-many linkage.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * multihop sets link primary to secondary :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * look for matching primary on this host
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Find a primary that is this host and is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * krdc but shares the same data volume as krdc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Find a secondary that is this host and is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * krdc but shares the same data volume as krdc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns secondary match that is configured.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Used by enable & resume code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called with rdc_conf_lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_CONT, "!krdc %p, %s %s (many_nxt %p multi_nxt %p)\n",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana p, q->primary.file, q->secondary.file, p->many_next,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (p && p != start);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG_MANY */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now find companion krdc */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!add_to_multi: lookup_multimany: mindex %d prim %s sec %s",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana mindex, urdc->primary.file, urdc->secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We are adding a new primary to a many
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * group that is the target of a multihop, just
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ignore it since we are linked in elsewhere.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Is previous leg using direct file I/O? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* It is, so cannot proceed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Is this leg using direct file I/O? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* It is, so cannot proceed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!add_to_multi: NULL multi_next index %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add a new set to the circular list of 1-to-many primaries and chain
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * up any multihop as well.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove a set from the circular list of 1-to-many primaries.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc: before remove_from_many");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove from multihop */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* search */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = old->many_next; p->many_next != old; p = p->many_next)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * old was part of a multihop, so switch multi pointers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to someone remaining on the many chain
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc: after remove_from_many empty");
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc: after remove_from_many");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_enable(rdc_set_t *rdc_set, int options, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Next check there aren't any enabled rdc sets which match. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EENABLED, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EMANY2ONE, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ENETBUF, rdc_set->primary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ENETBUF, rdc_set->secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check that the local data volume isn't in use as a bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check that the secondary data volume isn't in use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check that the local data vol is not in use as a diskqueue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_lookup_diskq(rdc_set->primary.file) >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check that the bitmap isn't in use as a data volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EBMPINUSE, local_bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check that the bitmap isn't already in use as a bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EBMPINUSE, local_bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check that the diskq (if here) is not in use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (diskq[0] && rdc_diskq_inuse(rdc_set, diskq)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set urdc->volume_size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EOPEN, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EOPEN, rdc_set->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy relevant parts of rdc_set to urdc field by field */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.intf, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.intf, rdc_set->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->group_name, rdc_set->group_name, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->disk_queue, rdc_set->disk_queue, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dup_rdc_netbuf(&rdc_set->primary.addr, &urdc->primary.addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.file, rdc_set->primary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.bitmap, rdc_set->primary.bitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dup_rdc_netbuf(&rdc_set->secondary.addr, &urdc->secondary.addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.file, rdc_set->secondary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.bitmap, rdc_set->secondary.bitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before we try to add to group, or create one, check out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if we are doing the wrong thing with the diskq
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (urdc->disk_queue[0] && (options & RDC_OPT_SYNC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = add_to_group(krdc, options, RDC_CMD_ENABLE)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EQNOADD, rdc_set->disk_queue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set->secondary.intf, rdc_set->secondary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * maxfbas was set in rdc_dev_open as primary's maxfbas.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If diskq's maxfbas is smaller, then use diskq's.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (grp && RDC_IS_DISKQ(grp) && (grp->diskqfd != 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!_rdc_enable: diskq maxfbas = %"
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!_rdc_enable: diskq maxfbas failed (%d)",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!_rdc_enable: diskq reserve failed (%d)", rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->direct_file, rdc_set->direct_file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((options & RDC_OPT_PRIMARY) && rdc_set->direct_file[0]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The rdc set is configured but not yet enabled. Other operations must
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ignore this set until it is enabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Still unknown */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = rdc_create_svinfo(rhost, addrp, urdc->netconfig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->netconfig = NULL; /* This will be no good soon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Don't set krdc->intf here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_enable_bitmap(krdc, options & RDC_OPT_SETBMP) < 0)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!_rdc_enable: krdc->lsrv already set: %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* And finally */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should we set the whole group logging? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EREGISTER, urdc->primary.file);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!nsc_register_path failed %s",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR: enabled %s %s", urdc->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EBITMAP, rdc_set->primary.bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EBITMAP, rdc_set->secondary.bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_enable(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _rdc_enable(uparms->rdc_set, uparms->options, kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_disable(rdc_k_info_t *krdc, rdc_config_t *uap, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((uap->options & RDC_OPT_FORCE_DISABLE) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_ASYNC(urdc) && RDC_IS_DISKQ(krdc->group) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((!IS_STATE(urdc, RDC_LOGGING)) && (!QEMPTY(q)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EQNOTEMPTY, urdc->disk_queue);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR: disabled %s %s", urdc->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No new io can come in through the io provider.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Wait for the async flusher to finish.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_ASYNC(urdc) && !RDC_IS_DISKQ(krdc->group)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int tries = 2; /* in case of hopelessly stuck flusher threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ok, force it to happen... */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!SNDR: async I/O pending and not flushed "
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "for %s during disable",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must not hold group lock during this function */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdc_dump_alloc_bufs_cd(krdc->index) == EAGAIN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we should now unregister the queue, with no conflicting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locks held. This is the last(only) member of the group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc->group->count == 1) { /* stop protecting queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!_rdc_disable: possible mem leak, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dcio_bitmap");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_disable(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Checks whether the state of one of the other sets in the 1-many or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * multi-hop config should prevent a sync from starting on this one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return NULL if no just cause or impediment is found, otherwise return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a pointer to the offending set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_allow_pri_sync(rdc_u_info_t *urdc, int options)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * In the reverse sync case we need to check the previous leg of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the multi-hop config. The link to that set can be from any of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the 1-many list, so as we go through we keep an eye open for it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((options & RDC_OPT_REVERSE) && (IS_MULTI(krdc))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This set links to the first leg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reverse sync needed is bad, as it means a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reverse sync in progress or started and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * didn't complete, so this primary volume
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is not consistent. So we shouldn't copy
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it to its secondary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Reverse, so see if we need to spot kmulti */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This set links to the first leg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Non-logging is bad, as the bitmap will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be updated with the bits for this sync.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ktmp = kmulti; /* In case we decide we do need to use ktmp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Replicating is bad as data is already flowing to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the target of the requested sync operation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Forward sync in progress is bad, as data is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * already flowing to the target of the requested
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync operation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reverse sync in progress is bad, as the primary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * has already decided which data to copy.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Clear the "sync needed" flags, as the multi-hop secondary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will be updated via this requested sync operation, so does
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not need to complete its aborted forward sync.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_MANY(krdc) && (options & RDC_OPT_REVERSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Clear any "reverse sync needed" flags, as the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * volume will be updated via this requested
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync operation, so does not need to complete
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * its aborted reverse sync.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_syncthr_t *syncinfo = (rdc_syncthr_t *)thrinfo;
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana DTRACE_PROBE2(rdc_sync_loop_netwrite_start, int, krdc->index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = nsc_alloc_buf(RDC_U_FD(krdc), syncinfo->offset, syncinfo->len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!RDC_SUCCESS(rc) || krdc->remote_index < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((krdc->disk_status == 1) || (krdc->dcio_bitmap == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = rdc_net_write(krdc->index, krdc->remote_index, handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle->sb_pos, handle->sb_len, RDC_NOSEQ, RDC_NOQUE, NULL)) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The following is to handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the case where the secondary side
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * has thrown our buffer handle token away in a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attempt to preserve its health on restart
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_sync_wrthr: remote write failed (%d) "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * see above comments on _rdc_sync_wrthr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_syncthr_t *syncinfo = (rdc_syncthr_t *)thrinfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = nsc_alloc_buf(RDC_U_FD(krdc), syncinfo->offset, syncinfo->len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!RDC_SUCCESS(rc) || krdc->remote_index < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((krdc->disk_status == 1) || (krdc->dcio_bitmap == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = rdc_net_read(krdc->index, krdc->remote_index, handle,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_sync_rdthr: remote read failed(%d)", rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_bitmap_many(krdc, handle->sb_pos, handle->sb_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = nsc_write(handle, handle->sb_pos, handle->sb_len, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_flags_log(urdc, RDC_VOL_FAILED, "nsc_write failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _rdc_sync_wrthr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync loop write thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if there are avail threads, we have not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * used up the pipe, so the sync loop will, if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * possible use these to multithread the write/read
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_syncthr_t *syncinfo = (rdc_syncthr_t *)thrinfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _rdc_rsrv_devs(krdc, RDC_RAW, RDC_INTERNAL);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!_rdc_sync_wrthr: NULL bitmap");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_SET_BITMASK(syncinfo->offset, syncinfo->len, &bitmask);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_CLR_BITMAP(krdc, syncinfo->offset, syncinfo->len, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * done with this, get rid of it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the status is not freed, it should still be a status chain
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that _rdc_sync() has the head of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * decrement the global sync thread num
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * krdc specific stuff
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_setup_syncthr(rdc_syncthr_t **synthr, nsc_off_t offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t len, rdc_k_info_t *krdc, sync_status_t *stats)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* alloc here, free in the sync thread */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rdc_syncthr_t *)kmem_zalloc(sizeof (rdc_syncthr_t), KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = (sync_status_t *)kmem_zalloc(sizeof (*s), KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_sync_status_ok(sync_status_t *status, int *offset)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_sync_status_ok: checked %d statuses", i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _rdc_sync() : rdc sync loop
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_STATE(urdc, RDC_QUEUING) && !IS_STATE(urdc, RDC_FULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* flusher is handling the sync in the update case */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pre-allocate a handle if we can - speeds up the sync.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alloc_h = nsc_alloc_handle(RDC_U_FD(krdc), NULL, NULL, NULL);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!rdc sync: failed to pre-alloc handle");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as this while loop can also move data, it is counted as a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync loop thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (krdc->disk_status == 1 || krdc->dcio_bitmap == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* skip unnecessary chunks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check for boundary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find maximal length we can transfer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we can only read maxfbas anyways */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* truncate to the io provider limit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the update is larger than a bitmap chunk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then truncate to a whole number of bitmap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the update is smaller than a bitmap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chunk, this must be the last write.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Find out if we can reserve a thread here ...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * note: skip the mutex for the first check, if the number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is up there, why bother even grabbing the mutex to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only realize that we can't have a thread anyways
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mtsync && sync_info.active_thr < RDC_MAX_SYNC_THREADS) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "allocate status for mt sync");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * syncinfo protected by sync_info lock but
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not part of the sync_info structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be careful if moving
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* overwrite buffer with remote data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts = rdc_net_read(krdc->index, krdc->remote_index,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!rdc sync: remote read failed (%d)", sts);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* commit locally */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reverse sync needed already set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "write failed during sync");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* send local data to remote */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle->sb_len, RDC_NOSEQ, RDC_NOQUE, NULL)) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The following is to handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the case where the secondary side
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * has thrown our buffer handle token away in a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attempt to preserve its health on restart
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!rdc sync: remote write failed (%d) 0x%x",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!_rdc_sync: NULL bitmap");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Only release/reserve if someone is waiting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (krdc->devices->id_release || nsc_waiting(RDC_U_FD(krdc))) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "failed to pre-alloc handle");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if sync_completed is 0 here,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we know that the main sync thread failed anyway
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so just free the statuses and fail
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sync_completed && (_rdc_sync_status_ok(sync_status, &rc) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_completed = 0; /* at least 1 thread failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we didn't increment, we didn't even sync,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so don't dec sync_info.active_thr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) rdc_net_state(krdc->index, CCIO_ENABLELOG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_flags_log(urdc, RDC_LOGGING, "sync failed to complete");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_sync(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((krdc->type_flag == 0) || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed or we raced with a teardown */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ESETNOTLOGGING, urdc->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ENOTPRIMARY, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((options & RDC_OPT_REVERSE) && (IS_STATE(urdc, RDC_QUEUING))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cannot reverse sync when queuing, need to go logging first
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EQNORSYNC, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc->intf = rdc_add_to_if(svp, &(urdc->primary.addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EADDTOIF, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Implies reserve failed when previous resume was done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rdc_get_vflags(urdc) & RDC_BMP_FAILED) && (krdc->bitmapfd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ubad = rdc_allow_pri_sync(urdc, options)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * there is a small window where _rdc_sync is still
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * running, but has cleared the RDC_SYNCING flag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use aux_state which is only cleared
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * after _rdc_sync had done its 'death' broadcast.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "RDC_AUXSYNCIP set, SYNCING off");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ESYNCING, rdc_set->primary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ESYNCING, rdc_set->primary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cannot forward sync if a reverse sync is needed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ERSYNCNEEDED, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if the rdc set is accessible on the remote node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_net_getstate(krdc, &sm, &um, &md, FALSE) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remote end may be inaccessible, or the rdc set is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enabled at the remote end.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ECONNOPEN, urdc->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc->remote_index = rdc_net_state(index, CCIO_RSYNC);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc->remote_index = rdc_net_state(index, CCIO_SLAVE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remote note probably not in a valid state to be synced,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as the state was fetched OK above.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ERSTATE, urdc->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) rdc_net_state(krdc->index, CCIO_ENABLELOG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_mflags(urdc, RDC_SLAVE | RDC_RSYNC_NEEDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_ENABLED(umulti) && (rdc_get_vflags(umulti) &
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "failed to read remote bitmap");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is a full sync (not an update sync), mark the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * entire bitmap dirty
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allow diskq->memq flusher to wake up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc->group->ra_queue.qfflags &= ~RDC_QFILLSLEEP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if this is a full sync on a non-diskq set or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a diskq set that has failed, clear the async flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* full syncs, or core queue are synchronous */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the queue failed because it was full, lets see
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if we can restart it. After _rdc_sync() is done
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the modes will switch and we will begin disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * queuing again. NOTE: this should only be called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * once per group, as it clears state for all group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * members, also clears the async flag for all members
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* don't add insult to injury by flushing a dead queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if we are updating, and a diskq and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the async thread isn't active, start
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((thrcount-- > 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For a reverse sync, merge the current bitmap with all other sets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that share this volume.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May merge more than once */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_u_info_t *umulti = &rdc_u_info[kmulti->index];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now set off the sync itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void (*)(void *))_rdc_sync, (void *)krdc, FALSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We used to just return here,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * but we need to clear the AUXSYNCIP bit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and there is a very small chance that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * someone may be waiting on the disk_status flag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * need the group lock held at failed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We use this flag now to make halt_sync() wait for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * us to terminate and let us take the group lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sync_completed && (options & RDC_OPT_REVERSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_suspend(rdc_k_info_t *krdc, rdc_set_t *rdc_set, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, rdc_set->primary.file,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR: suspended %s %s", urdc->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_ASYNC(urdc) && !RDC_IS_DISKQ(krdc->group)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int tries = 2; /* in case of possibly stuck flusher threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ok, force it to happen... */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!SNDR: async I/O pending and not flushed "
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "for %s during suspend",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must not hold group lock during this function */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdc_dump_alloc_bufs_cd(krdc->index) == EAGAIN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Don't rdc_clear_state, unlike _rdc_disable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we should now unregister the queue, with no conflicting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locks held. This is the last(only) member of the group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc->group->count == 1) { /* stop protecting queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!_rdc_suspend: possible mem leak, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dcio_bitmap");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_suspend(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _rdc_suspend(krdc, uparms->rdc_set, kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_resume(rdc_set_t *rdc_set, int options, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Next check there aren't any enabled rdc sets which match. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EENABLED, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EMANY2ONE, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ENETBUF, rdc_set->primary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ENETBUF, rdc_set->secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check that the local data volume isn't in use as a bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check that the secondary data volume isn't in use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check that the bitmap isn't in use as a data volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EBMPINUSE, local_bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check that the bitmap isn't already in use as a bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EBMPINUSE, local_bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set urdc->volume_size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EOPEN, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EOPEN, rdc_set->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy relevant parts of rdc_set to urdc field by field */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.intf, rdc_set->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.intf, rdc_set->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->group_name, rdc_set->group_name, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dup_rdc_netbuf(&rdc_set->primary.addr, &urdc->primary.addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.file, rdc_set->primary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.bitmap, rdc_set->primary.bitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dup_rdc_netbuf(&rdc_set->secondary.addr, &urdc->secondary.addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.file, rdc_set->secondary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.bitmap, rdc_set->secondary.bitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->disk_queue, rdc_set->disk_queue, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((options & RDC_OPT_SYNC) && urdc->disk_queue[0]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * init flags now so that state left by failures in add_to_group()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are preserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc1 = add_to_group(krdc, options, RDC_CMD_RESUME)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc1 == RDC_EQNOADD) { /* something went wrong with queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* don't return a failure here, continue with resume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* some other group add failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set->secondary.intf, rdc_set->secondary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * maxfbas was set in rdc_dev_open as primary's maxfbas.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If diskq's maxfbas is smaller, then use diskq's.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (grp && RDC_IS_DISKQ(grp) && (grp->diskqfd != 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!_rdc_resume: diskq maxfbas = %"
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!_rdc_resume: diskq maxfbas failed (%d)",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!_rdc_resume: diskq reserve failed (%d)", rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->direct_file, rdc_set->direct_file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((options & RDC_OPT_PRIMARY) && rdc_set->direct_file[0]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The rdc set is configured but not yet enabled. Other operations must
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ignore this set until it is enabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set tunable defaults, we'll pick up tunables from the header later */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = rdc_create_svinfo(rhost, addrp, urdc->netconfig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->netconfig = NULL; /* This will be no good soon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Don't set krdc->intf here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if the bitmap resume isn't clean, it will clear queuing flag */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!_rdc_resume: krdc->lsrv already set: %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* And finally */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should we set the whole group logging? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EREGISTER, urdc->primary.file);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!nsc_register_path failed %s",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR: resumed %s %s", urdc->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EBITMAP, urdc->primary.bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EBITMAP, urdc->secondary.bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Don't unset krdc->intf here, unlike _rdc_enable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configured but not enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(IS_CONFIGURED(krdc) && !IS_ENABLED(urdc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_resume(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _rdc_resume(uparms->rdc_set, uparms->options, kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if rdc_group_log is called because a volume has failed,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we must disgard the queue to preserve write ordering.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * later perhaps, we can keep queuing, but we would have to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rewrite the i/o path to acommodate that. currently, if there
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is a volume failure, the buffers are satisfied remotely and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * there is no way to satisfy them from the current diskq config
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * phew, if we do that.. it will be difficult
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; ; p = p->group_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wait here, until all in flight async i/o's have either
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * finished or failed. Avoid the race with r_net_state()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which tells remote end to log.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bail = RDC_CLNT_TMOUT * 2; /* to include retries */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_group_log(rdc_k_info_t *krdc, int flag, char *why)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((flag & RDC_QUEUING) && (!IS_STATE(urdc, RDC_SYNCING)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag_op = rdc_set_flags; /* keep queuing, link error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag_op = rdc_clr_flags; /* stop queuing, user request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; p != krdc; p = p->group_next) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!SNDR:Group point-in-time for grp: %s %s:%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->group_name, urdc->primary.intf, urdc->secondary.intf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set group logging at the same PIT under rdc_many_lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; p != krdc; p = p->group_next) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "consistency group member following leader");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This can cause the async threads to fail,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which in turn will call rdc_group_log()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * again. Release the lock and re-aquire.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdc_dump_alloc_bufs_cd(krdc->index) == EAGAIN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a little lazy, but neat. recall dump_alloc_bufs to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ensure that the queue pointers & seq are reset properly
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * after we have waited for inflight stuff
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdc_dump_alloc_bufs_cd(krdc->index) == EAGAIN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IS_DISKQ(krdc->group) && (!(flag & RDC_QUEUING))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fail or user request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Tell other node to start logging */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (krdc->lsrv && krdc->intf && !krdc->intf->if_down)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; p != krdc; p = p->group_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No point in time is possible, just deal with single set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_net_getstate(krdc, &sm, &um, &md, TRUE) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "failed to read remote state");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdc_dump_alloc_bufs_cd(krdc->index) == EAGAIN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a little lazy, but neat. recall dump_alloc_bufs to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ensure that the queue pointers & seq are reset
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * properly after we have waited for inflight stuff
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdc_dump_alloc_bufs_cd(krdc->index) == EAGAIN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Tell other node to start logging */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * just in case any threads were in flight during log cleanup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_log(rdc_k_info_t *krdc, rdc_set_t *rdc_set, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc->intf = rdc_add_to_if(svp, &(urdc->primary.addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krdc->intf = rdc_add_to_if(svp, &(urdc->secondary.addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EADDTOIF, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_group_log(krdc, RDC_FLUSH | RDC_ALLREMOTE, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ESYNCING, urdc->primary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_log(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_wait(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rdc_get_vflags(urdc) & (RDC_SYNCING | RDC_PRIMARY)) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cv_wait_sig(&krdc->synccv, &net_blk_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_health(rdc_config_t *uparms, spcs_s_info_t kstatus, int *rvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_isactive_if(&(urdc->primary.addr), &(urdc->secondary.addr)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_reconfig(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rdc_get_vflags(urdc) & RDC_BMP_FAILED) && (krdc->bitmapfd))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Move to a new bitmap if necessary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->primary.bitmap, uparms->rdc_set->primary.bitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* simulate a succesful rdc_move_bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->secondary.bitmap, uparms->rdc_set->secondary.bitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* simulate a succesful rdc_move_bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * At this point we fail any other type of reconfig
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if not in logging mode and we did not do a bitmap reconfig
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(rdc_get_vflags(urdc) & RDC_LOGGING) && rc == -2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no other changes possible unless logging */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Change direct file if necessary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(urdc->direct_file, uparms->rdc_set->direct_file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->direct_file, uparms->rdc_set->direct_file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Change group if necessary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(urdc->group_name, uparms->rdc_set->group_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(orig_group, urdc->group_name, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->group_name, uparms->rdc_set->group_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rc < 0) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana urdc->secondary.intf, urdc->secondary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Switch sync/async if necessary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Only member of group. Can change sync/async */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* switch to sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (((uparms->options & RDC_OPT_ASYNC) != 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* switch to async */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Reverse concept of primary and secondary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((uparms->options & RDC_OPT_REVERSE_ROLE) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disallow role reversal for advanced configurations
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana spcs_s_add(kstatus, RDC_EMASTER, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy primary parts of urdc to rdc_set field by field */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.primary.intf, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.primary.file, urdc->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(rdc_set.primary.bitmap, urdc->primary.bitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now overwrite urdc primary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.intf, urdc->secondary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.file, urdc->secondary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->primary.bitmap, urdc->secondary.bitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now ovwewrite urdc secondary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.intf, rdc_set.primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.file, rdc_set.primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(urdc->secondary.bitmap, rdc_set.primary.bitmap,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!rdc_reconfig: bitmap_ref alloc %"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana (rdc_get_vflags(urdc) & RDC_SYNC_NEEDED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Primary, so reverse sync needed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rdc_get_vflags(urdc) & RDC_RSYNC_NEEDED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Secondary, so forward sync needed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rewrite bitmap header
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no other changes possible unless logging */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_ENOTLOGGING, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_reset(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rdc_get_vflags(urdc) & RDC_BMP_FAILED) && (krdc->bitmapfd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fix direct file if necessary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rdc_get_vflags(urdc) & RDC_PRIMARY) && urdc->direct_file[0]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cleared an error so we should be in logging mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_flags_log(urdc, RDC_LOGGING, "set reset");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_tunable(rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; p != krdc; p = p->group_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; p != krdc; p = p->group_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EQNOQUEUE, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* queue will fail if this fails */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) rdc_stamp_diskq(krdc, 0, RDC_GROUP_LOCKED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EQNOQUEUE, urdc->primary.intf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* queue will fail if this fails */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) rdc_stamp_diskq(krdc, 0, RDC_GROUP_LOCKED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; p != krdc; p = p->group_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Changed autosync, so update rest of the group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = krdc->group_next; p != krdc; p = p->group_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_status(void *arg, int mode, rdc_config_t *uparms, spcs_s_info_t kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern int rdc_status_copy32(const void *, void *, size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A resume or enable failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_add(kstatus, RDC_EALREADY, uparms->rdc_set->primary.file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sneak out qstate in urdc->flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this is harmless because it's value is not used
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in urdc->flags. the real qstate is kept in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * group->diskq->disk_hdr.h.state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr = (char *)arg + offsetof(struct rdc_config32, rdc_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = rdc_status_copy32(urdc, ptr, sizeof (struct rdc_set32),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr = (char *)arg + offsetof(struct rdc_config, rdc_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = ddi_copyout(urdc, ptr, sizeof (struct rdc_set), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear out qstate from flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Overwrite the bitmap with one supplied by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy into all bitmaps that are tracking this volume.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_bitmapset(int op, char *sechost, char *secdev, void *bmapaddr, int bmapsz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must be modulo FBA */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!bitmapset: Offset is not on an FBA "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must be modulo FBA */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!bitmapset: Size is not on an FBA "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0 || (krdc->type_flag & RDC_DISABLEPEND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte indexvec = kmem_alloc(rdc_max_sets * sizeof (int), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte grouplocks = kmem_alloc(rdc_max_sets * sizeof (kmutex_t *), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I now have this set, and I want to take the group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lock on it, and all the group locks of all the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sets on the many and multi-hop links.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I have to take the many lock while traversing the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I think I also need to set the busy count on this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set, otherwise when I drop the conf_lock, what
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will stop some other process from coming in and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * issuing a disable?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Take this initial sets group lock first.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attempt to take the group lock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if we don't already have it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < groupind; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* already have the group lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * didn't find our lock in our collection,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attempt to take group lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < groupind; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = rdc_checkforbitmap(ktmp->index, off + bmapsz);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This can't be in our group already.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < groupind; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = rdc_checkforbitmap(kmulti->index, off + bmapsz);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = rdc_installbitmap(op, bmapaddr, bmapsz, off, mode, indexvec,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < groupind; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(indexvec, rdc_max_sets * sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(grouplocks, rdc_max_sets * sizeof (kmutex_t *));
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!checkforbitmap: No bitmap for set (%s:%s)",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana urdc->secondary.intf, urdc->secondary.file);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!checkbitmap: Bitmap exceeded, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "incore %" NSC_SZFMT " user supplied %" NSC_SZFMT
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana limit, urdc->secondary.intf, urdc->secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy the user supplied bitmap to this set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_installbitmap(int op, void *bmapaddr, int bmapsz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (left > 0) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!installbitmap: Copyin failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Maybe this should be just done once outside of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the the loop? (Less work, but leaves a window
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * where the bits_set doesn't match the bitmap).
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!installbitmap: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "write_bitmap_fba failed "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _rdc_config
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_rdc_config(void *arg, int mode, spcs_s_info_t kstatus, int *rvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(arg, STRUCT_BUF(uparms), STRUCT_SIZE(uparms), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STRUCT_SET_HANDLE(rs, mode, STRUCT_FGETP(uparms, rdc_set));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STRUCT_SET_HANDLE(pa, mode, STRUCT_FADDR(rs, primary));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STRUCT_SET_HANDLE(sa, mode, STRUCT_FADDR(rs, secondary));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd == RDC_CMD_ENABLE || cmd == RDC_CMD_RESUME) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fsvaddr.buf = kmem_zalloc(fsvaddr.len, KM_SLEEP);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!copyin failed primary.addr 2");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tsvaddr.buf = kmem_zalloc(tsvaddr.len, KM_SLEEP);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!copyin failed secondary addr");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fsvaddr.buf = kmem_zalloc(fsvaddr.len, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tsvaddr.buf = kmem_zalloc(tsvaddr.len, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (STRUCT_FGETP(uparms, rdc_set->netconfig) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte knconf = kmem_zalloc(sizeof (*knconf), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(STRUCT_FGETP(uparms, rdc_set->netconfig),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STRUCT_BUF(knconf_tmp), STRUCT_SIZE(knconf_tmp), mode)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!copyin failed netconfig");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte knconf->knc_semantics = STRUCT_FGET(knconf_tmp, knc_semantics);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte knconf->knc_protofmly = STRUCT_FGETP(knconf_tmp, knc_protofmly);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte knconf->knc_proto = STRUCT_FGETP(knconf_tmp, knc_proto);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte knconf->knc_rdev = STRUCT_FGET(knconf_tmp, knc_rdev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = ddi_copyin(knconf->knc_protofmly, pf, KNC_STRSIZE, mode);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!copyin failed parms protofmly");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = ddi_copyin(knconf->knc_proto, p, KNC_STRSIZE, mode);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!copyin failed parms proto");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* !NULL netconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy relevant parts of rdc_config to uap field by field */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(uap->rdc_set[0].primary.intf, STRUCT_FGETP(pa, intf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(uap->rdc_set[0].primary.file, STRUCT_FGETP(pa, file),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(uap->rdc_set[0].primary.bitmap, STRUCT_FGETP(pa, bitmap),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].flags = STRUCT_FGET(uparms, rdc_set->flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].index = STRUCT_FGET(uparms, rdc_set->index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].setid = STRUCT_FGET(uparms, rdc_set->setid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].sync_pos = STRUCT_FGET(uparms, rdc_set->sync_pos);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].volume_size = STRUCT_FGET(uparms, rdc_set->volume_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].bits_set = STRUCT_FGET(uparms, rdc_set->bits_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].autosync = STRUCT_FGET(uparms, rdc_set->autosync);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].maxqfbas = STRUCT_FGET(uparms, rdc_set->maxqfbas);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].maxqitems = STRUCT_FGET(uparms, rdc_set->maxqitems);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].asyncthr = STRUCT_FGET(uparms, rdc_set->asyncthr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].syshostid = STRUCT_FGET(uparms, rdc_set->syshostid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].primary.addr = fsvaddr; /* struct copy */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uap->rdc_set[0].secondary.addr = tsvaddr; /* struct copy */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(uap->rdc_set[0].secondary.intf, STRUCT_FGETP(sa, intf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(uap->rdc_set[0].secondary.file, STRUCT_FGETP(sa, file),
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana STRUCT_FGETP(rs, direct_file), NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(uap->rdc_set[0].group_name, STRUCT_FGETP(rs, group_name),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(uap->rdc_set[0].disk_queue, STRUCT_FGETP(rs, disk_queue),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialise the threadset if it has not already been done.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This has to be done now, not in rdcattach(), because
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdcattach() can be called before nskernd is running (eg.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * boot -r) in which case the nst_init() would fail and hence
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the attach would fail.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Threadset creation is locked by the rdc_conf_lock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * destruction is inherently single threaded as it is done in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _rdc_unload() which must be the last thing performed by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdcdetach().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Tune the threadset size after a successful rdc_set addition
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or removal.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * krdc->group->lock held on entry to halt_sync()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If a sync is in progress, halt it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cv_wait_sig(&krdc->haltcv, &krdc->group->lock) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return size in blocks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _rdc_rsrv_devs(krdc, RDC_RAW, RDC_INTERNAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create a new dataset for this transfer, and add it to the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of datasets via the net_dataset pointer in the krdc.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_net_add_set: bad index %d", index);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_net_add_set: kmem_alloc failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* raced with a disable command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared the id generator, (and the locks).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dset2 = krdc->net_dataset; dset2; dset2 = dset2->next) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "rdc_net_add_set duplicate id %p:%d %p:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fetch the previously added dataset.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_net_get_set: bad index %d", index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Decrement the inuse counter. Data may be freed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_net_put_set(int index, rdc_net_dataset_t *dset)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_net_put_set: bad index %d", index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mark that we are finished with this set. Decrement inuse
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * counter, mark as needing deletion, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * remove from linked list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_net_del_set(int index, rdc_net_dataset_t *dset)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_net_del_set: bad index %d", index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free all the memory associated with this set, and remove from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Enters and exits with dc_sleep lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_net_free_set(rdc_k_info_t *krdc, rdc_net_dataset_t *dset)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dsetp = &krdc->net_dataset; *dsetp; dsetp = &((*dsetp)->next)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!rdc_net_free_set: Unable to find "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * unlinked from list. Free all the data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free my core.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free all the dataitems and the data it points to.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate and initialize a rdc_aio_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_aio_tbuf_get(void *n, void *h, int pos, int len, int flag, int index, int s)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!_rdcaiotbufget: kmem_alloc failed bp aio");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set up seq later, in case thr create fails */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_aio_buf_get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get an aio_buf
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc: rdc_aio_buf_get bad index %x", index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_aio_buf_del
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delete a aio_buf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (pp = &h->rdc_anon; *pp; pp = &((*pp)->next)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(p, sizeof (*p));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_aio_buf_add
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add a aio_buf.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_aio_buf_add: kmem_alloc failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kmemalloc a new group structure and setup the common
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte group = kmem_zalloc(sizeof (rdc_group_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte group->diskq.lastio = kmem_zalloc(sizeof (rdc_aio_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&group->lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&group->ra_queue.net_qlock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&group->diskqmutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&group->diskq.disk_qlock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&group->diskq.head_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&group->addthrnumlk, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&group->unregistercv, NULL, CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&group->asyncqcv, NULL, CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&group->diskq.busycv, NULL, CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&group->diskq.qfullcv, NULL, CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&group->ra_queue.qfcv, NULL, CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(group->synccount == 0); /* group was kmem_zalloc'ed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add default number of threads to the flusher thread set, plus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one extra thread for the disk queue flusher
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_newgroup: nst_add_thread failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* try to remove flusher threads that this group added to _rdc_flset */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nst_del_thread(_rdc_flset, group->rdc_addthrnum + 3) !=
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_delgroup: nst_del_thread failed");