xfs_bmap_util: use swap macro
Make use of the swap macro and remove some unnecessary variables. This makes the code easier to read and maintain. Also, reduces the stack usage. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
1d5bebbafc
commit
897992b7e3
@ -1688,7 +1688,6 @@ xfs_swap_extent_forks(
|
|||||||
int *src_log_flags,
|
int *src_log_flags,
|
||||||
int *target_log_flags)
|
int *target_log_flags)
|
||||||
{
|
{
|
||||||
struct xfs_ifork tempifp, *ifp, *tifp;
|
|
||||||
xfs_filblks_t aforkblks = 0;
|
xfs_filblks_t aforkblks = 0;
|
||||||
xfs_filblks_t taforkblks = 0;
|
xfs_filblks_t taforkblks = 0;
|
||||||
xfs_extnum_t junk;
|
xfs_extnum_t junk;
|
||||||
@ -1730,11 +1729,7 @@ xfs_swap_extent_forks(
|
|||||||
/*
|
/*
|
||||||
* Swap the data forks of the inodes
|
* Swap the data forks of the inodes
|
||||||
*/
|
*/
|
||||||
ifp = &ip->i_df;
|
swap(ip->i_df, tip->i_df);
|
||||||
tifp = &tip->i_df;
|
|
||||||
tempifp = *ifp; /* struct copy */
|
|
||||||
*ifp = *tifp; /* struct copy */
|
|
||||||
*tifp = tempifp; /* struct copy */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fix the on-disk inode values
|
* Fix the on-disk inode values
|
||||||
@ -1743,13 +1738,8 @@ xfs_swap_extent_forks(
|
|||||||
ip->i_d.di_nblocks = tip->i_d.di_nblocks - taforkblks + aforkblks;
|
ip->i_d.di_nblocks = tip->i_d.di_nblocks - taforkblks + aforkblks;
|
||||||
tip->i_d.di_nblocks = tmp + taforkblks - aforkblks;
|
tip->i_d.di_nblocks = tmp + taforkblks - aforkblks;
|
||||||
|
|
||||||
tmp = (uint64_t) ip->i_d.di_nextents;
|
swap(ip->i_d.di_nextents, tip->i_d.di_nextents);
|
||||||
ip->i_d.di_nextents = tip->i_d.di_nextents;
|
swap(ip->i_d.di_format, tip->i_d.di_format);
|
||||||
tip->i_d.di_nextents = tmp;
|
|
||||||
|
|
||||||
tmp = (uint64_t) ip->i_d.di_format;
|
|
||||||
ip->i_d.di_format = tip->i_d.di_format;
|
|
||||||
tip->i_d.di_format = tmp;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The extents in the source inode could still contain speculative
|
* The extents in the source inode could still contain speculative
|
||||||
@ -1844,7 +1834,6 @@ xfs_swap_extents(
|
|||||||
int src_log_flags, target_log_flags;
|
int src_log_flags, target_log_flags;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int lock_flags;
|
int lock_flags;
|
||||||
struct xfs_ifork *cowfp;
|
|
||||||
uint64_t f;
|
uint64_t f;
|
||||||
int resblks = 0;
|
int resblks = 0;
|
||||||
|
|
||||||
@ -1986,18 +1975,11 @@ xfs_swap_extents(
|
|||||||
|
|
||||||
/* Swap the cow forks. */
|
/* Swap the cow forks. */
|
||||||
if (xfs_sb_version_hasreflink(&mp->m_sb)) {
|
if (xfs_sb_version_hasreflink(&mp->m_sb)) {
|
||||||
xfs_extnum_t extnum;
|
|
||||||
|
|
||||||
ASSERT(ip->i_cformat == XFS_DINODE_FMT_EXTENTS);
|
ASSERT(ip->i_cformat == XFS_DINODE_FMT_EXTENTS);
|
||||||
ASSERT(tip->i_cformat == XFS_DINODE_FMT_EXTENTS);
|
ASSERT(tip->i_cformat == XFS_DINODE_FMT_EXTENTS);
|
||||||
|
|
||||||
extnum = ip->i_cnextents;
|
swap(ip->i_cnextents, tip->i_cnextents);
|
||||||
ip->i_cnextents = tip->i_cnextents;
|
swap(ip->i_cowfp, tip->i_cowfp);
|
||||||
tip->i_cnextents = extnum;
|
|
||||||
|
|
||||||
cowfp = ip->i_cowfp;
|
|
||||||
ip->i_cowfp = tip->i_cowfp;
|
|
||||||
tip->i_cowfp = cowfp;
|
|
||||||
|
|
||||||
if (ip->i_cowfp && ip->i_cowfp->if_bytes)
|
if (ip->i_cowfp && ip->i_cowfp->if_bytes)
|
||||||
xfs_inode_set_cowblocks_tag(ip);
|
xfs_inode_set_cowblocks_tag(ip);
|
||||||
|
Loading…
Reference in New Issue
Block a user