]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
simplify xfs_find_handle() a bit
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 1 Jun 2024 06:18:39 +0000 (02:18 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 3 Nov 2024 06:28:06 +0000 (01:28 -0500)
XFS_IOC_FD_TO_HANDLE can grab a reference to copied ->f_path and
let the file go; results in simpler control flow - cleanup is
the same for both "by descriptor" and "by pathname" cases.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/xfs/xfs_handle.c

index 49e5e5f04e60339100a67e61a0e21d22f5d48204..f19fce557354eca77d3fd1d4a0ffe573eb1b59f4 100644 (file)
@@ -85,22 +85,23 @@ xfs_find_handle(
        int                     hsize;
        xfs_handle_t            handle;
        struct inode            *inode;
-       struct fd               f = EMPTY_FD;
        struct path             path;
        int                     error;
        struct xfs_inode        *ip;
 
        if (cmd == XFS_IOC_FD_TO_HANDLE) {
-               f = fdget(hreq->fd);
-               if (!fd_file(f))
+               CLASS(fd, f)(hreq->fd);
+
+               if (fd_empty(f))
                        return -EBADF;
-               inode = file_inode(fd_file(f));
+               path = fd_file(f)->f_path;
+               path_get(&path);
        } else {
                error = user_path_at(AT_FDCWD, hreq->path, 0, &path);
                if (error)
                        return error;
-               inode = d_inode(path.dentry);
        }
+       inode = d_inode(path.dentry);
        ip = XFS_I(inode);
 
        /*
@@ -134,10 +135,7 @@ xfs_find_handle(
        error = 0;
 
  out_put:
-       if (cmd == XFS_IOC_FD_TO_HANDLE)
-               fdput(f);
-       else
-               path_put(&path);
+       path_put(&path);
        return error;
 }