[PATCH 12/13] vfs: Convert select to use idr_get_tag_batch()

From: Sandhya Bankar
Date: Sat Apr 29 2017 - 03:52:17 EST


Convert select to use idr_get_tag_batch().

Signed-off-by: Sandhya Bankar <bankarsandhya512@xxxxxxxxx>
Signed-off-by: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx>
---
fs/select.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/select.c b/fs/select.c
index e211227..5d20a14 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -346,32 +346,33 @@ static int poll_select_copy_remaining(struct timespec64 *end_time,

static int max_select_fd(unsigned long n, fd_set_bits *fds)
{
- unsigned long *open_fds;
+ unsigned long bad_fds;
unsigned long set;
int max;
- struct fdtable *fdt;
+ struct idr *fd_idr = &current->files->fd_idr;

/* handle last in-complete long-word first */
set = ~(~0UL << (n & (BITS_PER_LONG-1)));
n /= BITS_PER_LONG;
- fdt = files_fdtable(current->files);
- open_fds = fdt->open_fds + n;
max = 0;
if (set) {
set &= BITS(fds, n);
if (set) {
- if (!(set & ~*open_fds))
+ bad_fds = idr_get_tag_batch(fd_idr, (n * BITS_PER_LONG),
+ IDR_FREE);
+ if (!(set & bad_fds))
goto get_max;
return -EBADF;
}
}
while (n) {
- open_fds--;
n--;
set = BITS(fds, n);
if (!set)
continue;
- if (set & ~*open_fds)
+ bad_fds = idr_get_tag_batch(fd_idr, (n * BITS_PER_LONG),
+ IDR_FREE);
+ if (set & bad_fds)
return -EBADF;
if (max)
continue;
--
1.8.3.1