lkml.org 
[lkml]   [2020]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 07/12] eventfd: use __anon_inode_getfd
Date
Use __anon_inode_getfd instead of opencoding the logic using
get_unused_fd_flags + anon_inode_getfile.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/eventfd.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/fs/eventfd.c b/fs/eventfd.c
index df466ef81dddf..9b6d5137679b2 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -423,20 +423,11 @@ static int do_eventfd(unsigned int count, int flags)
ctx->count = count;
ctx->flags = flags;
ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL);
-
- flags &= EFD_SHARED_FCNTL_FLAGS;
- flags |= O_RDWR;
- fd = get_unused_fd_flags(flags);
+ fd = __anon_inode_getfd("[eventfd]", &eventfd_fops, ctx,
+ (flags & EFD_SHARED_FCNTL_FLAGS) | O_RDWR, &file);
if (fd < 0)
goto err;

- file = anon_inode_getfile("[eventfd]", &eventfd_fops, ctx, flags);
- if (IS_ERR(file)) {
- put_unused_fd(fd);
- fd = PTR_ERR(file);
- goto err;
- }
-
file->f_mode |= FMODE_NOWAIT;
fd_install(fd, file);
return fd;
--
2.26.2
\
 
 \ /
  Last update: 2020-05-08 17:37    [W:0.104 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site