]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.39/patches.drivers/libfc-make-fc_disc-inline-with.diff
Add ignored *.diff files of the xen patches
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.drivers / libfc-make-fc_disc-inline-with.diff
1 From: Chris Leech <christopher.leech@intel.com>
2 Subject: [FcOE] make fc_disc inline with the fc_lport structure
3 References: bnc #459142
4
5 The extra memory allocation we're not being checked for failure. Rather than
6 further complicating things, just make the discovery code required fields be
7 part of the lport structure.
8
9 Signed-off-by: Chris Leech <christopher.leech@intel.com>
10 Acked-by: Bernhard Walle <bwalle@suse.de>
11 ---
12
13 drivers/scsi/libfc/fc_disc.c | 80 +++++++-----------------------------------
14 drivers/scsi/libfc/fc_lport.c | 2 -
15 include/scsi/libfc.h | 22 ++++++++++-
16 3 files changed, 35 insertions(+), 69 deletions(-)
17
18
19 --- a/drivers/scsi/libfc/fc_disc.c
20 +++ b/drivers/scsi/libfc/fc_disc.c
21 @@ -45,26 +45,6 @@ static int fc_disc_debug;
22 FC_DBG(fmt); \
23 } while (0)
24
25 -struct fc_disc {
26 - unsigned char retry_count;
27 - unsigned char delay;
28 - unsigned char pending;
29 - unsigned char requested;
30 - unsigned short seq_count;
31 - unsigned char buf_len;
32 - enum fc_disc_event event;
33 -
34 - void (*disc_callback)(struct fc_lport *,
35 - enum fc_disc_event);
36 -
37 - struct list_head rports;
38 - struct fc_lport *lport;
39 - struct mutex disc_mutex;
40 - struct fc_gpn_ft_resp partial_buf; /* partial name buffer */
41 - struct delayed_work disc_work;
42 -
43 -};
44 -
45 static void fc_disc_gpn_ft_req(struct fc_disc *);
46 static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *);
47 static int fc_disc_new_target(struct fc_disc *, struct fc_rport *,
48 @@ -83,14 +63,11 @@ static void fc_disc_restart(struct fc_di
49 struct fc_rport *fc_disc_lookup_rport(const struct fc_lport *lport,
50 u32 port_id)
51 {
52 - struct fc_disc *disc = lport->disc;
53 + const struct fc_disc *disc = &lport->disc;
54 struct fc_rport *rport, *found = NULL;
55 struct fc_rport_libfc_priv *rdata;
56 int disc_found = 0;
57
58 - if (!disc)
59 - return NULL;
60 -
61 list_for_each_entry(rdata, &disc->rports, peers) {
62 rport = PRIV_TO_RPORT(rdata);
63 if (rport->port_id == port_id) {
64 @@ -108,27 +85,6 @@ struct fc_rport *fc_disc_lookup_rport(co
65 }
66
67 /**
68 - * fc_disc_alloc - Allocate a discovery work object
69 - * @lport: The FC lport associated with the discovery job
70 - */
71 -static inline struct fc_disc *fc_disc_alloc(struct fc_lport *lport)
72 -{
73 - struct fc_disc *disc;
74 -
75 - disc = kzalloc(sizeof(struct fc_disc), GFP_KERNEL);
76 - INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout);
77 - mutex_init(&disc->disc_mutex);
78 - INIT_LIST_HEAD(&disc->rports);
79 -
80 - disc->lport = lport;
81 - lport->disc = disc;
82 - disc->delay = FC_DISC_DELAY;
83 - disc->event = DISC_EV_NONE;
84 -
85 - return disc;
86 -}
87 -
88 -/**
89 * fc_disc_stop_rports - delete all the remote ports associated with the lport
90 * @disc: The discovery job to stop rports on
91 *
92 @@ -167,7 +123,7 @@ static void fc_disc_rport_callback(struc
93 enum fc_rport_event event)
94 {
95 struct fc_rport_libfc_priv *rdata = rport->dd_data;
96 - struct fc_disc *disc = lport->disc;
97 + struct fc_disc *disc = &lport->disc;
98 int found = 0;
99
100 FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event,
101 @@ -304,13 +260,7 @@ static void fc_disc_recv_req(struct fc_s
102 struct fc_lport *lport)
103 {
104 u8 op;
105 - struct fc_disc *disc = lport->disc;
106 -
107 - if (!disc) {
108 - FC_DBG("Received a request for an lport not managed "
109 - "by the discovery engine\n");
110 - return;
111 - }
112 + struct fc_disc *disc = &lport->disc;
113
114 op = fc_frame_payload_op(fp);
115 switch (op) {
116 @@ -365,17 +315,7 @@ static void fc_disc_start(void (*disc_ca
117 {
118 struct fc_rport *rport;
119 struct fc_rport_identifiers ids;
120 - struct fc_disc *disc = lport->disc;
121 -
122 - if (!disc) {
123 - FC_DEBUG_DISC("No existing discovery job, "
124 - "creating one for lport (%6x)\n",
125 - fc_host_port_id(lport->host));
126 - disc = fc_disc_alloc(lport);
127 - } else
128 - FC_DEBUG_DISC("Found an existing discovery job "
129 - "for lport (%6x)\n",
130 - fc_host_port_id(lport->host));
131 + struct fc_disc *disc = &lport->disc;
132
133 /*
134 * At this point we may have a new disc job or an existing
135 @@ -831,7 +771,7 @@ out:
136 */
137 void fc_disc_stop(struct fc_lport *lport)
138 {
139 - struct fc_disc *disc = lport->disc;
140 + struct fc_disc *disc = &lport->disc;
141
142 if (disc) {
143 cancel_delayed_work_sync(&disc->disc_work);
144 @@ -858,6 +798,7 @@ void fc_disc_stop_final(struct fc_lport
145 */
146 int fc_disc_init(struct fc_lport *lport)
147 {
148 + struct fc_disc *disc;
149
150 if (!lport->tt.disc_start)
151 lport->tt.disc_start = fc_disc_start;
152 @@ -874,6 +815,15 @@ int fc_disc_init(struct fc_lport *lport)
153 if (!lport->tt.rport_lookup)
154 lport->tt.rport_lookup = fc_disc_lookup_rport;
155
156 + disc = &lport->disc;
157 + INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout);
158 + mutex_init(&disc->disc_mutex);
159 + INIT_LIST_HEAD(&disc->rports);
160 +
161 + disc->lport = lport;
162 + disc->delay = FC_DISC_DELAY;
163 + disc->event = DISC_EV_NONE;
164 +
165 return 0;
166 }
167 EXPORT_SYMBOL(fc_disc_init);
168 --- a/drivers/scsi/libfc/fc_lport.c
169 +++ b/drivers/scsi/libfc/fc_lport.c
170 @@ -627,8 +627,6 @@ int fc_fabric_logoff(struct fc_lport *lp
171 {
172 lport->tt.disc_stop_final(lport);
173 mutex_lock(&lport->lp_mutex);
174 - kfree(lport->disc);
175 - lport->disc = NULL;
176 fc_lport_enter_logo(lport);
177 mutex_unlock(&lport->lp_mutex);
178 return 0;
179 --- a/include/scsi/libfc.h
180 +++ b/include/scsi/libfc.h
181 @@ -572,7 +572,25 @@ struct libfc_function_template {
182 void (*disc_stop_final) (struct fc_lport *);
183 };
184
185 -struct fc_disc;
186 +/* information used by the discovery layer */
187 +struct fc_disc {
188 + unsigned char retry_count;
189 + unsigned char delay;
190 + unsigned char pending;
191 + unsigned char requested;
192 + unsigned short seq_count;
193 + unsigned char buf_len;
194 + enum fc_disc_event event;
195 +
196 + void (*disc_callback)(struct fc_lport *,
197 + enum fc_disc_event);
198 +
199 + struct list_head rports;
200 + struct fc_lport *lport;
201 + struct mutex disc_mutex;
202 + struct fc_gpn_ft_resp partial_buf; /* partial name buffer */
203 + struct delayed_work disc_work;
204 +};
205
206 struct fc_lport {
207 struct list_head list;
208 @@ -582,8 +600,8 @@ struct fc_lport {
209 struct fc_exch_mgr *emp;
210 struct fc_rport *dns_rp;
211 struct fc_rport *ptp_rp;
212 - struct fc_disc *disc;
213 void *scsi_priv;
214 + struct fc_disc disc;
215
216 /* Operational Information */
217 struct libfc_function_template tt;