From: Vadim Lobanov Fix the computation of the length of an allocated fdarray, when we decide to grow the fdtable. The rationale behind this fix is as follows: => The 'nr' variable is the requested fd, so will be one less than the minimum allowable fdarray size. => Due to the above fact, when we divide 'nr' by a fourth-of-a-page block, we will always be exactly one block short of the size we need. => Incrementing before the division is wrong, because the division will discard a non-zero modulo, possibly leaving us one fourth-of-a-page block short. Signed-off-by: Vadim Lobanov Signed-off-by: Andrew Morton --- fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff -puN fs/file.c~fdtable-implement-new-pagesize-based-fdtable-allocator-fix fs/file.c --- a/fs/file.c~fdtable-implement-new-pagesize-based-fdtable-allocator-fix +++ a/fs/file.c @@ -142,9 +142,8 @@ static struct fdtable * alloc_fdtable(un * the fdarray into page-sized chunks: starting at a quarter of a page, * and growing in powers of two from there on. */ - nr++; nr /= (PAGE_SIZE / 4 / sizeof(struct file *)); - nr = roundup_pow_of_two(nr); + nr = roundup_pow_of_two(nr + 1); nr *= (PAGE_SIZE / 4 / sizeof(struct file *)); if (nr > NR_OPEN) nr = NR_OPEN; _