@@ -162,7 +162,7 @@ static struct fdtable *alloc_fdtable(unsigned int slots_wanted)
162
162
* Expand the file descriptor table.
163
163
* This function will allocate a new fdtable and both fd array and fdset, of
164
164
* the given size.
165
- * Return <0 error code on error; 1 on successful completion.
165
+ * Return <0 error code on error; 0 on successful completion.
166
166
* The files->file_lock should be held on entry, and will be held on exit.
167
167
*/
168
168
static int expand_fdtable (struct files_struct * files , unsigned int nr )
@@ -191,50 +191,48 @@ static int expand_fdtable(struct files_struct *files, unsigned int nr)
191
191
call_rcu (& cur_fdt -> rcu , free_fdtable_rcu );
192
192
/* coupled with smp_rmb() in fd_install() */
193
193
smp_wmb ();
194
- return 1 ;
194
+ return 0 ;
195
195
}
196
196
197
197
/*
198
198
* Expand files.
199
199
* This function will expand the file structures, if the requested size exceeds
200
200
* the current capacity and there is room for expansion.
201
- * Return <0 error code on error; 0 when nothing done; 1 when files were
202
- * expanded and execution may have blocked.
201
+ * Return <0 error code on error; 0 on success.
203
202
* The files->file_lock should be held on entry, and will be held on exit.
204
203
*/
205
204
static int expand_files (struct files_struct * files , unsigned int nr )
206
205
__releases (files - > file_lock )
207
206
__acquires (files - > file_lock )
208
207
{
209
208
struct fdtable * fdt ;
210
- int expanded = 0 ;
209
+ int error ;
211
210
212
211
repeat :
213
212
fdt = files_fdtable (files );
214
213
215
214
/* Do we need to expand? */
216
215
if (nr < fdt -> max_fds )
217
- return expanded ;
216
+ return 0 ;
218
217
219
218
/* Can we expand? */
220
219
if (nr >= sysctl_nr_open )
221
220
return - EMFILE ;
222
221
223
222
if (unlikely (files -> resize_in_progress )) {
224
223
spin_unlock (& files -> file_lock );
225
- expanded = 1 ;
226
224
wait_event (files -> resize_wait , !files -> resize_in_progress );
227
225
spin_lock (& files -> file_lock );
228
226
goto repeat ;
229
227
}
230
228
231
229
/* All good, so we try */
232
230
files -> resize_in_progress = true;
233
- expanded = expand_fdtable (files , nr );
231
+ error = expand_fdtable (files , nr );
234
232
files -> resize_in_progress = false;
235
233
236
234
wake_up_all (& files -> resize_wait );
237
- return expanded ;
235
+ return error ;
238
236
}
239
237
240
238
static inline void __set_close_on_exec (unsigned int fd , struct fdtable * fdt ,
@@ -507,12 +505,7 @@ static int alloc_fd(unsigned start, unsigned end, unsigned flags)
507
505
if (error < 0 )
508
506
goto out ;
509
507
510
- /*
511
- * If we needed to expand the fs array we
512
- * might have blocked - try again.
513
- */
514
- if (error )
515
- goto repeat ;
508
+ goto repeat ;
516
509
}
517
510
518
511
if (start <= files -> next_fd )
0 commit comments