Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 144452
b: refs/heads/master
c: b4c6f54
h: refs/heads/master
v: v3
  • Loading branch information
Abhijeet Joglekar authored and James Bottomley committed Apr 27, 2009
1 parent b7c6ef6 commit a46e969
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 76f6804e7e7bb836cbdf4a73fe6c5485e4cc04c2
refs/heads/master: b4c6f54632ad664a3d9e7f05e4ea0f1803e32755
36 changes: 25 additions & 11 deletions trunk/drivers/scsi/libfc/fc_disc.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ void fc_disc_stop_rports(struct fc_disc *disc)
lport->tt.rport_logoff(rport);
}

list_for_each_entry_safe(rdata, next, &disc->rogue_rports, peers) {
rport = PRIV_TO_RPORT(rdata);
lport->tt.rport_logoff(rport);
}

mutex_unlock(&disc->disc_mutex);
}

Expand All @@ -131,23 +136,32 @@ static void fc_disc_rport_callback(struct fc_lport *lport,
{
struct fc_rport_libfc_priv *rdata = rport->dd_data;
struct fc_disc *disc = &lport->disc;
int found = 0;

FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event,
rport->port_id);

if (event == RPORT_EV_CREATED) {
switch (event) {
case RPORT_EV_CREATED:
if (disc) {
found = 1;
mutex_lock(&disc->disc_mutex);
list_add_tail(&rdata->peers, &disc->rports);
mutex_unlock(&disc->disc_mutex);
}
break;
case RPORT_EV_LOGO:
case RPORT_EV_FAILED:
case RPORT_EV_STOP:
mutex_lock(&disc->disc_mutex);
mutex_lock(&rdata->rp_mutex);
if (rdata->trans_state == FC_PORTSTATE_ROGUE)
list_del(&rdata->peers);
mutex_unlock(&rdata->rp_mutex);
mutex_unlock(&disc->disc_mutex);
break;
default:
break;
}

if (!found)
FC_DEBUG_DISC("The rport (%6x) is not maintained "
"by the discovery layer\n", rport->port_id);
}

/**
Expand Down Expand Up @@ -439,6 +453,7 @@ static int fc_disc_new_target(struct fc_disc *disc,
rdata = rport->dd_data;
rdata->ops = &fc_disc_rport_ops;
rdata->rp_state = RPORT_ST_INIT;
list_add_tail(&rdata->peers, &disc->rogue_rports);
lport->tt.rport_login(rport);
}
}
Expand Down Expand Up @@ -630,6 +645,8 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
rdata = rport->dd_data;
rdata->ops = &fc_disc_rport_ops;
rdata->local_port = lport;
list_add_tail(&rdata->peers,
&disc->rogue_rports);
lport->tt.rport_login(rport);
} else
FC_DBG("Failed to allocate memory for "
Expand Down Expand Up @@ -769,7 +786,6 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
{
struct fc_lport *lport;
struct fc_rport *rport;
struct fc_rport *new_rport;
struct fc_rport_libfc_priv *rdata;

Expand All @@ -778,15 +794,12 @@ static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
if (dp->ids.port_id == fc_host_port_id(lport->host))
goto out;

rport = lport->tt.rport_lookup(lport, dp->ids.port_id);
if (rport)
fc_disc_del_target(disc, rport);

new_rport = lport->tt.rport_create(dp);
if (new_rport) {
rdata = new_rport->dd_data;
rdata->ops = &fc_disc_rport_ops;
kfree(dp);
list_add_tail(&rdata->peers, &disc->rogue_rports);
lport->tt.rport_login(new_rport);
}
return;
Expand Down Expand Up @@ -848,6 +861,7 @@ int fc_disc_init(struct fc_lport *lport)
INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout);
mutex_init(&disc->disc_mutex);
INIT_LIST_HEAD(&disc->rports);
INIT_LIST_HEAD(&disc->rogue_rports);

disc->lport = lport;
disc->delay = FC_DISC_DELAY;
Expand Down
28 changes: 28 additions & 0 deletions trunk/drivers/scsi/libfc/fc_rport.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ static void fc_rport_work(struct work_struct *work)
"(%6x).\n", ids.port_id);
event = RPORT_EV_FAILED;
}
if (rport->port_id != FC_FID_DIR_SERV)
if (rport_ops->event_callback)
rport_ops->event_callback(lport, rport,
RPORT_EV_FAILED);
put_device(&rport->dev);
rport = new_rport;
rdata = new_rport->dd_data;
Expand Down Expand Up @@ -325,11 +329,20 @@ int fc_rport_login(struct fc_rport *rport)
int fc_rport_logoff(struct fc_rport *rport)
{
struct fc_rport_libfc_priv *rdata = rport->dd_data;
struct fc_lport *lport = rdata->local_port;

mutex_lock(&rdata->rp_mutex);

FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id);

if (rdata->rp_state == RPORT_ST_NONE) {
FC_DEBUG_RPORT("(%6x): Port (%6x) in NONE state,"
" not removing", fc_host_port_id(lport->host),
rport->port_id);
mutex_unlock(&rdata->rp_mutex);
goto out;
}

fc_rport_enter_logo(rport);

/*
Expand All @@ -349,6 +362,7 @@ int fc_rport_logoff(struct fc_rport *rport)

mutex_unlock(&rdata->rp_mutex);

out:
return 0;
}

Expand Down Expand Up @@ -1015,6 +1029,8 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
default:
FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected "
"state %d\n", sid, rdata->rp_state);
fc_frame_free(fp);
return;
break;
}

Expand Down Expand Up @@ -1106,6 +1122,8 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
reason = ELS_RJT_NONE;
break;
default:
fc_frame_free(rx_fp);
return;
break;
}
len = fr_len(rx_fp) - sizeof(*fh);
Expand Down Expand Up @@ -1235,6 +1253,11 @@ static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp,
"while in state %s\n", ntoh24(fh->fh_s_id),
fc_rport_state(rport));

if (rdata->rp_state == RPORT_ST_NONE) {
fc_frame_free(fp);
return;
}

rjt_data.fp = NULL;
rjt_data.reason = ELS_RJT_UNAB;
rjt_data.explan = ELS_EXPL_NONE;
Expand Down Expand Up @@ -1264,6 +1287,11 @@ static void fc_rport_recv_logo_req(struct fc_rport *rport, struct fc_seq *sp,
"while in state %s\n", ntoh24(fh->fh_s_id),
fc_rport_state(rport));

if (rdata->rp_state == RPORT_ST_NONE) {
fc_frame_free(fp);
return;
}

rdata->event = RPORT_EV_LOGO;
queue_work(rport_event_queue, &rdata->event_work);

Expand Down
1 change: 1 addition & 0 deletions trunk/include/scsi/libfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ struct fc_disc {
enum fc_disc_event);

struct list_head rports;
struct list_head rogue_rports;
struct fc_lport *lport;
struct mutex disc_mutex;
struct fc_gpn_ft_resp partial_buf; /* partial name buffer */
Expand Down

0 comments on commit a46e969

Please sign in to comment.