Exemplo n.º 1
0
static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
        struct zfcp_adapter *adapter,
        struct zfcp_port *port,
        struct scsi_device *sdev)
{
    struct zfcp_erp_action *erp_action;
    struct zfcp_scsi_dev *zfcp_sdev;

    switch (need) {
    case ZFCP_ERP_ACTION_REOPEN_LUN:
        zfcp_sdev = sdev_to_zfcp(sdev);
        if (!(act_status & ZFCP_STATUS_ERP_NO_REF))
            if (scsi_device_get(sdev))
                return NULL;
        atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
                        &zfcp_sdev->status);
        erp_action = &zfcp_sdev->erp_action;
        memset(erp_action, 0, sizeof(struct zfcp_erp_action));
        erp_action->port = port;
        erp_action->sdev = sdev;
        if (!(atomic_read(&zfcp_sdev->status) &
                ZFCP_STATUS_COMMON_RUNNING))
            act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
        break;

    case ZFCP_ERP_ACTION_REOPEN_PORT:
    case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
        if (!get_device(&port->dev))
            return NULL;
        zfcp_erp_action_dismiss_port(port);
        atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
        erp_action = &port->erp_action;
        memset(erp_action, 0, sizeof(struct zfcp_erp_action));
        erp_action->port = port;
        if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_RUNNING))
            act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
        break;

    case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
        kref_get(&adapter->ref);
        zfcp_erp_action_dismiss_adapter(adapter);
        atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);
        erp_action = &adapter->erp_action;
        memset(erp_action, 0, sizeof(struct zfcp_erp_action));
        if (!(atomic_read(&adapter->status) &
                ZFCP_STATUS_COMMON_RUNNING))
            act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
        break;

    default:
        return NULL;
    }

    erp_action->adapter = adapter;
    erp_action->action = need;
    erp_action->status = act_status;

    return erp_action;
}
Exemplo n.º 2
0
static struct scsi_disk *__scsi_disk_get(struct gendisk *disk)
{
	struct scsi_disk *sdkp = NULL;

	if (disk->private_data) {
		sdkp = scsi_disk(disk);
		if (scsi_device_get(sdkp->device) == 0)
			kref_get(&sdkp->kref);
		else
			sdkp = NULL;
	}
	return sdkp;
}
Exemplo n.º 3
0
static struct scsi_disk *scsi_disk_get(struct gendisk *disk)
{
	struct scsi_disk *sdkp = NULL;

	down(&sd_ref_sem);
	if (disk->private_data == NULL)
		goto out;
	sdkp = scsi_disk(disk);
	kref_get(&sdkp->kref);
	if (scsi_device_get(sdkp->device))
		goto out_put;
	up(&sd_ref_sem);
	return sdkp;

 out_put:
	kref_put(&sdkp->kref, scsi_disk_release);
	sdkp = NULL;
 out:
	up(&sd_ref_sem);
	return sdkp;
}