提交 9737e6a7 编写于 作者: R Robert Love 提交者: James Bottomley

[SCSI] libfc: Initialize fc_rport_identifiers inside fc_rport_create

Currently these values are initialized by the callers. This was exposed
by a later patch that adds PLOGI request support. The patch failed to
initialize the new remote port's roles and it caused problems. This patch
has the rport_create routine initialize the identifiers and then the
callers can override them with real values.
Signed-off-by: NRobert Love <robert.w.love@intel.com>
Signed-off-by: NJames Bottomley <James.Bottomley@suse.de>
上级 935d0fce
master alk-4.19.24 alk-4.19.30 alk-4.19.34 alk-4.19.36 alk-4.19.43 alk-4.19.48 alk-4.19.57 ck-4.19.67 ck-4.19.81 ck-4.19.91 github/fork/deepanshu1422/fix-typo-in-comment github/fork/haosdent/fix-typo linux-next v4.19.91 v4.19.90 v4.19.89 v4.19.88 v4.19.87 v4.19.86 v4.19.85 v4.19.84 v4.19.83 v4.19.82 v4.19.81 v4.19.80 v4.19.79 v4.19.78 v4.19.77 v4.19.76 v4.19.75 v4.19.74 v4.19.73 v4.19.72 v4.19.71 v4.19.70 v4.19.69 v4.19.68 v4.19.67 v4.19.66 v4.19.65 v4.19.64 v4.19.63 v4.19.62 v4.19.61 v4.19.60 v4.19.59 v4.19.58 v4.19.57 v4.19.56 v4.19.55 v4.19.54 v4.19.53 v4.19.52 v4.19.51 v4.19.50 v4.19.49 v4.19.48 v4.19.47 v4.19.46 v4.19.45 v4.19.44 v4.19.43 v4.19.42 v4.19.41 v4.19.40 v4.19.39 v4.19.38 v4.19.37 v4.19.36 v4.19.35 v4.19.34 v4.19.33 v4.19.32 v4.19.31 v4.19.30 v4.19.29 v4.19.28 v4.19.27 v4.19.26 v4.19.25 v4.19.24 v4.19.23 v4.19.22 v4.19.21 v4.19.20 v4.19.19 v4.19.18 v4.19.17 v4.19.16 v4.19.15 v4.19.14 v4.19.13 v4.19.12 v4.19.11 v4.19.10 v4.19.9 v4.19.8 v4.19.7 v4.19.6 v4.19.5 v4.19.4 v4.19.3 v4.19.2 v4.19.1 v4.19 v4.19-rc8 v4.19-rc7 v4.19-rc6 v4.19-rc5 v4.19-rc4 v4.19-rc3 v4.19-rc2 v4.19-rc1 ck-release-21 ck-release-20 ck-release-19.2 ck-release-19.1 ck-release-19 ck-release-18 ck-release-17.2 ck-release-17.1 ck-release-17 ck-release-16 ck-release-15.1 ck-release-15 ck-release-14 ck-release-13.2 ck-release-13 ck-release-12 ck-release-11 ck-release-10 ck-release-9 ck-release-7 alk-release-15 alk-release-14 alk-release-13.2 alk-release-13 alk-release-12 alk-release-11 alk-release-10 alk-release-9 alk-release-7
无相关合并请求
......@@ -137,10 +137,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
break;
}
dp->lp = lport;
dp->ids.port_id = ntoh24(pp->rscn_fid);
dp->ids.port_name = -1;
dp->ids.node_name = -1;
dp->ids.roles = FC_RPORT_ROLE_UNKNOWN;
dp->port_id = ntoh24(pp->rscn_fid);
list_add_tail(&dp->peers, &disc_ports);
break;
case ELS_ADDR_FMT_AREA:
......@@ -162,7 +159,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
redisc, lport->state, disc->pending);
list_for_each_entry_safe(dp, next, &disc_ports, peers) {
list_del(&dp->peers);
rdata = lport->tt.rport_lookup(lport, dp->ids.port_id);
rdata = lport->tt.rport_lookup(lport, dp->port_id);
if (rdata) {
lport->tt.rport_logoff(rdata);
}
......@@ -435,15 +432,14 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
while (plen >= sizeof(*np)) {
ids.port_id = ntoh24(np->fp_fid);
ids.port_name = ntohll(np->fp_wwpn);
ids.node_name = -1;
ids.roles = FC_RPORT_ROLE_UNKNOWN;
if (ids.port_id != fc_host_port_id(lport->host) &&
ids.port_name != lport->wwpn) {
rdata = lport->tt.rport_create(lport, &ids);
if (rdata)
rdata = lport->tt.rport_create(lport, ids.port_id);
if (rdata) {
rdata->ids.port_name = ids.port_name;
rdata->disc_id = disc->disc_id;
else {
} else {
printk(KERN_WARNING "libfc: Failed to allocate "
"memory for the newly discovered port "
"(%6x)\n", ids.port_id);
......@@ -580,10 +576,10 @@ static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
lport = disc->lport;
if (dp->ids.port_id == fc_host_port_id(lport->host))
if (dp->port_id == fc_host_port_id(lport->host))
goto out;
rdata = lport->tt.rport_create(lport, &dp->ids);
rdata = lport->tt.rport_create(lport, dp->port_id);
if (rdata) {
rdata->disc_id = disc->disc_id;
kfree(dp);
......
......@@ -198,17 +198,12 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
u32 remote_fid, u64 remote_wwpn,
u64 remote_wwnn)
{
struct fc_rport_identifiers ids;
ids.port_id = remote_fid;
ids.port_name = remote_wwpn;
ids.node_name = remote_wwnn;
ids.roles = FC_RPORT_ROLE_UNKNOWN;
mutex_lock(&lport->disc.disc_mutex);
if (lport->ptp_rp)
lport->tt.rport_logoff(lport->ptp_rp);
lport->ptp_rp = lport->tt.rport_create(lport, &ids);
lport->ptp_rp = lport->tt.rport_create(lport, remote_fid);
lport->ptp_rp->ids.port_name = remote_wwpn;
lport->ptp_rp->ids.node_name = remote_wwnn;
mutex_unlock(&lport->disc.disc_mutex);
lport->tt.rport_login(lport->ptp_rp);
......@@ -1287,12 +1282,6 @@ static struct fc_rport_operations fc_lport_rport_ops = {
static void fc_lport_enter_dns(struct fc_lport *lport)
{
struct fc_rport_priv *rdata;
struct fc_rport_identifiers ids;
ids.port_id = FC_FID_DIR_SERV;
ids.port_name = -1;
ids.node_name = -1;
ids.roles = FC_RPORT_ROLE_UNKNOWN;
FC_LPORT_DBG(lport, "Entered DNS state from %s state\n",
fc_lport_state(lport));
......@@ -1300,7 +1289,7 @@ static void fc_lport_enter_dns(struct fc_lport *lport)
fc_lport_state_enter(lport, LPORT_ST_DNS);
mutex_lock(&lport->disc.disc_mutex);
rdata = lport->tt.rport_create(lport, &ids);
rdata = lport->tt.rport_create(lport, FC_FID_DIR_SERV);
mutex_unlock(&lport->disc.disc_mutex);
if (!rdata)
goto err;
......
......@@ -104,18 +104,18 @@ static struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport,
}
/**
* fc_rport_create() - create remote port in INIT state.
* @lport: local port.
* @ids: remote port identifiers.
* fc_rport_create() - Create a new remote port
* @lport: The local port that the new remote port is for
* @port_id: The port ID for the new remote port
*
* Locking note: must be called with the disc_mutex held.
*/
static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport,
struct fc_rport_identifiers *ids)
u32 port_id)
{
struct fc_rport_priv *rdata;
rdata = lport->tt.rport_lookup(lport, ids->port_id);
rdata = lport->tt.rport_lookup(lport, port_id);
if (rdata)
return rdata;
......@@ -123,7 +123,11 @@ static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport,
if (!rdata)
return NULL;
rdata->ids = *ids;
rdata->ids.node_name = -1;
rdata->ids.port_name = -1;
rdata->ids.port_id = port_id;
rdata->ids.roles = FC_RPORT_ROLE_UNKNOWN;
kref_init(&rdata->kref);
mutex_init(&rdata->rp_mutex);
rdata->local_port = lport;
......@@ -135,7 +139,7 @@ static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport,
rdata->maxframe_size = FC_MIN_MAX_PAYLOAD;
INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout);
INIT_WORK(&rdata->event_work, fc_rport_work);
if (ids->port_id != FC_FID_DIR_SERV)
if (port_id != FC_FID_DIR_SERV)
list_add(&rdata->peers, &lport->disc.rports);
return rdata;
}
......
......@@ -148,16 +148,16 @@ enum fc_rport_state {
/**
* struct fc_disc_port - temporary discovery port to hold rport identifiers
* @lp: Fibre Channel host port instance
* @peers: node for list management during discovery and RSCN processing
* @ids: identifiers structure to pass to fc_remote_port_add()
* @rport_work: work struct for starting the rport state machine
* @lp: Fibre Channel host port instance
* @peers: Node for list management during discovery and RSCN processing
* @rport_work: Work struct for starting the rport state machine
* @port_id: Port ID of the discovered port
*/
struct fc_disc_port {
struct fc_lport *lp;
struct list_head peers;
struct fc_rport_identifiers ids;
struct work_struct rport_work;
u32 port_id;
};
enum fc_rport_event {
......@@ -565,10 +565,11 @@ struct libfc_function_template {
int (*lport_reset)(struct fc_lport *);
/*
* Create a remote port
* Create a remote port with a given port ID
*
* STATUS: OPTIONAL
*/
struct fc_rport_priv *(*rport_create)(struct fc_lport *,
struct fc_rport_identifiers *);
struct fc_rport_priv *(*rport_create)(struct fc_lport *, u32);
/*
* Initiates the RP state machine. It is called from the LP module.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部