Commit e6f7e14
nfs_localio: simplify interface to nfsd for getting nfsd_file
The nfsd_localio_operations structure contains nfsd_file_get() to get a
reference to an nfsd_file. This is only used in one place, where
nfsd_open_local_fh() is also used.
This patch combines the two, calling nfsd_open_local_fh() passing a
pointer to where the nfsd_file pointer might be stored. If there is a
pointer there an nfsd_file_get() can get a reference, that reference is
returned. If not a new nfsd_file is acquired, stored at the pointer,
and returned. When we store a reference we also increase the refcount
on the net, as that refcount is decrements when we clear the stored
pointer.
We now get an extra reference *before* storing the new nfsd_file at the
given location. This avoids possible races with the nfsd_file being
freed before the final reference can be taken.
This patch moves the rcu_dereference() needed after fetching from
ro_file or rw_file into the nfsd code where the 'struct nfs_file' is
fully defined. This avoids an error reported by older versions of gcc
such as gcc-8 which complain about rcu_dereference() use in contexts
where the structure (which will supposedly be accessed) is not fully
defined.
Reported-by: Pali Rohár <pali@kernel.org>
Reported-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Fixes: 86e0041 ("nfs: cache all open LOCALIO nfsd_file(s) in client")
Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>1 parent 77e82fb commit e6f7e14
3 files changed
+55
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | 212 | | |
218 | 213 | | |
219 | 214 | | |
| |||
228 | 223 | | |
229 | 224 | | |
230 | 225 | | |
| 226 | + | |
231 | 227 | | |
232 | 228 | | |
233 | 229 | | |
234 | 230 | | |
235 | 231 | | |
236 | | - | |
| 232 | + | |
237 | 233 | | |
238 | 234 | | |
239 | 235 | | |
| |||
260 | 256 | | |
261 | 257 | | |
262 | 258 | | |
263 | | - | |
| 259 | + | |
264 | 260 | | |
265 | 261 | | |
266 | 262 | | |
| |||
272 | 268 | | |
273 | 269 | | |
274 | 270 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
293 | 274 | | |
294 | 275 | | |
295 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
264 | | - | |
| 265 | + | |
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | 27 | | |
42 | 28 | | |
43 | 29 | | |
| |||
46 | 32 | | |
47 | 33 | | |
48 | 34 | | |
| 35 | + | |
49 | 36 | | |
50 | 37 | | |
51 | 38 | | |
| |||
56 | 43 | | |
57 | 44 | | |
58 | 45 | | |
59 | | - | |
| 46 | + | |
60 | 47 | | |
61 | 48 | | |
62 | | - | |
| 49 | + | |
| 50 | + | |
63 | 51 | | |
64 | 52 | | |
65 | 53 | | |
| |||
73 | 61 | | |
74 | 62 | | |
75 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
76 | 70 | | |
77 | 71 | | |
78 | 72 | | |
| |||
94 | 88 | | |
95 | 89 | | |
96 | 90 | | |
97 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
98 | 114 | | |
99 | 115 | | |
100 | 116 | | |
101 | 117 | | |
102 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
103 | 132 | | |
104 | 133 | | |
105 | 134 | | |
| |||
0 commit comments