Skip to content

Commit 0d113fc

Browse files
author
Al Viro
committed
simplify xfs_find_handle() a bit
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 <[email protected]>
1 parent 54dac3d commit 0d113fc

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

fs/xfs/xfs_handle.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,23 @@ xfs_find_handle(
8585
int hsize;
8686
xfs_handle_t handle;
8787
struct inode *inode;
88-
struct fd f = EMPTY_FD;
8988
struct path path;
9089
int error;
9190
struct xfs_inode *ip;
9291

9392
if (cmd == XFS_IOC_FD_TO_HANDLE) {
94-
f = fdget(hreq->fd);
95-
if (!fd_file(f))
93+
CLASS(fd, f)(hreq->fd);
94+
95+
if (fd_empty(f))
9696
return -EBADF;
97-
inode = file_inode(fd_file(f));
97+
path = fd_file(f)->f_path;
98+
path_get(&path);
9899
} else {
99100
error = user_path_at(AT_FDCWD, hreq->path, 0, &path);
100101
if (error)
101102
return error;
102-
inode = d_inode(path.dentry);
103103
}
104+
inode = d_inode(path.dentry);
104105
ip = XFS_I(inode);
105106

106107
/*
@@ -134,10 +135,7 @@ xfs_find_handle(
134135
error = 0;
135136

136137
out_put:
137-
if (cmd == XFS_IOC_FD_TO_HANDLE)
138-
fdput(f);
139-
else
140-
path_put(&path);
138+
path_put(&path);
141139
return error;
142140
}
143141

0 commit comments

Comments
 (0)