提交 98718312 编写于 作者: A Asias He 提交者: Michael S. Tsirkin

vhost-scsi: Rename struct tcm_vhost_tpg *tv_tpg to *tpg

Signed-off-by: NAsias He <asias@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 683bd967
...@@ -700,7 +700,7 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work) ...@@ -700,7 +700,7 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work)
static struct tcm_vhost_cmd * static struct tcm_vhost_cmd *
vhost_scsi_allocate_cmd(struct vhost_virtqueue *vq, vhost_scsi_allocate_cmd(struct vhost_virtqueue *vq,
struct tcm_vhost_tpg *tv_tpg, struct tcm_vhost_tpg *tpg,
struct virtio_scsi_cmd_req *v_req, struct virtio_scsi_cmd_req *v_req,
u32 exp_data_len, u32 exp_data_len,
int data_direction) int data_direction)
...@@ -708,7 +708,7 @@ vhost_scsi_allocate_cmd(struct vhost_virtqueue *vq, ...@@ -708,7 +708,7 @@ vhost_scsi_allocate_cmd(struct vhost_virtqueue *vq,
struct tcm_vhost_cmd *tv_cmd; struct tcm_vhost_cmd *tv_cmd;
struct tcm_vhost_nexus *tv_nexus; struct tcm_vhost_nexus *tv_nexus;
tv_nexus = tv_tpg->tpg_nexus; tv_nexus = tpg->tpg_nexus;
if (!tv_nexus) { if (!tv_nexus) {
pr_err("Unable to locate active struct tcm_vhost_nexus\n"); pr_err("Unable to locate active struct tcm_vhost_nexus\n");
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
...@@ -890,7 +890,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) ...@@ -890,7 +890,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
{ {
struct tcm_vhost_tpg **vs_tpg; struct tcm_vhost_tpg **vs_tpg;
struct virtio_scsi_cmd_req v_req; struct virtio_scsi_cmd_req v_req;
struct tcm_vhost_tpg *tv_tpg; struct tcm_vhost_tpg *tpg;
struct tcm_vhost_cmd *tv_cmd; struct tcm_vhost_cmd *tv_cmd;
u32 exp_data_len, data_first, data_num, data_direction; u32 exp_data_len, data_first, data_num, data_direction;
unsigned out, in, i; unsigned out, in, i;
...@@ -976,10 +976,10 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) ...@@ -976,10 +976,10 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
/* Extract the tpgt */ /* Extract the tpgt */
target = v_req.lun[1]; target = v_req.lun[1];
tv_tpg = ACCESS_ONCE(vs_tpg[target]); tpg = ACCESS_ONCE(vs_tpg[target]);
/* Target does not exist, fail the request */ /* Target does not exist, fail the request */
if (unlikely(!tv_tpg)) { if (unlikely(!tpg)) {
vhost_scsi_send_bad_target(vs, vq, head, out); vhost_scsi_send_bad_target(vs, vq, head, out);
continue; continue;
} }
...@@ -988,7 +988,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) ...@@ -988,7 +988,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
for (i = 0; i < data_num; i++) for (i = 0; i < data_num; i++)
exp_data_len += vq->iov[data_first + i].iov_len; exp_data_len += vq->iov[data_first + i].iov_len;
tv_cmd = vhost_scsi_allocate_cmd(vq, tv_tpg, &v_req, tv_cmd = vhost_scsi_allocate_cmd(vq, tpg, &v_req,
exp_data_len, data_direction); exp_data_len, data_direction);
if (IS_ERR(tv_cmd)) { if (IS_ERR(tv_cmd)) {
vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n", vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n",
...@@ -1167,7 +1167,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, ...@@ -1167,7 +1167,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
struct vhost_scsi_target *t) struct vhost_scsi_target *t)
{ {
struct tcm_vhost_tport *tv_tport; struct tcm_vhost_tport *tv_tport;
struct tcm_vhost_tpg *tv_tpg; struct tcm_vhost_tpg *tpg;
struct tcm_vhost_tpg **vs_tpg; struct tcm_vhost_tpg **vs_tpg;
struct vhost_virtqueue *vq; struct vhost_virtqueue *vq;
int index, ret, i, len; int index, ret, i, len;
...@@ -1194,32 +1194,32 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, ...@@ -1194,32 +1194,32 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
if (vs->vs_tpg) if (vs->vs_tpg)
memcpy(vs_tpg, vs->vs_tpg, len); memcpy(vs_tpg, vs->vs_tpg, len);
list_for_each_entry(tv_tpg, &tcm_vhost_list, tv_tpg_list) { list_for_each_entry(tpg, &tcm_vhost_list, tv_tpg_list) {
mutex_lock(&tv_tpg->tv_tpg_mutex); mutex_lock(&tpg->tv_tpg_mutex);
if (!tv_tpg->tpg_nexus) { if (!tpg->tpg_nexus) {
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
continue; continue;
} }
if (tv_tpg->tv_tpg_vhost_count != 0) { if (tpg->tv_tpg_vhost_count != 0) {
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
continue; continue;
} }
tv_tport = tv_tpg->tport; tv_tport = tpg->tport;
if (!strcmp(tv_tport->tport_name, t->vhost_wwpn)) { if (!strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
if (vs->vs_tpg && vs->vs_tpg[tv_tpg->tport_tpgt]) { if (vs->vs_tpg && vs->vs_tpg[tpg->tport_tpgt]) {
kfree(vs_tpg); kfree(vs_tpg);
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
ret = -EEXIST; ret = -EEXIST;
goto out; goto out;
} }
tv_tpg->tv_tpg_vhost_count++; tpg->tv_tpg_vhost_count++;
tv_tpg->vhost_scsi = vs; tpg->vhost_scsi = vs;
vs_tpg[tv_tpg->tport_tpgt] = tv_tpg; vs_tpg[tpg->tport_tpgt] = tpg;
smp_mb__after_atomic_inc(); smp_mb__after_atomic_inc();
match = true; match = true;
} }
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
} }
if (match) { if (match) {
...@@ -1257,7 +1257,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, ...@@ -1257,7 +1257,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
struct vhost_scsi_target *t) struct vhost_scsi_target *t)
{ {
struct tcm_vhost_tport *tv_tport; struct tcm_vhost_tport *tv_tport;
struct tcm_vhost_tpg *tv_tpg; struct tcm_vhost_tpg *tpg;
struct vhost_virtqueue *vq; struct vhost_virtqueue *vq;
bool match = false; bool match = false;
int index, ret, i; int index, ret, i;
...@@ -1280,30 +1280,30 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, ...@@ -1280,30 +1280,30 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
target = i; target = i;
tv_tpg = vs->vs_tpg[target]; tpg = vs->vs_tpg[target];
if (!tv_tpg) if (!tpg)
continue; continue;
mutex_lock(&tv_tpg->tv_tpg_mutex); mutex_lock(&tpg->tv_tpg_mutex);
tv_tport = tv_tpg->tport; tv_tport = tpg->tport;
if (!tv_tport) { if (!tv_tport) {
ret = -ENODEV; ret = -ENODEV;
goto err_tpg; goto err_tpg;
} }
if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) { if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
pr_warn("tv_tport->tport_name: %s, tv_tpg->tport_tpgt: %hu" pr_warn("tv_tport->tport_name: %s, tpg->tport_tpgt: %hu"
" does not match t->vhost_wwpn: %s, t->vhost_tpgt: %hu\n", " does not match t->vhost_wwpn: %s, t->vhost_tpgt: %hu\n",
tv_tport->tport_name, tv_tpg->tport_tpgt, tv_tport->tport_name, tpg->tport_tpgt,
t->vhost_wwpn, t->vhost_tpgt); t->vhost_wwpn, t->vhost_tpgt);
ret = -EINVAL; ret = -EINVAL;
goto err_tpg; goto err_tpg;
} }
tv_tpg->tv_tpg_vhost_count--; tpg->tv_tpg_vhost_count--;
tv_tpg->vhost_scsi = NULL; tpg->vhost_scsi = NULL;
vs->vs_tpg[target] = NULL; vs->vs_tpg[target] = NULL;
match = true; match = true;
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
} }
if (match) { if (match) {
for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) { for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
...@@ -1327,7 +1327,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, ...@@ -1327,7 +1327,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
return 0; return 0;
err_tpg: err_tpg:
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
err_dev: err_dev:
mutex_unlock(&vs->dev.mutex); mutex_unlock(&vs->dev.mutex);
mutex_unlock(&tcm_vhost_mutex); mutex_unlock(&tcm_vhost_mutex);
...@@ -1577,16 +1577,16 @@ static void tcm_vhost_hotunplug(struct tcm_vhost_tpg *tpg, struct se_lun *lun) ...@@ -1577,16 +1577,16 @@ static void tcm_vhost_hotunplug(struct tcm_vhost_tpg *tpg, struct se_lun *lun)
static int tcm_vhost_port_link(struct se_portal_group *se_tpg, static int tcm_vhost_port_link(struct se_portal_group *se_tpg,
struct se_lun *lun) struct se_lun *lun)
{ {
struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg, struct tcm_vhost_tpg *tpg = container_of(se_tpg,
struct tcm_vhost_tpg, se_tpg); struct tcm_vhost_tpg, se_tpg);
mutex_lock(&tcm_vhost_mutex); mutex_lock(&tcm_vhost_mutex);
mutex_lock(&tv_tpg->tv_tpg_mutex); mutex_lock(&tpg->tv_tpg_mutex);
tv_tpg->tv_tpg_port_count++; tpg->tv_tpg_port_count++;
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
tcm_vhost_hotplug(tv_tpg, lun); tcm_vhost_hotplug(tpg, lun);
mutex_unlock(&tcm_vhost_mutex); mutex_unlock(&tcm_vhost_mutex);
...@@ -1596,16 +1596,16 @@ static int tcm_vhost_port_link(struct se_portal_group *se_tpg, ...@@ -1596,16 +1596,16 @@ static int tcm_vhost_port_link(struct se_portal_group *se_tpg,
static void tcm_vhost_port_unlink(struct se_portal_group *se_tpg, static void tcm_vhost_port_unlink(struct se_portal_group *se_tpg,
struct se_lun *lun) struct se_lun *lun)
{ {
struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg, struct tcm_vhost_tpg *tpg = container_of(se_tpg,
struct tcm_vhost_tpg, se_tpg); struct tcm_vhost_tpg, se_tpg);
mutex_lock(&tcm_vhost_mutex); mutex_lock(&tcm_vhost_mutex);
mutex_lock(&tv_tpg->tv_tpg_mutex); mutex_lock(&tpg->tv_tpg_mutex);
tv_tpg->tv_tpg_port_count--; tpg->tv_tpg_port_count--;
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
tcm_vhost_hotunplug(tv_tpg, lun); tcm_vhost_hotunplug(tpg, lun);
mutex_unlock(&tcm_vhost_mutex); mutex_unlock(&tcm_vhost_mutex);
} }
...@@ -1654,23 +1654,23 @@ static void tcm_vhost_drop_nodeacl(struct se_node_acl *se_acl) ...@@ -1654,23 +1654,23 @@ static void tcm_vhost_drop_nodeacl(struct se_node_acl *se_acl)
kfree(nacl); kfree(nacl);
} }
static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg, static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tpg,
const char *name) const char *name)
{ {
struct se_portal_group *se_tpg; struct se_portal_group *se_tpg;
struct tcm_vhost_nexus *tv_nexus; struct tcm_vhost_nexus *tv_nexus;
mutex_lock(&tv_tpg->tv_tpg_mutex); mutex_lock(&tpg->tv_tpg_mutex);
if (tv_tpg->tpg_nexus) { if (tpg->tpg_nexus) {
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
pr_debug("tv_tpg->tpg_nexus already exists\n"); pr_debug("tpg->tpg_nexus already exists\n");
return -EEXIST; return -EEXIST;
} }
se_tpg = &tv_tpg->se_tpg; se_tpg = &tpg->se_tpg;
tv_nexus = kzalloc(sizeof(struct tcm_vhost_nexus), GFP_KERNEL); tv_nexus = kzalloc(sizeof(struct tcm_vhost_nexus), GFP_KERNEL);
if (!tv_nexus) { if (!tv_nexus) {
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
pr_err("Unable to allocate struct tcm_vhost_nexus\n"); pr_err("Unable to allocate struct tcm_vhost_nexus\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -1679,7 +1679,7 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg, ...@@ -1679,7 +1679,7 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg,
*/ */
tv_nexus->tvn_se_sess = transport_init_session(); tv_nexus->tvn_se_sess = transport_init_session();
if (IS_ERR(tv_nexus->tvn_se_sess)) { if (IS_ERR(tv_nexus->tvn_se_sess)) {
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
kfree(tv_nexus); kfree(tv_nexus);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1691,7 +1691,7 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg, ...@@ -1691,7 +1691,7 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg,
tv_nexus->tvn_se_sess->se_node_acl = core_tpg_check_initiator_node_acl( tv_nexus->tvn_se_sess->se_node_acl = core_tpg_check_initiator_node_acl(
se_tpg, (unsigned char *)name); se_tpg, (unsigned char *)name);
if (!tv_nexus->tvn_se_sess->se_node_acl) { if (!tv_nexus->tvn_se_sess->se_node_acl) {
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
pr_debug("core_tpg_check_initiator_node_acl() failed" pr_debug("core_tpg_check_initiator_node_acl() failed"
" for %s\n", name); " for %s\n", name);
transport_free_session(tv_nexus->tvn_se_sess); 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,9 +1704,9 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg,
*/ */
__transport_register_session(se_tpg, tv_nexus->tvn_se_sess->se_node_acl, __transport_register_session(se_tpg, tv_nexus->tvn_se_sess->se_node_acl,
tv_nexus->tvn_se_sess, tv_nexus); tv_nexus->tvn_se_sess, tv_nexus);
tv_tpg->tpg_nexus = tv_nexus; tpg->tpg_nexus = tv_nexus;
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
return 0; return 0;
} }
...@@ -1761,20 +1761,20 @@ static int tcm_vhost_drop_nexus(struct tcm_vhost_tpg *tpg) ...@@ -1761,20 +1761,20 @@ static int tcm_vhost_drop_nexus(struct tcm_vhost_tpg *tpg)
static ssize_t tcm_vhost_tpg_show_nexus(struct se_portal_group *se_tpg, static ssize_t tcm_vhost_tpg_show_nexus(struct se_portal_group *se_tpg,
char *page) char *page)
{ {
struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg, struct tcm_vhost_tpg *tpg = container_of(se_tpg,
struct tcm_vhost_tpg, se_tpg); struct tcm_vhost_tpg, se_tpg);
struct tcm_vhost_nexus *tv_nexus; struct tcm_vhost_nexus *tv_nexus;
ssize_t ret; ssize_t ret;
mutex_lock(&tv_tpg->tv_tpg_mutex); mutex_lock(&tpg->tv_tpg_mutex);
tv_nexus = tv_tpg->tpg_nexus; tv_nexus = tpg->tpg_nexus;
if (!tv_nexus) { if (!tv_nexus) {
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
return -ENODEV; return -ENODEV;
} }
ret = snprintf(page, PAGE_SIZE, "%s\n", ret = snprintf(page, PAGE_SIZE, "%s\n",
tv_nexus->tvn_se_sess->se_node_acl->initiatorname); tv_nexus->tvn_se_sess->se_node_acl->initiatorname);
mutex_unlock(&tv_tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
return ret; return ret;
} }
...@@ -1783,16 +1783,16 @@ static ssize_t tcm_vhost_tpg_store_nexus(struct se_portal_group *se_tpg, ...@@ -1783,16 +1783,16 @@ static ssize_t tcm_vhost_tpg_store_nexus(struct se_portal_group *se_tpg,
const char *page, const char *page,
size_t count) size_t count)
{ {
struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg, struct tcm_vhost_tpg *tpg = container_of(se_tpg,
struct tcm_vhost_tpg, se_tpg); struct tcm_vhost_tpg, se_tpg);
struct tcm_vhost_tport *tport_wwn = tv_tpg->tport; struct tcm_vhost_tport *tport_wwn = tpg->tport;
unsigned char i_port[TCM_VHOST_NAMELEN], *ptr, *port_ptr; unsigned char i_port[TCM_VHOST_NAMELEN], *ptr, *port_ptr;
int ret; int ret;
/* /*
* Shutdown the active I_T nexus if 'NULL' is passed.. * Shutdown the active I_T nexus if 'NULL' is passed..
*/ */
if (!strncmp(page, "NULL", 4)) { if (!strncmp(page, "NULL", 4)) {
ret = tcm_vhost_drop_nexus(tv_tpg); ret = tcm_vhost_drop_nexus(tpg);
return (!ret) ? count : ret; return (!ret) ? count : ret;
} }
/* /*
...@@ -1850,7 +1850,7 @@ static ssize_t tcm_vhost_tpg_store_nexus(struct se_portal_group *se_tpg, ...@@ -1850,7 +1850,7 @@ static ssize_t tcm_vhost_tpg_store_nexus(struct se_portal_group *se_tpg,
if (i_port[strlen(i_port)-1] == '\n') if (i_port[strlen(i_port)-1] == '\n')
i_port[strlen(i_port)-1] = '\0'; i_port[strlen(i_port)-1] = '\0';
ret = tcm_vhost_make_nexus(tv_tpg, port_ptr); ret = tcm_vhost_make_nexus(tpg, port_ptr);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册