Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1633261

[PATCH 08/13] vfs: Use idr_tag_get() in fd_is_open().

From Sandhya Bankar <bankarsandhya512@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 08/13] vfs: Use idr_tag_get() in fd_is_open().
Date 2017-04-29 09:50 +0200
Message-ID <tBviG-3qf-9@gated-at.bofh.it> (permalink)
References <tBuZk-3il-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Use idr_tag_get() in fd_is_open() to know whether a given fd is
allocated.  Also move fd_is_open() to file.c and make it static
as it is only called from one place.

Signed-off-by: Sandhya Bankar <bankarsandhya512@gmail.com>
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
---
 fs/file.c               | 7 ++++++-
 include/linux/fdtable.h | 5 -----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index e8c6ada..8d67968 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -222,6 +222,11 @@ static int expand_files(struct files_struct *files, unsigned int nr)
 	return expanded;
 }
 
+static inline bool fd_is_open(unsigned int fd, struct files_struct *files)
+{
+	return !idr_tag_get(&files->fd_idr, fd, IDR_FREE);
+}
+
 static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt)
 {
 	__set_bit(fd, fdt->close_on_exec);
@@ -778,7 +783,7 @@ static int do_dup2(struct files_struct *files,
 	 */
 	fdt = files_fdtable(files);
 	tofree = idr_find(&files->fd_idr, fd);
-	if (!tofree && fd_is_open(fd, fdt))
+	if (!tofree && fd_is_open(fd, files))
 		goto Ebusy;
 	get_file(file);
 	if (tofree) {
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 6bece35..67259f4 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -34,11 +34,6 @@ static inline bool close_on_exec(unsigned int fd, const struct fdtable *fdt)
 	return test_bit(fd, fdt->close_on_exec);
 }
 
-static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt)
-{
-	return test_bit(fd, fdt->open_fds);
-}
-
 /*
  * Open file table structure
  */
-- 
1.8.3.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/13] vfs: Convert file allocation code to use the IDR Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:30 +0200
  [PATCH 02/13] idr: Add idr_for_each_entry_tagged() Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:40 +0200
  [PATCH 03/13] idr, radix-tree: Add get_tag_batch function Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:50 +0200
  [PATCH 08/13] vfs: Use idr_tag_get() in fd_is_open(). Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:50 +0200
  [PATCH 04/13] idr, radix-tree: Implement copy_preload Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:50 +0200
  [PATCH 07/13] vfs: Remove full_fds_bits from fd allocation code path. Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:50 +0200
  [PATCH 09/13] vfs: Rewrite close_files() Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:50 +0200
  [PATCH 05/13] vfs: Replace array of file pointers with an IDR Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:50 +0200
  [PATCH 06/13] vfs: Remove next_fd from fd alloc code path. Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:50 +0200
  [PATCH 10/13] vfs: Replace close_on_exec bitmap with an IDR tag Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 09:50 +0200
  [PATCH 13/13] vfs: Delete struct fdtable Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 10:00 +0200
  [PATCH 12/13] vfs: Convert select to use idr_get_tag_batch() Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 10:00 +0200
  [PATCH 11/13] vfs: Add init_task.h include Sandhya Bankar <bankarsandhya512@gmail.com> - 2017-04-29 10:00 +0200

csiph-web