]>
Commit | Line | Data |
---|---|---|
8f69975d BS |
1 | From: Robert Love <robert.w.love@intel.com> |
2 | Subject: [FcOE] Set the release function for the rport's kobject (round 2) | |
3 | References: bnc #459142 | |
4 | ||
5 | We need to be better about reference counting. The first | |
6 | step is to make use of the release function that is called | |
7 | when the reference count drops to 0. | |
8 | ||
9 | There was some inital push back by Joe on this patch. We | |
10 | talked off-list and agreed that the benefit of not having | |
11 | to check whether a rport is rogue or real overweighed the | |
12 | fact that we might be using reference counting on objects | |
13 | (rogue) that cannot be acted on by another thread. | |
14 | ||
15 | There is likely room for improvement here, but this should | |
16 | be a stable start. | |
17 | ||
18 | Signed-off-by: Robert Love <robert.w.love@intel.com> | |
19 | Acked-by: Bernhard Walle <bwalle@suse.de> | |
20 | --- | |
21 | ||
22 | drivers/scsi/libfc/fc_rport.c | 18 ++++++++++-------- | |
23 | include/scsi/libfc.h | 1 - | |
24 | 2 files changed, 10 insertions(+), 9 deletions(-) | |
25 | ||
26 | ||
27 | --- a/drivers/scsi/libfc/fc_rport.c | |
28 | +++ b/drivers/scsi/libfc/fc_rport.c | |
29 | @@ -93,6 +93,13 @@ static const char *fc_rport_state_names[ | |
30 | [RPORT_ST_LOGO] = "LOGO", | |
31 | }; | |
32 | ||
33 | +static void fc_rport_rogue_destroy(struct device *dev) | |
34 | +{ | |
35 | + struct fc_rport *rport = dev_to_rport(dev); | |
36 | + FC_DEBUG_RPORT("Destroying rogue rport (%6x)\n", rport->port_id); | |
37 | + kfree(rport); | |
38 | +} | |
39 | + | |
40 | struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp) | |
41 | { | |
42 | struct fc_rport *rport; | |
43 | @@ -115,7 +122,7 @@ struct fc_rport *fc_rport_rogue_create(s | |
44 | * upstream so it fine that this is really ugly and hacky right now. | |
45 | */ | |
46 | device_initialize(&rport->dev); | |
47 | - rport->dev.release = fc_rport_rogue_destroy; // XXX: bwalle | |
48 | + rport->dev.release = fc_rport_rogue_destroy; | |
49 | ||
50 | mutex_init(&rdata->rp_mutex); | |
51 | rdata->local_port = dp->lp; | |
52 | @@ -137,11 +144,6 @@ struct fc_rport *fc_rport_rogue_create(s | |
53 | return rport; | |
54 | } | |
55 | ||
56 | -void fc_rport_rogue_destroy(struct fc_rport *rport) | |
57 | -{ | |
58 | - kfree(rport); | |
59 | -} | |
60 | - | |
61 | /** | |
62 | * fc_rport_state - return a string for the state the rport is in | |
63 | * @rport: The rport whose state we want to get a string for | |
64 | @@ -263,7 +265,7 @@ static void fc_rport_work(struct work_st | |
65 | "(%6x).\n", ids.port_id); | |
66 | event = RPORT_EV_FAILED; | |
67 | } | |
68 | - fc_rport_rogue_destroy(rport); | |
69 | + put_device(&rport->dev); | |
70 | rport = new_rport; | |
71 | rdata = new_rport->dd_data; | |
72 | if (rport_ops->event_callback) | |
73 | @@ -276,7 +278,7 @@ static void fc_rport_work(struct work_st | |
74 | if (rport_ops->event_callback) | |
75 | rport_ops->event_callback(lport, rport, event); | |
76 | if (trans_state == FC_PORTSTATE_ROGUE) | |
77 | - fc_rport_rogue_destroy(rport); | |
78 | + put_device(&rport->dev); | |
79 | else | |
80 | fc_remote_port_delete(rport); | |
81 | } else | |
82 | --- a/include/scsi/libfc.h | |
83 | +++ b/include/scsi/libfc.h | |
84 | @@ -169,7 +169,6 @@ struct fc_rport_libfc_priv { | |
85 | (struct fc_rport_libfc_priv *)((void *)x + sizeof(struct fc_rport)); | |
86 | ||
87 | struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *); | |
88 | -void fc_rport_rogue_destroy(struct fc_rport *); | |
89 | ||
90 | static inline void fc_rport_set_name(struct fc_rport *rport, u64 wwpn, u64 wwnn) | |
91 | { |