diff options
Diffstat (limited to 'fs/xfs/xfs_dfrag.c')
-rw-r--r-- | fs/xfs/xfs_dfrag.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index 2211e885ef24..760f4c5b5160 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -128,10 +128,8 @@ xfs_swap_extents( | |||
128 | xfs_swapext_t *sxp) | 128 | xfs_swapext_t *sxp) |
129 | { | 129 | { |
130 | xfs_mount_t *mp; | 130 | xfs_mount_t *mp; |
131 | xfs_inode_t *ips[2]; | ||
132 | xfs_trans_t *tp; | 131 | xfs_trans_t *tp; |
133 | xfs_bstat_t *sbp = &sxp->sx_stat; | 132 | xfs_bstat_t *sbp = &sxp->sx_stat; |
134 | bhv_vnode_t *vp, *tvp; | ||
135 | xfs_ifork_t *tempifp, *ifp, *tifp; | 133 | xfs_ifork_t *tempifp, *ifp, *tifp; |
136 | int ilf_fields, tilf_fields; | 134 | int ilf_fields, tilf_fields; |
137 | static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL; | 135 | static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL; |
@@ -150,19 +148,8 @@ xfs_swap_extents( | |||
150 | } | 148 | } |
151 | 149 | ||
152 | sbp = &sxp->sx_stat; | 150 | sbp = &sxp->sx_stat; |
153 | vp = XFS_ITOV(ip); | ||
154 | tvp = XFS_ITOV(tip); | ||
155 | |||
156 | /* Lock in i_ino order */ | ||
157 | if (ip->i_ino < tip->i_ino) { | ||
158 | ips[0] = ip; | ||
159 | ips[1] = tip; | ||
160 | } else { | ||
161 | ips[0] = tip; | ||
162 | ips[1] = ip; | ||
163 | } | ||
164 | 151 | ||
165 | xfs_lock_inodes(ips, 2, lock_flags); | 152 | xfs_lock_two_inodes(ip, tip, lock_flags); |
166 | locked = 1; | 153 | locked = 1; |
167 | 154 | ||
168 | /* Verify that both files have the same format */ | 155 | /* Verify that both files have the same format */ |
@@ -184,7 +171,7 @@ xfs_swap_extents( | |||
184 | goto error0; | 171 | goto error0; |
185 | } | 172 | } |
186 | 173 | ||
187 | if (VN_CACHED(tvp) != 0) { | 174 | if (VN_CACHED(VFS_I(tip)) != 0) { |
188 | xfs_inval_cached_trace(tip, 0, -1, 0, -1); | 175 | xfs_inval_cached_trace(tip, 0, -1, 0, -1); |
189 | error = xfs_flushinval_pages(tip, 0, -1, | 176 | error = xfs_flushinval_pages(tip, 0, -1, |
190 | FI_REMAPF_LOCKED); | 177 | FI_REMAPF_LOCKED); |
@@ -193,7 +180,7 @@ xfs_swap_extents( | |||
193 | } | 180 | } |
194 | 181 | ||
195 | /* Verify O_DIRECT for ftmp */ | 182 | /* Verify O_DIRECT for ftmp */ |
196 | if (VN_CACHED(tvp) != 0) { | 183 | if (VN_CACHED(VFS_I(tip)) != 0) { |
197 | error = XFS_ERROR(EINVAL); | 184 | error = XFS_ERROR(EINVAL); |
198 | goto error0; | 185 | goto error0; |
199 | } | 186 | } |
@@ -237,7 +224,7 @@ xfs_swap_extents( | |||
237 | * vop_read (or write in the case of autogrow) they block on the iolock | 224 | * vop_read (or write in the case of autogrow) they block on the iolock |
238 | * until we have switched the extents. | 225 | * until we have switched the extents. |
239 | */ | 226 | */ |
240 | if (VN_MAPPED(vp)) { | 227 | if (VN_MAPPED(VFS_I(ip))) { |
241 | error = XFS_ERROR(EBUSY); | 228 | error = XFS_ERROR(EBUSY); |
242 | goto error0; | 229 | goto error0; |
243 | } | 230 | } |
@@ -265,7 +252,7 @@ xfs_swap_extents( | |||
265 | locked = 0; | 252 | locked = 0; |
266 | goto error0; | 253 | goto error0; |
267 | } | 254 | } |
268 | xfs_lock_inodes(ips, 2, XFS_ILOCK_EXCL); | 255 | xfs_lock_two_inodes(ip, tip, XFS_ILOCK_EXCL); |
269 | 256 | ||
270 | /* | 257 | /* |
271 | * Count the number of extended attribute blocks | 258 | * Count the number of extended attribute blocks |
@@ -350,15 +337,11 @@ xfs_swap_extents( | |||
350 | break; | 337 | break; |
351 | } | 338 | } |
352 | 339 | ||
353 | /* | ||
354 | * Increment vnode ref counts since xfs_trans_commit & | ||
355 | * xfs_trans_cancel will both unlock the inodes and | ||
356 | * decrement the associated ref counts. | ||
357 | */ | ||
358 | VN_HOLD(vp); | ||
359 | VN_HOLD(tvp); | ||
360 | 340 | ||
341 | IHOLD(ip); | ||
361 | xfs_trans_ijoin(tp, ip, lock_flags); | 342 | xfs_trans_ijoin(tp, ip, lock_flags); |
343 | |||
344 | IHOLD(tip); | ||
362 | xfs_trans_ijoin(tp, tip, lock_flags); | 345 | xfs_trans_ijoin(tp, tip, lock_flags); |
363 | 346 | ||
364 | xfs_trans_log_inode(tp, ip, ilf_fields); | 347 | xfs_trans_log_inode(tp, ip, ilf_fields); |