diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-02-04 20:13:07 -0500 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-02-07 02:22:02 -0500 |
commit | 35fec8df65217546f6d9d508b203c1d135a67fbc (patch) | |
tree | e6f7b4b8d4df7e2f5ac571ba39ad72f256102785 /fs/xfs | |
parent | 199037c598daf5f3602dace68c331665a4f4f0c1 (diff) |
[XFS] clean up xfs_swapext
- stop using vnodes
- use proper multiple label goto unwinding
- give the struct file * variables saner names
SGI-PV: 971186
SGI-Modid: xfs-linux-melb:xfs-kern:30366a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_dfrag.c | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index 03a42d21610a..5d3285952ff7 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -52,76 +52,61 @@ xfs_swapext( | |||
52 | xfs_swapext_t __user *sxu) | 52 | xfs_swapext_t __user *sxu) |
53 | { | 53 | { |
54 | xfs_swapext_t *sxp; | 54 | xfs_swapext_t *sxp; |
55 | xfs_inode_t *ip=NULL, *tip=NULL; | 55 | xfs_inode_t *ip, *tip; |
56 | xfs_mount_t *mp; | 56 | struct file *file, *target_file; |
57 | struct file *fp = NULL, *tfp = NULL; | ||
58 | bhv_vnode_t *vp, *tvp; | ||
59 | int error = 0; | 57 | int error = 0; |
60 | 58 | ||
61 | sxp = kmem_alloc(sizeof(xfs_swapext_t), KM_MAYFAIL); | 59 | sxp = kmem_alloc(sizeof(xfs_swapext_t), KM_MAYFAIL); |
62 | if (!sxp) { | 60 | if (!sxp) { |
63 | error = XFS_ERROR(ENOMEM); | 61 | error = XFS_ERROR(ENOMEM); |
64 | goto error0; | 62 | goto out; |
65 | } | 63 | } |
66 | 64 | ||
67 | if (copy_from_user(sxp, sxu, sizeof(xfs_swapext_t))) { | 65 | if (copy_from_user(sxp, sxu, sizeof(xfs_swapext_t))) { |
68 | error = XFS_ERROR(EFAULT); | 66 | error = XFS_ERROR(EFAULT); |
69 | goto error0; | 67 | goto out_free_sxp; |
70 | } | 68 | } |
71 | 69 | ||
72 | /* Pull information for the target fd */ | 70 | /* Pull information for the target fd */ |
73 | if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) || | 71 | file = fget((int)sxp->sx_fdtarget); |
74 | ((vp = vn_from_inode(fp->f_path.dentry->d_inode)) == NULL)) { | 72 | if (!file) { |
75 | error = XFS_ERROR(EINVAL); | 73 | error = XFS_ERROR(EINVAL); |
76 | goto error0; | 74 | goto out_free_sxp; |
77 | } | ||
78 | |||
79 | ip = xfs_vtoi(vp); | ||
80 | if (ip == NULL) { | ||
81 | error = XFS_ERROR(EBADF); | ||
82 | goto error0; | ||
83 | } | 75 | } |
84 | 76 | ||
85 | if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) || | 77 | target_file = fget((int)sxp->sx_fdtmp); |
86 | ((tvp = vn_from_inode(tfp->f_path.dentry->d_inode)) == NULL)) { | 78 | if (!target_file) { |
87 | error = XFS_ERROR(EINVAL); | 79 | error = XFS_ERROR(EINVAL); |
88 | goto error0; | 80 | goto out_put_file; |
89 | } | 81 | } |
90 | 82 | ||
91 | tip = xfs_vtoi(tvp); | 83 | ip = XFS_I(file->f_path.dentry->d_inode); |
92 | if (tip == NULL) { | 84 | tip = XFS_I(target_file->f_path.dentry->d_inode); |
93 | error = XFS_ERROR(EBADF); | ||
94 | goto error0; | ||
95 | } | ||
96 | 85 | ||
97 | if (ip->i_mount != tip->i_mount) { | 86 | if (ip->i_mount != tip->i_mount) { |
98 | error = XFS_ERROR(EINVAL); | 87 | error = XFS_ERROR(EINVAL); |
99 | goto error0; | 88 | goto out_put_target_file; |
100 | } | 89 | } |
101 | 90 | ||
102 | if (ip->i_ino == tip->i_ino) { | 91 | if (ip->i_ino == tip->i_ino) { |
103 | error = XFS_ERROR(EINVAL); | 92 | error = XFS_ERROR(EINVAL); |
104 | goto error0; | 93 | goto out_put_target_file; |
105 | } | 94 | } |
106 | 95 | ||
107 | mp = ip->i_mount; | 96 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
108 | 97 | error = XFS_ERROR(EIO); | |
109 | if (XFS_FORCED_SHUTDOWN(mp)) { | 98 | goto out_put_target_file; |
110 | error = XFS_ERROR(EIO); | ||
111 | goto error0; | ||
112 | } | 99 | } |
113 | 100 | ||
114 | error = xfs_swap_extents(ip, tip, sxp); | 101 | error = xfs_swap_extents(ip, tip, sxp); |
115 | 102 | ||
116 | error0: | 103 | out_put_target_file: |
117 | if (fp != NULL) | 104 | fput(target_file); |
118 | fput(fp); | 105 | out_put_file: |
119 | if (tfp != NULL) | 106 | fput(file); |
120 | fput(tfp); | 107 | out_free_sxp: |
121 | 108 | kmem_free(sxp, sizeof(xfs_swapext_t)); | |
122 | if (sxp != NULL) | 109 | out: |
123 | kmem_free(sxp, sizeof(xfs_swapext_t)); | ||
124 | |||
125 | return error; | 110 | return error; |
126 | } | 111 | } |
127 | 112 | ||