diff mbox

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

Message ID 95215e24f0724f9a16b0ad6ea8ee1b9a070d133b.1493315290.git.bankarsandhya512@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sandhya Bankar April 27, 2017, 7:18 p.m. UTC
Convert select to use idr_get_tag_batch().

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

Patch

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;