linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sandhya Bankar <bankarsandhya512@gmail.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	viro@zeniv.linux.org.uk, mawilcox@microsoft.com,
	keescook@chromium.org, adobriyan@gmail.com, re.emese@gmail.com,
	riel@surriel.com
Subject: [RESEND PATCH 12/13] vfs: Convert select to use idr_get_tag_batch()
Date: Tue, 11 Jul 2017 19:06:33 +0530	[thread overview]
Message-ID: <95215e24f0724f9a16b0ad6ea8ee1b9a070d133b.1493315290.git.bankarsandhya512@gmail.com> (raw)
In-Reply-To: <cover.1493315288.git.bankarsandhya512@gmail.com>

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 --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

  parent reply	other threads:[~2017-07-11 13:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11 11:36 [RESEND PATCH 00/13] vfs: Convert file allocation code to use the IDR Sandhya Bankar
2017-07-11 13:20 ` [RESEND PATCH 05/13] vfs: Replace array of file pointers with an IDR Sandhya Bankar
2017-10-04 15:45   ` Mateusz Guzik
2017-07-11 13:22 ` [RESEND PATCH 06/13] vfs: Remove next_fd from fd alloc code path Sandhya Bankar
2017-07-11 13:24 ` [RESEND PATCH 07/13] vfs: Remove full_fds_bits from fd allocation " Sandhya Bankar
2017-07-11 13:27 ` [RESEND PATCH 08/13] vfs: Use idr_tag_get() in fd_is_open() Sandhya Bankar
2017-07-11 13:29 ` [RESEND PATCH 09/13] vfs: Rewrite close_files() Sandhya Bankar
2017-07-11 13:32 ` [RESEND PATCH 10/13] vfs: Replace close_on_exec bitmap with an IDR tag Sandhya Bankar
2017-07-11 13:36 ` Sandhya Bankar [this message]
2017-07-11 13:38 ` [RESEND PATCH 13/13] vfs: Delete struct fdtable Sandhya Bankar
2017-07-11 14:15 ` [RESEND PATCH 04/13] idr, radix-tree: Implement copy_preload Sandhya Bankar
2017-07-11 14:19 ` [RESEND PATCH 03/13] idr, radix-tree: Add get_tag_batch function Sandhya Bankar
2017-07-11 14:21 ` [RESEND PATCH 02/13] idr: Add idr_for_each_entry_tagged() Sandhya Bankar
2017-07-11 14:24 ` [RESEND PATCH 01/13] idr: Add ability to set/clear tags Sandhya Bankar
2017-07-11 14:27 ` [RESEND PATCH 11/13] vfs: Add init_task.h include Sandhya Bankar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95215e24f0724f9a16b0ad6ea8ee1b9a070d133b.1493315290.git.bankarsandhya512@gmail.com \
    --to=bankarsandhya512@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mawilcox@microsoft.com \
    --cc=re.emese@gmail.com \
    --cc=riel@surriel.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).