Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcmu: Fix dev_config_store

Currently when there is a reconfig, the uio_info->name
does not get updated to reflect the change in the dev_config
name change.

On restart tcmu-runner there will be a mismatch between
the dev_config string in uio and the tcmu structure that contains
the string. When this occurs it'll reload the one in uio
and you lose the reconfigured device path.

v2: Created a helper function for the updating of uio_info

Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

authored by

Bryant G. Ly and committed by
Nicholas Bellinger
de8c5221 016a5fec

+24 -8
+24 -8
drivers/target/target_core_user.c
··· 1418 1418 return ret; 1419 1419 } 1420 1420 1421 - static int tcmu_configure_device(struct se_device *dev) 1421 + static int tcmu_update_uio_info(struct tcmu_dev *udev) 1422 1422 { 1423 - struct tcmu_dev *udev = TCMU_DEV(dev); 1424 1423 struct tcmu_hba *hba = udev->hba->hba_ptr; 1425 1424 struct uio_info *info; 1426 - struct tcmu_mailbox *mb; 1427 - size_t size; 1428 - size_t used; 1429 - int ret = 0; 1425 + size_t size, used; 1430 1426 char *str; 1431 1427 1432 1428 info = &udev->uio_info; 1433 - 1434 1429 size = snprintf(NULL, 0, "tcm-user/%u/%s/%s", hba->host_id, udev->name, 1435 1430 udev->dev_config); 1436 1431 size += 1; /* for \0 */ ··· 1434 1439 return -ENOMEM; 1435 1440 1436 1441 used = snprintf(str, size, "tcm-user/%u/%s", hba->host_id, udev->name); 1437 - 1438 1442 if (udev->dev_config[0]) 1439 1443 snprintf(str + used, size - used, "/%s", udev->dev_config); 1440 1444 1441 1445 info->name = str; 1446 + 1447 + return 0; 1448 + } 1449 + 1450 + static int tcmu_configure_device(struct se_device *dev) 1451 + { 1452 + struct tcmu_dev *udev = TCMU_DEV(dev); 1453 + struct uio_info *info; 1454 + struct tcmu_mailbox *mb; 1455 + int ret = 0; 1456 + 1457 + ret = tcmu_update_uio_info(udev); 1458 + if (ret) 1459 + return ret; 1460 + 1461 + info = &udev->uio_info; 1442 1462 1443 1463 udev->mb_addr = vzalloc(CMDR_SIZE); 1444 1464 if (!udev->mb_addr) { ··· 1796 1786 pr_err("Unable to reconfigure device\n"); 1797 1787 return ret; 1798 1788 } 1789 + strlcpy(udev->dev_config, page, TCMU_CONFIG_LEN); 1790 + 1791 + ret = tcmu_update_uio_info(udev); 1792 + if (ret) 1793 + return ret; 1794 + return count; 1799 1795 } 1800 1796 strlcpy(udev->dev_config, page, TCMU_CONFIG_LEN); 1801 1797