diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-08-12 06:49:48 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-12 17:56:06 -0400 |
commit | a133d952b44cef278d2da664d742d51ef95f4dd3 (patch) | |
tree | 7a6f2d8bfc9be9d29246f2ed94582186331cbd45 /fs/xfs/xfs_ioctl.c | |
parent | e546cb79ef7ebe53060369dae665fa449a544353 (diff) |
xfs: consolidate extent swap code
So we don't need xfs_dfrag.h in userspace anymore, move the extent
swap ioctl structure definition to xfs_fs.h where most of the other
ioctl structure definitions are.
Now that we don't need separate files for extent swapping, separate
the basic file descriptor checking code to xfs_ioctl.c, and the code
that does the extent swap operation to xfs_bmap_util.c. This
cleanly separates the user interface code from the physical
mechanism used to do the extent swap.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_ioctl.c')
-rw-r--r-- | fs/xfs/xfs_ioctl.c | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 557c7b8b2425..efb216de5f69 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include "xfs_bmap.h" | 35 | #include "xfs_bmap.h" |
36 | #include "xfs_bmap_util.h" | 36 | #include "xfs_bmap_util.h" |
37 | #include "xfs_buf_item.h" | 37 | #include "xfs_buf_item.h" |
38 | #include "xfs_dfrag.h" | ||
39 | #include "xfs_fsops.h" | 38 | #include "xfs_fsops.h" |
40 | #include "xfs_discard.h" | 39 | #include "xfs_discard.h" |
41 | #include "xfs_quota.h" | 40 | #include "xfs_quota.h" |
@@ -1363,6 +1362,75 @@ xfs_ioc_getbmapx( | |||
1363 | return 0; | 1362 | return 0; |
1364 | } | 1363 | } |
1365 | 1364 | ||
1365 | int | ||
1366 | xfs_ioc_swapext( | ||
1367 | xfs_swapext_t *sxp) | ||
1368 | { | ||
1369 | xfs_inode_t *ip, *tip; | ||
1370 | struct fd f, tmp; | ||
1371 | int error = 0; | ||
1372 | |||
1373 | /* Pull information for the target fd */ | ||
1374 | f = fdget((int)sxp->sx_fdtarget); | ||
1375 | if (!f.file) { | ||
1376 | error = XFS_ERROR(EINVAL); | ||
1377 | goto out; | ||
1378 | } | ||
1379 | |||
1380 | if (!(f.file->f_mode & FMODE_WRITE) || | ||
1381 | !(f.file->f_mode & FMODE_READ) || | ||
1382 | (f.file->f_flags & O_APPEND)) { | ||
1383 | error = XFS_ERROR(EBADF); | ||
1384 | goto out_put_file; | ||
1385 | } | ||
1386 | |||
1387 | tmp = fdget((int)sxp->sx_fdtmp); | ||
1388 | if (!tmp.file) { | ||
1389 | error = XFS_ERROR(EINVAL); | ||
1390 | goto out_put_file; | ||
1391 | } | ||
1392 | |||
1393 | if (!(tmp.file->f_mode & FMODE_WRITE) || | ||
1394 | !(tmp.file->f_mode & FMODE_READ) || | ||
1395 | (tmp.file->f_flags & O_APPEND)) { | ||
1396 | error = XFS_ERROR(EBADF); | ||
1397 | goto out_put_tmp_file; | ||
1398 | } | ||
1399 | |||
1400 | if (IS_SWAPFILE(file_inode(f.file)) || | ||
1401 | IS_SWAPFILE(file_inode(tmp.file))) { | ||
1402 | error = XFS_ERROR(EINVAL); | ||
1403 | goto out_put_tmp_file; | ||
1404 | } | ||
1405 | |||
1406 | ip = XFS_I(file_inode(f.file)); | ||
1407 | tip = XFS_I(file_inode(tmp.file)); | ||
1408 | |||
1409 | if (ip->i_mount != tip->i_mount) { | ||
1410 | error = XFS_ERROR(EINVAL); | ||
1411 | goto out_put_tmp_file; | ||
1412 | } | ||
1413 | |||
1414 | if (ip->i_ino == tip->i_ino) { | ||
1415 | error = XFS_ERROR(EINVAL); | ||
1416 | goto out_put_tmp_file; | ||
1417 | } | ||
1418 | |||
1419 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) { | ||
1420 | error = XFS_ERROR(EIO); | ||
1421 | goto out_put_tmp_file; | ||
1422 | } | ||
1423 | |||
1424 | error = xfs_swap_extents(ip, tip, sxp); | ||
1425 | |||
1426 | out_put_tmp_file: | ||
1427 | fdput(tmp); | ||
1428 | out_put_file: | ||
1429 | fdput(f); | ||
1430 | out: | ||
1431 | return error; | ||
1432 | } | ||
1433 | |||
1366 | /* | 1434 | /* |
1367 | * Note: some of the ioctl's return positive numbers as a | 1435 | * Note: some of the ioctl's return positive numbers as a |
1368 | * byte count indicating success, such as readlink_by_handle. | 1436 | * byte count indicating success, such as readlink_by_handle. |
@@ -1507,7 +1575,7 @@ xfs_file_ioctl( | |||
1507 | error = mnt_want_write_file(filp); | 1575 | error = mnt_want_write_file(filp); |
1508 | if (error) | 1576 | if (error) |
1509 | return error; | 1577 | return error; |
1510 | error = xfs_swapext(&sxp); | 1578 | error = xfs_ioc_swapext(&sxp); |
1511 | mnt_drop_write_file(filp); | 1579 | mnt_drop_write_file(filp); |
1512 | return -error; | 1580 | return -error; |
1513 | } | 1581 | } |