if (atomic_test_mask (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status) && port->erp_action.action == ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) { debug_text_event(adapter->erp_dbf, 4, "pf_actenq_drp"); 
if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) { if (port->erp_action.action != ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) { ZFCP_LOG_INFO("dropped erp action %i (port " "0x%016Lx, action in use: %i)\n", action, port->wwpn, port->erp_action.action); debug_text_event(adapter->erp_dbf, 4, "pf_actenq_drp"); } else debug_text_event(adapter->erp_dbf, 4, "pf_actenq_drpcp"); 
zfcp_erp_action_enqueue(int action,			struct zfcp_adapter *adapter,			struct zfcp_port *port, struct zfcp_unit *unit){	int retval = 1;	struct zfcp_erp_action *erp_action = NULL;	int stronger_action = 0;	u32 status = 0;	/*	 * We need some rules here which check whether we really need	 * this action or whether we should just drop it.	 * E.g. if there is a unfinished 'Reopen Port' request then we drop a	 * 'Reopen Unit' request for an associated unit since we can't	 * satisfy this request now. A 'Reopen Port' action will trigger	 * 'Reopen Unit' actions when it completes.	 * Thus, there are only actions in the queue which can immediately be	 * executed. This makes the processing of the action queue more	 * efficient.	 */	if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,			      &adapter->status))		return -EIO;	debug_event(adapter->erp_dbf, 4, &action, sizeof (int));	/* check whether we really need this */	switch (action) {	case ZFCP_ERP_ACTION_REOPEN_UNIT:		if (atomic_test_mask		    (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)) {			debug_text_event(adapter->erp_dbf, 4, "u_actenq_drp");			debug_event(adapter->erp_dbf, 4, &port->wwpn,				    sizeof (wwn_t));			debug_event(adapter->erp_dbf, 4, &unit->fcp_lun,				    sizeof (fcp_lun_t));			goto out;		}		if (!atomic_test_mask		    (ZFCP_STATUS_COMMON_RUNNING, &port->status) ||		    atomic_test_mask		    (ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {			goto out;		}		if (!atomic_test_mask		    (ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) {			stronger_action = ZFCP_ERP_ACTION_REOPEN_PORT;			unit = NULL;		}		/* fall through !!! */	case ZFCP_ERP_ACTION_REOPEN_PORT:		if (atomic_test_mask		    (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) {			debug_text_event(adapter->erp_dbf, 4, "p_actenq_drp");			debug_event(adapter->erp_dbf, 4, &port->wwpn,				    sizeof (wwn_t));			goto out;		}		/* fall through !!! */	case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:		if (atomic_test_mask		    (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)		    && port->erp_action.action ==		    ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) {			debug_text_event(adapter->erp_dbf, 4, "pf_actenq_drp");			debug_event(adapter->erp_dbf, 4, &port->wwpn,				    sizeof (wwn_t));			goto out;		}		if (!atomic_test_mask		    (ZFCP_STATUS_COMMON_RUNNING, &adapter->status) ||		    atomic_test_mask		    (ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {			goto out;		}		if (!atomic_test_mask		    (ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) {			stronger_action = ZFCP_ERP_ACTION_REOPEN_ADAPTER;			port = NULL;		}		/* fall through !!! */	case ZFCP_ERP_ACTION_REOPEN_ADAPTER:		if (atomic_test_mask		    (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)) {			debug_text_event(adapter->erp_dbf, 4, "a_actenq_drp");			goto out;		}		break;	default:		debug_text_exception(adapter->erp_dbf, 1, "a_actenq_bug");		debug_event(adapter->erp_dbf, 1, &action, sizeof (int));		ZFCP_LOG_NORMAL("bug: unknown erp action requested "				"on adapter %s (action=%d)\n",				zfcp_get_busid_by_adapter(adapter), action);		goto out;	}	/* check whether we need something stronger first */	if (stronger_action) {		debug_text_event(adapter->erp_dbf, 4, "a_actenq_str");		debug_event(adapter->erp_dbf, 4, &stronger_action,			    sizeof (int));		ZFCP_LOG_DEBUG("stronger erp action %d needed before "			       "erp action %d on adapter %s\n",			       stronger_action, action,			       zfcp_get_busid_by_adapter(adapter));		action = stronger_action;	}	/* mark adapter to have some error recovery pending */	atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);	/* setup error recovery action */	switch (action) {	case ZFCP_ERP_ACTION_REOPEN_UNIT:		zfcp_unit_get(unit);		atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status);		erp_action = &unit->erp_action;		if (!atomic_test_mask		    (ZFCP_STATUS_COMMON_RUNNING, &unit->status))			status = ZFCP_STATUS_ERP_CLOSE_ONLY;		break;	case ZFCP_ERP_ACTION_REOPEN_PORT:	case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:		zfcp_port_get(port);		zfcp_erp_action_dismiss_port(port);		atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);		erp_action = &port->erp_action;		if (!atomic_test_mask		    (ZFCP_STATUS_COMMON_RUNNING, &port->status))			status = ZFCP_STATUS_ERP_CLOSE_ONLY;		break;	case ZFCP_ERP_ACTION_REOPEN_ADAPTER:		zfcp_adapter_get(adapter);		zfcp_erp_action_dismiss_adapter(adapter);		atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);		erp_action = &adapter->erp_action;		if (!atomic_test_mask		    (ZFCP_STATUS_COMMON_RUNNING, &adapter->status))			status = ZFCP_STATUS_ERP_CLOSE_ONLY;		break;	}	debug_text_event(adapter->erp_dbf, 4, "a_actenq");	memset(erp_action, 0, sizeof (struct zfcp_erp_action));	erp_action->adapter = adapter;	erp_action->port = port;	erp_action->unit = unit;	erp_action->action = action;	erp_action->status = status;	++adapter->erp_total_count;	/* finally put it into 'ready' queue and kick erp thread */	list_add(&erp_action->list, &adapter->erp_ready_head);	up(&adapter->erp_ready_sem);	retval = 0; out:	return retval;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/3734d24b2e8d85796de70c13705cfb7cbb1d77df/zfcp_erp.c/buggy/drivers/s390/scsi/zfcp_erp.c