Skip to content

Commit aeea4b7

Browse files
Brian Fosterdjwong
authored andcommitted
xfs: move local to extent inode logging into bmap helper
The callers of xfs_bmap_local_to_extents_empty() log the inode external to the function, yet this function is where the on-disk format value is updated. Push the inode logging down into the function itself to help prevent future mistakes. Note that internal bmap callers track the inode logging flags independently and thus may log the inode core twice due to this change. This is harmless, so leave this code around for consistency with the other attr fork conversion functions. Signed-off-by: Brian Foster <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 603efeb commit aeea4b7

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,7 @@ xfs_attr_shortform_to_leaf(
826826
sf = (xfs_attr_shortform_t *)tmpbuffer;
827827

828828
xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
829-
xfs_bmap_local_to_extents_empty(dp, XFS_ATTR_FORK);
830-
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
829+
xfs_bmap_local_to_extents_empty(args->trans, dp, XFS_ATTR_FORK);
831830

832831
bp = NULL;
833832
error = xfs_da_grow_inode(args, &blkno);

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ xfs_bmap_extents_to_btree(
792792
*/
793793
void
794794
xfs_bmap_local_to_extents_empty(
795+
struct xfs_trans *tp,
795796
struct xfs_inode *ip,
796797
int whichfork)
797798
{
@@ -808,6 +809,7 @@ xfs_bmap_local_to_extents_empty(
808809
ifp->if_u1.if_root = NULL;
809810
ifp->if_height = 0;
810811
XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
812+
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
811813
}
812814

813815

@@ -840,7 +842,7 @@ xfs_bmap_local_to_extents(
840842
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL);
841843

842844
if (!ifp->if_bytes) {
843-
xfs_bmap_local_to_extents_empty(ip, whichfork);
845+
xfs_bmap_local_to_extents_empty(tp, ip, whichfork);
844846
flags = XFS_ILOG_CORE;
845847
goto done;
846848
}
@@ -887,7 +889,7 @@ xfs_bmap_local_to_extents(
887889

888890
/* account for the change in fork size */
889891
xfs_idata_realloc(ip, -ifp->if_bytes, whichfork);
890-
xfs_bmap_local_to_extents_empty(ip, whichfork);
892+
xfs_bmap_local_to_extents_empty(tp, ip, whichfork);
891893
flags |= XFS_ILOG_CORE;
892894

893895
ifp->if_u1.if_root = NULL;

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
182182
xfs_filblks_t len);
183183
int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
184184
int xfs_bmap_set_attrforkoff(struct xfs_inode *ip, int size, int *version);
185-
void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
185+
void xfs_bmap_local_to_extents_empty(struct xfs_trans *tp,
186+
struct xfs_inode *ip, int whichfork);
186187
void __xfs_bmap_add_free(struct xfs_trans *tp, xfs_fsblock_t bno,
187188
xfs_filblks_t len, const struct xfs_owner_info *oinfo,
188189
bool skip_discard);

fs/xfs/libxfs/xfs_dir2_block.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,9 +1096,8 @@ xfs_dir2_sf_to_block(
10961096
memcpy(sfp, oldsfp, ifp->if_bytes);
10971097

10981098
xfs_idata_realloc(dp, -ifp->if_bytes, XFS_DATA_FORK);
1099-
xfs_bmap_local_to_extents_empty(dp, XFS_DATA_FORK);
1099+
xfs_bmap_local_to_extents_empty(tp, dp, XFS_DATA_FORK);
11001100
dp->i_d.di_size = 0;
1101-
xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
11021101

11031102
/*
11041103
* Add block 0 to the inode.

0 commit comments

Comments
 (0)