switch simple cases of fget_light to fdget

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro
2012-08-28 12:52:22 -04:00
parent a5b470ba06
commit 2903ff019b
44 changed files with 631 additions and 761 deletions

View File

@@ -48,44 +48,44 @@ xfs_swapext(
xfs_swapext_t *sxp)
{
xfs_inode_t *ip, *tip;
struct file *file, *tmp_file;
int error = 0, fput_needed, fput_needed_tmp;
struct fd f, tmp;
int error = 0;
/* Pull information for the target fd */
file = fget_light((int)sxp->sx_fdtarget, &fput_needed);
if (!file) {
f = fdget((int)sxp->sx_fdtarget);
if (!f.file) {
error = XFS_ERROR(EINVAL);
goto out;
}
if (!(file->f_mode & FMODE_WRITE) ||
!(file->f_mode & FMODE_READ) ||
(file->f_flags & O_APPEND)) {
if (!(f.file->f_mode & FMODE_WRITE) ||
!(f.file->f_mode & FMODE_READ) ||
(f.file->f_flags & O_APPEND)) {
error = XFS_ERROR(EBADF);
goto out_put_file;
}
tmp_file = fget_light((int)sxp->sx_fdtmp, &fput_needed_tmp);
if (!tmp_file) {
tmp = fdget((int)sxp->sx_fdtmp);
if (!tmp.file) {
error = XFS_ERROR(EINVAL);
goto out_put_file;
}
if (!(tmp_file->f_mode & FMODE_WRITE) ||
!(tmp_file->f_mode & FMODE_READ) ||
(tmp_file->f_flags & O_APPEND)) {
if (!(tmp.file->f_mode & FMODE_WRITE) ||
!(tmp.file->f_mode & FMODE_READ) ||
(tmp.file->f_flags & O_APPEND)) {
error = XFS_ERROR(EBADF);
goto out_put_tmp_file;
}
if (IS_SWAPFILE(file->f_path.dentry->d_inode) ||
IS_SWAPFILE(tmp_file->f_path.dentry->d_inode)) {
if (IS_SWAPFILE(f.file->f_path.dentry->d_inode) ||
IS_SWAPFILE(tmp.file->f_path.dentry->d_inode)) {
error = XFS_ERROR(EINVAL);
goto out_put_tmp_file;
}
ip = XFS_I(file->f_path.dentry->d_inode);
tip = XFS_I(tmp_file->f_path.dentry->d_inode);
ip = XFS_I(f.file->f_path.dentry->d_inode);
tip = XFS_I(tmp.file->f_path.dentry->d_inode);
if (ip->i_mount != tip->i_mount) {
error = XFS_ERROR(EINVAL);
@@ -105,9 +105,9 @@ xfs_swapext(
error = xfs_swap_extents(ip, tip, sxp);
out_put_tmp_file:
fput_light(tmp_file, fput_needed_tmp);
fdput(tmp);
out_put_file:
fput_light(file, fput_needed);
fdput(f);
out:
return error;
}

View File

@@ -70,16 +70,16 @@ xfs_find_handle(
int hsize;
xfs_handle_t handle;
struct inode *inode;
struct file *file = NULL;
struct fd f;
struct path path;
int error, fput_needed;
int error;
struct xfs_inode *ip;
if (cmd == XFS_IOC_FD_TO_HANDLE) {
file = fget_light(hreq->fd, &fput_needed);
if (!file)
f = fdget(hreq->fd);
if (!f.file)
return -EBADF;
inode = file->f_path.dentry->d_inode;
inode = f.file->f_path.dentry->d_inode;
} else {
error = user_lpath((const char __user *)hreq->path, &path);
if (error)
@@ -134,7 +134,7 @@ xfs_find_handle(
out_put:
if (cmd == XFS_IOC_FD_TO_HANDLE)
fput_light(file, fput_needed);
fdput(f);
else
path_put(&path);
return error;