aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost/scsi.c
diff options
context:
space:
mode:
authorAsias He <asias@redhat.com>2013-05-06 04:38:28 -0400
committerMichael S. Tsirkin <mst@redhat.com>2013-07-07 07:38:57 -0400
commit9871831283e79575deb63fa341e9c7f3c1223d10 (patch)
treec23c24ebef951975b185287ab29126202c85eded /drivers/vhost/scsi.c
parent683bd967dd32eec4e4c45e4d38e9f807a2fd9479 (diff)
vhost-scsi: Rename struct tcm_vhost_tpg *tv_tpg to *tpg
Signed-off-by: Asias He <asias@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost/scsi.c')
-rw-r--r--drivers/vhost/scsi.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index acac9cc93edf..7fb18595c744 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -700,7 +700,7 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work)
700 700
701static struct tcm_vhost_cmd * 701static struct tcm_vhost_cmd *
702vhost_scsi_allocate_cmd(struct vhost_virtqueue *vq, 702vhost_scsi_allocate_cmd(struct vhost_virtqueue *vq,
703 struct tcm_vhost_tpg *tv_tpg, 703 struct tcm_vhost_tpg *tpg,
704 struct virtio_scsi_cmd_req *v_req, 704 struct virtio_scsi_cmd_req *v_req,
705 u32 exp_data_len, 705 u32 exp_data_len,
706 int data_direction) 706 int data_direction)
@@ -708,7 +708,7 @@ vhost_scsi_allocate_cmd(struct vhost_virtqueue *vq,
708 struct tcm_vhost_cmd *tv_cmd; 708 struct tcm_vhost_cmd *tv_cmd;
709 struct tcm_vhost_nexus *tv_nexus; 709 struct tcm_vhost_nexus *tv_nexus;
710 710
711 tv_nexus = tv_tpg->tpg_nexus; 711 tv_nexus = tpg->tpg_nexus;
712 if (!tv_nexus) { 712 if (!tv_nexus) {
713 pr_err("Unable to locate active struct tcm_vhost_nexus\n"); 713 pr_err("Unable to locate active struct tcm_vhost_nexus\n");
714 return ERR_PTR(-EIO); 714 return ERR_PTR(-EIO);
@@ -890,7 +890,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
890{ 890{
891 struct tcm_vhost_tpg **vs_tpg; 891 struct tcm_vhost_tpg **vs_tpg;
892 struct virtio_scsi_cmd_req v_req; 892 struct virtio_scsi_cmd_req v_req;
893 struct tcm_vhost_tpg *tv_tpg; 893 struct tcm_vhost_tpg *tpg;
894 struct tcm_vhost_cmd *tv_cmd; 894 struct tcm_vhost_cmd *tv_cmd;
895 u32 exp_data_len, data_first, data_num, data_direction; 895 u32 exp_data_len, data_first, data_num, data_direction;
896 unsigned out, in, i; 896 unsigned out, in, i;
@@ -976,10 +976,10 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
976 976
977 /* Extract the tpgt */ 977 /* Extract the tpgt */
978 target = v_req.lun[1]; 978 target = v_req.lun[1];
979 tv_tpg = ACCESS_ONCE(vs_tpg[target]); 979 tpg = ACCESS_ONCE(vs_tpg[target]);
980 980
981 /* Target does not exist, fail the request */ 981 /* Target does not exist, fail the request */
982 if (unlikely(!tv_tpg)) { 982 if (unlikely(!tpg)) {
983 vhost_scsi_send_bad_target(vs, vq, head, out); 983 vhost_scsi_send_bad_target(vs, vq, head, out);
984 continue; 984 continue;
985 } 985 }
@@ -988,7 +988,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
988 for (i = 0; i < data_num; i++) 988 for (i = 0; i < data_num; i++)
989 exp_data_len += vq->iov[data_first + i].iov_len; 989 exp_data_len += vq->iov[data_first + i].iov_len;
990 990
991 tv_cmd = vhost_scsi_allocate_cmd(vq, tv_tpg, &v_req, 991 tv_cmd = vhost_scsi_allocate_cmd(vq, tpg, &v_req,
992 exp_data_len, data_direction); 992 exp_data_len, data_direction);
993 if (IS_ERR(tv_cmd)) { 993 if (IS_ERR(tv_cmd)) {
994 vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n", 994 vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n",
@@ -1167,7 +1167,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
1167 struct vhost_scsi_target *t) 1167 struct vhost_scsi_target *t)
1168{ 1168{
1169 struct tcm_vhost_tport *tv_tport; 1169 struct tcm_vhost_tport *tv_tport;
1170 struct tcm_vhost_tpg *tv_tpg; 1170 struct tcm_vhost_tpg *tpg;
1171 struct tcm_vhost_tpg **vs_tpg; 1171 struct tcm_vhost_tpg **vs_tpg;
1172 struct vhost_virtqueue *vq; 1172 struct vhost_virtqueue *vq;
1173 int index, ret, i, len; 1173 int index, ret, i, len;
@@ -1194,32 +1194,32 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
1194 if (vs->vs_tpg) 1194 if (vs->vs_tpg)
1195 memcpy(vs_tpg, vs->vs_tpg, len); 1195 memcpy(vs_tpg, vs->vs_tpg, len);
1196 1196
1197 list_for_each_entry(tv_tpg, &tcm_vhost_list, tv_tpg_list) { 1197 list_for_each_entry(tpg, &tcm_vhost_list, tv_tpg_list) {
1198 mutex_lock(&tv_tpg->tv_tpg_mutex); 1198 mutex_lock(&tpg->tv_tpg_mutex);
1199 if (!tv_tpg->tpg_nexus) { 1199 if (!tpg->tpg_nexus) {
1200 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1200 mutex_unlock(&tpg->tv_tpg_mutex);
1201 continue; 1201 continue;
1202 } 1202 }
1203 if (tv_tpg->tv_tpg_vhost_count != 0) { 1203 if (tpg->tv_tpg_vhost_count != 0) {
1204 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1204 mutex_unlock(&tpg->tv_tpg_mutex);
1205 continue; 1205 continue;
1206 } 1206 }
1207 tv_tport = tv_tpg->tport; 1207 tv_tport = tpg->tport;
1208 1208
1209 if (!strcmp(tv_tport->tport_name, t->vhost_wwpn)) { 1209 if (!strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
1210 if (vs->vs_tpg && vs->vs_tpg[tv_tpg->tport_tpgt]) { 1210 if (vs->vs_tpg && vs->vs_tpg[tpg->tport_tpgt]) {
1211 kfree(vs_tpg); 1211 kfree(vs_tpg);
1212 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1212 mutex_unlock(&tpg->tv_tpg_mutex);
1213 ret = -EEXIST; 1213 ret = -EEXIST;
1214 goto out; 1214 goto out;
1215 } 1215 }
1216 tv_tpg->tv_tpg_vhost_count++; 1216 tpg->tv_tpg_vhost_count++;
1217 tv_tpg->vhost_scsi = vs; 1217 tpg->vhost_scsi = vs;
1218 vs_tpg[tv_tpg->tport_tpgt] = tv_tpg; 1218 vs_tpg[tpg->tport_tpgt] = tpg;
1219 smp_mb__after_atomic_inc(); 1219 smp_mb__after_atomic_inc();
1220 match = true; 1220 match = true;
1221 } 1221 }
1222 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1222 mutex_unlock(&tpg->tv_tpg_mutex);
1223 } 1223 }
1224 1224
1225 if (match) { 1225 if (match) {
@@ -1257,7 +1257,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
1257 struct vhost_scsi_target *t) 1257 struct vhost_scsi_target *t)
1258{ 1258{
1259 struct tcm_vhost_tport *tv_tport; 1259 struct tcm_vhost_tport *tv_tport;
1260 struct tcm_vhost_tpg *tv_tpg; 1260 struct tcm_vhost_tpg *tpg;
1261 struct vhost_virtqueue *vq; 1261 struct vhost_virtqueue *vq;
1262 bool match = false; 1262 bool match = false;
1263 int index, ret, i; 1263 int index, ret, i;
@@ -1280,30 +1280,30 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
1280 1280
1281 for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { 1281 for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
1282 target = i; 1282 target = i;
1283 tv_tpg = vs->vs_tpg[target]; 1283 tpg = vs->vs_tpg[target];
1284 if (!tv_tpg) 1284 if (!tpg)
1285 continue; 1285 continue;
1286 1286
1287 mutex_lock(&tv_tpg->tv_tpg_mutex); 1287 mutex_lock(&tpg->tv_tpg_mutex);
1288 tv_tport = tv_tpg->tport; 1288 tv_tport = tpg->tport;
1289 if (!tv_tport) { 1289 if (!tv_tport) {
1290 ret = -ENODEV; 1290 ret = -ENODEV;
1291 goto err_tpg; 1291 goto err_tpg;
1292 } 1292 }
1293 1293
1294 if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) { 1294 if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
1295 pr_warn("tv_tport->tport_name: %s, tv_tpg->tport_tpgt: %hu" 1295 pr_warn("tv_tport->tport_name: %s, tpg->tport_tpgt: %hu"
1296 " does not match t->vhost_wwpn: %s, t->vhost_tpgt: %hu\n", 1296 " does not match t->vhost_wwpn: %s, t->vhost_tpgt: %hu\n",
1297 tv_tport->tport_name, tv_tpg->tport_tpgt, 1297 tv_tport->tport_name, tpg->tport_tpgt,
1298 t->vhost_wwpn, t->vhost_tpgt); 1298 t->vhost_wwpn, t->vhost_tpgt);
1299 ret = -EINVAL; 1299 ret = -EINVAL;
1300 goto err_tpg; 1300 goto err_tpg;
1301 } 1301 }
1302 tv_tpg->tv_tpg_vhost_count--; 1302 tpg->tv_tpg_vhost_count--;
1303 tv_tpg->vhost_scsi = NULL; 1303 tpg->vhost_scsi = NULL;
1304 vs->vs_tpg[target] = NULL; 1304 vs->vs_tpg[target] = NULL;
1305 match = true; 1305 match = true;
1306 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1306 mutex_unlock(&tpg->tv_tpg_mutex);
1307 } 1307 }
1308 if (match) { 1308 if (match) {
1309 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) { 1309 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
@@ -1327,7 +1327,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
1327 return 0; 1327 return 0;
1328 1328
1329err_tpg: 1329err_tpg:
1330 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1330 mutex_unlock(&tpg->tv_tpg_mutex);
1331err_dev: 1331err_dev:
1332 mutex_unlock(&vs->dev.mutex); 1332 mutex_unlock(&vs->dev.mutex);
1333 mutex_unlock(&tcm_vhost_mutex); 1333 mutex_unlock(&tcm_vhost_mutex);
@@ -1577,16 +1577,16 @@ static void tcm_vhost_hotunplug(struct tcm_vhost_tpg *tpg, struct se_lun *lun)
1577static int tcm_vhost_port_link(struct se_portal_group *se_tpg, 1577static int tcm_vhost_port_link(struct se_portal_group *se_tpg,
1578 struct se_lun *lun) 1578 struct se_lun *lun)
1579{ 1579{
1580 struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg, 1580 struct tcm_vhost_tpg *tpg = container_of(se_tpg,
1581 struct tcm_vhost_tpg, se_tpg); 1581 struct tcm_vhost_tpg, se_tpg);
1582 1582
1583 mutex_lock(&tcm_vhost_mutex); 1583 mutex_lock(&tcm_vhost_mutex);
1584 1584
1585 mutex_lock(&tv_tpg->tv_tpg_mutex); 1585 mutex_lock(&tpg->tv_tpg_mutex);
1586 tv_tpg->tv_tpg_port_count++; 1586 tpg->tv_tpg_port_count++;
1587 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1587 mutex_unlock(&tpg->tv_tpg_mutex);
1588 1588
1589 tcm_vhost_hotplug(tv_tpg, lun); 1589 tcm_vhost_hotplug(tpg, lun);
1590 1590
1591 mutex_unlock(&tcm_vhost_mutex); 1591 mutex_unlock(&tcm_vhost_mutex);
1592 1592
@@ -1596,16 +1596,16 @@ static int tcm_vhost_port_link(struct se_portal_group *se_tpg,
1596static void tcm_vhost_port_unlink(struct se_portal_group *se_tpg, 1596static void tcm_vhost_port_unlink(struct se_portal_group *se_tpg,
1597 struct se_lun *lun) 1597 struct se_lun *lun)
1598{ 1598{
1599 struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg, 1599 struct tcm_vhost_tpg *tpg = container_of(se_tpg,
1600 struct tcm_vhost_tpg, se_tpg); 1600 struct tcm_vhost_tpg, se_tpg);
1601 1601
1602 mutex_lock(&tcm_vhost_mutex); 1602 mutex_lock(&tcm_vhost_mutex);
1603 1603
1604 mutex_lock(&tv_tpg->tv_tpg_mutex); 1604 mutex_lock(&tpg->tv_tpg_mutex);
1605 tv_tpg->tv_tpg_port_count--; 1605 tpg->tv_tpg_port_count--;
1606 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1606 mutex_unlock(&tpg->tv_tpg_mutex);
1607 1607
1608 tcm_vhost_hotunplug(tv_tpg, lun); 1608 tcm_vhost_hotunplug(tpg, lun);
1609 1609
1610 mutex_unlock(&tcm_vhost_mutex); 1610 mutex_unlock(&tcm_vhost_mutex);
1611} 1611}
@@ -1654,23 +1654,23 @@ static void tcm_vhost_drop_nodeacl(struct se_node_acl *se_acl)
1654 kfree(nacl); 1654 kfree(nacl);
1655} 1655}
1656 1656
1657static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg, 1657static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tpg,
1658 const char *name) 1658 const char *name)
1659{ 1659{
1660 struct se_portal_group *se_tpg; 1660 struct se_portal_group *se_tpg;
1661 struct tcm_vhost_nexus *tv_nexus; 1661 struct tcm_vhost_nexus *tv_nexus;
1662 1662
1663 mutex_lock(&tv_tpg->tv_tpg_mutex); 1663 mutex_lock(&tpg->tv_tpg_mutex);
1664 if (tv_tpg->tpg_nexus) { 1664 if (tpg->tpg_nexus) {
1665 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1665 mutex_unlock(&tpg->tv_tpg_mutex);
1666 pr_debug("tv_tpg->tpg_nexus already exists\n"); 1666 pr_debug("tpg->tpg_nexus already exists\n");
1667 return -EEXIST; 1667 return -EEXIST;
1668 } 1668 }
1669 se_tpg = &tv_tpg->se_tpg; 1669 se_tpg = &tpg->se_tpg;
1670 1670
1671 tv_nexus = kzalloc(sizeof(struct tcm_vhost_nexus), GFP_KERNEL); 1671 tv_nexus = kzalloc(sizeof(struct tcm_vhost_nexus), GFP_KERNEL);
1672 if (!tv_nexus) { 1672 if (!tv_nexus) {
1673 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1673 mutex_unlock(&tpg->tv_tpg_mutex);
1674 pr_err("Unable to allocate struct tcm_vhost_nexus\n"); 1674 pr_err("Unable to allocate struct tcm_vhost_nexus\n");
1675 return -ENOMEM; 1675 return -ENOMEM;
1676 } 1676 }
@@ -1679,7 +1679,7 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg,
1679 */ 1679 */
1680 tv_nexus->tvn_se_sess = transport_init_session(); 1680 tv_nexus->tvn_se_sess = transport_init_session();
1681 if (IS_ERR(tv_nexus->tvn_se_sess)) { 1681 if (IS_ERR(tv_nexus->tvn_se_sess)) {
1682 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1682 mutex_unlock(&tpg->tv_tpg_mutex);
1683 kfree(tv_nexus); 1683 kfree(tv_nexus);
1684 return -ENOMEM; 1684 return -ENOMEM;
1685 } 1685 }
@@ -1691,7 +1691,7 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg,
1691 tv_nexus->tvn_se_sess->se_node_acl = core_tpg_check_initiator_node_acl( 1691 tv_nexus->tvn_se_sess->se_node_acl = core_tpg_check_initiator_node_acl(
1692 se_tpg, (unsigned char *)name); 1692 se_tpg, (unsigned char *)name);
1693 if (!tv_nexus->tvn_se_sess->se_node_acl) { 1693 if (!tv_nexus->tvn_se_sess->se_node_acl) {
1694 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1694 mutex_unlock(&tpg->tv_tpg_mutex);
1695 pr_debug("core_tpg_check_initiator_node_acl() failed" 1695 pr_debug("core_tpg_check_initiator_node_acl() failed"
1696 " for %s\n", name); 1696 " for %s\n", name);
1697 transport_free_session(tv_nexus->tvn_se_sess); 1697 transport_free_session(tv_nexus->tvn_se_sess);
@@ -1704,9 +1704,9 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg,
1704 */ 1704 */
1705 __transport_register_session(se_tpg, tv_nexus->tvn_se_sess->se_node_acl, 1705 __transport_register_session(se_tpg, tv_nexus->tvn_se_sess->se_node_acl,
1706 tv_nexus->tvn_se_sess, tv_nexus); 1706 tv_nexus->tvn_se_sess, tv_nexus);
1707 tv_tpg->tpg_nexus = tv_nexus; 1707 tpg->tpg_nexus = tv_nexus;
1708 1708
1709 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1709 mutex_unlock(&tpg->tv_tpg_mutex);
1710 return 0; 1710 return 0;
1711} 1711}
1712 1712
@@ -1761,20 +1761,20 @@ static int tcm_vhost_drop_nexus(struct tcm_vhost_tpg *tpg)
1761static ssize_t tcm_vhost_tpg_show_nexus(struct se_portal_group *se_tpg, 1761static ssize_t tcm_vhost_tpg_show_nexus(struct se_portal_group *se_tpg,
1762 char *page) 1762 char *page)
1763{ 1763{
1764 struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg, 1764 struct tcm_vhost_tpg *tpg = container_of(se_tpg,
1765 struct tcm_vhost_tpg, se_tpg); 1765 struct tcm_vhost_tpg, se_tpg);
1766 struct tcm_vhost_nexus *tv_nexus; 1766 struct tcm_vhost_nexus *tv_nexus;
1767 ssize_t ret; 1767 ssize_t ret;
1768 1768
1769 mutex_lock(&tv_tpg->tv_tpg_mutex); 1769 mutex_lock(&tpg->tv_tpg_mutex);
1770 tv_nexus = tv_tpg->tpg_nexus; 1770 tv_nexus = tpg->tpg_nexus;
1771 if (!tv_nexus) { 1771 if (!tv_nexus) {
1772 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1772 mutex_unlock(&tpg->tv_tpg_mutex);
1773 return -ENODEV; 1773 return -ENODEV;
1774 } 1774 }
1775 ret = snprintf(page, PAGE_SIZE, "%s\n", 1775 ret = snprintf(page, PAGE_SIZE, "%s\n",
1776 tv_nexus->tvn_se_sess->se_node_acl->initiatorname); 1776 tv_nexus->tvn_se_sess->se_node_acl->initiatorname);
1777 mutex_unlock(&tv_tpg->tv_tpg_mutex); 1777 mutex_unlock(&tpg->tv_tpg_mutex);
1778 1778
1779 return ret; 1779 return ret;
1780} 1780}
@@ -1783,16 +1783,16 @@ static ssize_t tcm_vhost_tpg_store_nexus(struct se_portal_group *se_tpg,
1783 const char *page, 1783 const char *page,
1784 size_t count) 1784 size_t count)
1785{ 1785{
1786 struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg, 1786 struct tcm_vhost_tpg *tpg = container_of(se_tpg,
1787 struct tcm_vhost_tpg, se_tpg); 1787 struct tcm_vhost_tpg, se_tpg);
1788 struct tcm_vhost_tport *tport_wwn = tv_tpg->tport; 1788 struct tcm_vhost_tport *tport_wwn = tpg->tport;
1789 unsigned char i_port[TCM_VHOST_NAMELEN], *ptr, *port_ptr; 1789 unsigned char i_port[TCM_VHOST_NAMELEN], *ptr, *port_ptr;
1790 int ret; 1790 int ret;
1791 /* 1791 /*
1792 * Shutdown the active I_T nexus if 'NULL' is passed.. 1792 * Shutdown the active I_T nexus if 'NULL' is passed..
1793 */ 1793 */
1794 if (!strncmp(page, "NULL", 4)) { 1794 if (!strncmp(page, "NULL", 4)) {
1795 ret = tcm_vhost_drop_nexus(tv_tpg); 1795 ret = tcm_vhost_drop_nexus(tpg);
1796 return (!ret) ? count : ret; 1796 return (!ret) ? count : ret;
1797 } 1797 }
1798 /* 1798 /*
@@ -1850,7 +1850,7 @@ check_newline:
1850 if (i_port[strlen(i_port)-1] == '\n') 1850 if (i_port[strlen(i_port)-1] == '\n')
1851 i_port[strlen(i_port)-1] = '\0'; 1851 i_port[strlen(i_port)-1] = '\0';
1852 1852
1853 ret = tcm_vhost_make_nexus(tv_tpg, port_ptr); 1853 ret = tcm_vhost_make_nexus(tpg, port_ptr);
1854 if (ret < 0) 1854 if (ret < 0)
1855 return ret; 1855 return ret;
1856 1856