diff options
Diffstat (limited to 'drivers/target/target_core_device.c')
-rw-r--r-- | drivers/target/target_core_device.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 0c5992f0d946..edbcabbf85f7 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -320,11 +320,12 @@ int core_free_device_list_for_node( | |||
320 | void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd) | 320 | void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd) |
321 | { | 321 | { |
322 | struct se_dev_entry *deve; | 322 | struct se_dev_entry *deve; |
323 | unsigned long flags; | ||
323 | 324 | ||
324 | spin_lock_irq(&se_nacl->device_list_lock); | 325 | spin_lock_irqsave(&se_nacl->device_list_lock, flags); |
325 | deve = &se_nacl->device_list[se_cmd->orig_fe_lun]; | 326 | deve = &se_nacl->device_list[se_cmd->orig_fe_lun]; |
326 | deve->deve_cmds--; | 327 | deve->deve_cmds--; |
327 | spin_unlock_irq(&se_nacl->device_list_lock); | 328 | spin_unlock_irqrestore(&se_nacl->device_list_lock, flags); |
328 | } | 329 | } |
329 | 330 | ||
330 | void core_update_device_list_access( | 331 | void core_update_device_list_access( |
@@ -656,7 +657,7 @@ int target_report_luns(struct se_task *se_task) | |||
656 | unsigned char *buf; | 657 | unsigned char *buf; |
657 | u32 cdb_offset = 0, lun_count = 0, offset = 8, i; | 658 | u32 cdb_offset = 0, lun_count = 0, offset = 8, i; |
658 | 659 | ||
659 | buf = transport_kmap_first_data_page(se_cmd); | 660 | buf = (unsigned char *) transport_kmap_data_sg(se_cmd); |
660 | 661 | ||
661 | /* | 662 | /* |
662 | * If no struct se_session pointer is present, this struct se_cmd is | 663 | * If no struct se_session pointer is present, this struct se_cmd is |
@@ -694,7 +695,7 @@ int target_report_luns(struct se_task *se_task) | |||
694 | * See SPC3 r07, page 159. | 695 | * See SPC3 r07, page 159. |
695 | */ | 696 | */ |
696 | done: | 697 | done: |
697 | transport_kunmap_first_data_page(se_cmd); | 698 | transport_kunmap_data_sg(se_cmd); |
698 | lun_count *= 8; | 699 | lun_count *= 8; |
699 | buf[0] = ((lun_count >> 24) & 0xff); | 700 | buf[0] = ((lun_count >> 24) & 0xff); |
700 | buf[1] = ((lun_count >> 16) & 0xff); | 701 | buf[1] = ((lun_count >> 16) & 0xff); |
@@ -1294,24 +1295,26 @@ struct se_lun *core_dev_add_lun( | |||
1294 | { | 1295 | { |
1295 | struct se_lun *lun_p; | 1296 | struct se_lun *lun_p; |
1296 | u32 lun_access = 0; | 1297 | u32 lun_access = 0; |
1298 | int rc; | ||
1297 | 1299 | ||
1298 | if (atomic_read(&dev->dev_access_obj.obj_access_count) != 0) { | 1300 | if (atomic_read(&dev->dev_access_obj.obj_access_count) != 0) { |
1299 | pr_err("Unable to export struct se_device while dev_access_obj: %d\n", | 1301 | pr_err("Unable to export struct se_device while dev_access_obj: %d\n", |
1300 | atomic_read(&dev->dev_access_obj.obj_access_count)); | 1302 | atomic_read(&dev->dev_access_obj.obj_access_count)); |
1301 | return NULL; | 1303 | return ERR_PTR(-EACCES); |
1302 | } | 1304 | } |
1303 | 1305 | ||
1304 | lun_p = core_tpg_pre_addlun(tpg, lun); | 1306 | lun_p = core_tpg_pre_addlun(tpg, lun); |
1305 | if ((IS_ERR(lun_p)) || !lun_p) | 1307 | if (IS_ERR(lun_p)) |
1306 | return NULL; | 1308 | return lun_p; |
1307 | 1309 | ||
1308 | if (dev->dev_flags & DF_READ_ONLY) | 1310 | if (dev->dev_flags & DF_READ_ONLY) |
1309 | lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; | 1311 | lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; |
1310 | else | 1312 | else |
1311 | lun_access = TRANSPORT_LUNFLAGS_READ_WRITE; | 1313 | lun_access = TRANSPORT_LUNFLAGS_READ_WRITE; |
1312 | 1314 | ||
1313 | if (core_tpg_post_addlun(tpg, lun_p, lun_access, dev) < 0) | 1315 | rc = core_tpg_post_addlun(tpg, lun_p, lun_access, dev); |
1314 | return NULL; | 1316 | if (rc < 0) |
1317 | return ERR_PTR(rc); | ||
1315 | 1318 | ||
1316 | pr_debug("%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from" | 1319 | pr_debug("%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from" |
1317 | " CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(), | 1320 | " CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(), |
@@ -1348,11 +1351,10 @@ int core_dev_del_lun( | |||
1348 | u32 unpacked_lun) | 1351 | u32 unpacked_lun) |
1349 | { | 1352 | { |
1350 | struct se_lun *lun; | 1353 | struct se_lun *lun; |
1351 | int ret = 0; | ||
1352 | 1354 | ||
1353 | lun = core_tpg_pre_dellun(tpg, unpacked_lun, &ret); | 1355 | lun = core_tpg_pre_dellun(tpg, unpacked_lun); |
1354 | if (!lun) | 1356 | if (IS_ERR(lun)) |
1355 | return ret; | 1357 | return PTR_ERR(lun); |
1356 | 1358 | ||
1357 | core_tpg_post_dellun(tpg, lun); | 1359 | core_tpg_post_dellun(tpg, lun); |
1358 | 1360 | ||