|
@@ -78,12 +78,16 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
|
|
&deve->read_bytes);
|
|
&deve->read_bytes);
|
|
|
|
|
|
se_lun = rcu_dereference(deve->se_lun);
|
|
se_lun = rcu_dereference(deve->se_lun);
|
|
|
|
+
|
|
|
|
+ if (!percpu_ref_tryget_live(&se_lun->lun_ref)) {
|
|
|
|
+ se_lun = NULL;
|
|
|
|
+ goto out_unlock;
|
|
|
|
+ }
|
|
|
|
+
|
|
se_cmd->se_lun = rcu_dereference(deve->se_lun);
|
|
se_cmd->se_lun = rcu_dereference(deve->se_lun);
|
|
se_cmd->pr_res_key = deve->pr_res_key;
|
|
se_cmd->pr_res_key = deve->pr_res_key;
|
|
se_cmd->orig_fe_lun = unpacked_lun;
|
|
se_cmd->orig_fe_lun = unpacked_lun;
|
|
se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
|
|
se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
|
|
-
|
|
|
|
- percpu_ref_get(&se_lun->lun_ref);
|
|
|
|
se_cmd->lun_ref_active = true;
|
|
se_cmd->lun_ref_active = true;
|
|
|
|
|
|
if ((se_cmd->data_direction == DMA_TO_DEVICE) &&
|
|
if ((se_cmd->data_direction == DMA_TO_DEVICE) &&
|
|
@@ -97,6 +101,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
|
|
goto ref_dev;
|
|
goto ref_dev;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+out_unlock:
|
|
rcu_read_unlock();
|
|
rcu_read_unlock();
|
|
|
|
|
|
if (!se_lun) {
|
|
if (!se_lun) {
|
|
@@ -815,6 +820,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
|
|
xcopy_lun = &dev->xcopy_lun;
|
|
xcopy_lun = &dev->xcopy_lun;
|
|
rcu_assign_pointer(xcopy_lun->lun_se_dev, dev);
|
|
rcu_assign_pointer(xcopy_lun->lun_se_dev, dev);
|
|
init_completion(&xcopy_lun->lun_ref_comp);
|
|
init_completion(&xcopy_lun->lun_ref_comp);
|
|
|
|
+ init_completion(&xcopy_lun->lun_shutdown_comp);
|
|
INIT_LIST_HEAD(&xcopy_lun->lun_deve_list);
|
|
INIT_LIST_HEAD(&xcopy_lun->lun_deve_list);
|
|
INIT_LIST_HEAD(&xcopy_lun->lun_dev_link);
|
|
INIT_LIST_HEAD(&xcopy_lun->lun_dev_link);
|
|
mutex_init(&xcopy_lun->lun_tg_pt_md_mutex);
|
|
mutex_init(&xcopy_lun->lun_tg_pt_md_mutex);
|