mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
xfs: factor out xrep_reset_fork_to_extents helper for scrub/repair
The open-coded 8-line series of steps to reset a fork to empty extents format is repeated 3 times; factor this out into a helper to eliminate cut and paste. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
e029aeece8
commit
1e3f1adf6d
|
|
@ -1319,21 +1319,8 @@ xrep_xattr_swap_prep(
|
|||
* that to an empty extent list in preparation for the atomic mapping
|
||||
* exchange.
|
||||
*/
|
||||
if (ip_local) {
|
||||
struct xfs_ifork *ifp;
|
||||
|
||||
ifp = xfs_ifork_ptr(sc->ip, XFS_ATTR_FORK);
|
||||
|
||||
xfs_idestroy_fork(ifp);
|
||||
ifp->if_format = XFS_DINODE_FMT_EXTENTS;
|
||||
ifp->if_nextents = 0;
|
||||
ifp->if_bytes = 0;
|
||||
ifp->if_data = NULL;
|
||||
ifp->if_height = 0;
|
||||
|
||||
xfs_trans_log_inode(sc->tp, sc->ip,
|
||||
XFS_ILOG_CORE | XFS_ILOG_ADATA);
|
||||
}
|
||||
if (ip_local)
|
||||
xrep_reset_fork_to_extents(sc, XFS_ATTR_FORK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1510,20 +1510,8 @@ xrep_dir_swap_prep(
|
|||
* to an empty extent list in preparation for the atomic mapping
|
||||
* exchange.
|
||||
*/
|
||||
if (ip_local) {
|
||||
struct xfs_ifork *ifp;
|
||||
|
||||
ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK);
|
||||
xfs_idestroy_fork(ifp);
|
||||
ifp->if_format = XFS_DINODE_FMT_EXTENTS;
|
||||
ifp->if_nextents = 0;
|
||||
ifp->if_bytes = 0;
|
||||
ifp->if_data = NULL;
|
||||
ifp->if_height = 0;
|
||||
|
||||
xfs_trans_log_inode(sc->tp, sc->ip,
|
||||
XFS_ILOG_CORE | XFS_ILOG_DDATA);
|
||||
}
|
||||
if (ip_local)
|
||||
xrep_reset_fork_to_extents(sc, XFS_DATA_FORK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -882,6 +882,37 @@ xrep_ino_ensure_extent_count(
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Discard the contents of this fork and initialize as empty extent-format. */
|
||||
void
|
||||
xrep_reset_fork_to_extents(
|
||||
struct xfs_scrub *sc,
|
||||
int whichfork)
|
||||
{
|
||||
struct xfs_ifork *ifp = xfs_ifork_ptr(sc->ip, whichfork);
|
||||
uint ilog_flags = XFS_ILOG_CORE;
|
||||
|
||||
switch (whichfork) {
|
||||
case XFS_DATA_FORK:
|
||||
ilog_flags |= XFS_ILOG_DDATA;
|
||||
break;
|
||||
case XFS_ATTR_FORK:
|
||||
ilog_flags |= XFS_ILOG_ADATA;
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
return;
|
||||
}
|
||||
|
||||
xfs_idestroy_fork(ifp);
|
||||
ifp->if_format = XFS_DINODE_FMT_EXTENTS;
|
||||
ifp->if_nextents = 0;
|
||||
ifp->if_bytes = 0;
|
||||
ifp->if_data = NULL;
|
||||
ifp->if_height = 0;
|
||||
|
||||
xfs_trans_log_inode(sc->tp, sc->ip, ilog_flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize all the btree cursors for an AG repair except for the btree that
|
||||
* we're rebuilding.
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ int xrep_setup_xfbtree(struct xfs_scrub *sc, const char *descr);
|
|||
int xrep_ino_ensure_extent_count(struct xfs_scrub *sc, int whichfork,
|
||||
xfs_extnum_t nextents);
|
||||
int xrep_reset_perag_resv(struct xfs_scrub *sc);
|
||||
void xrep_reset_fork_to_extents(struct xfs_scrub *sc, int whichfork);
|
||||
int xrep_bmap(struct xfs_scrub *sc, int whichfork, bool allow_unwritten);
|
||||
int xrep_metadata_inode_forks(struct xfs_scrub *sc);
|
||||
int xrep_setup_ag_rmapbt(struct xfs_scrub *sc);
|
||||
|
|
|
|||
|
|
@ -303,20 +303,8 @@ xrep_symlink_swap_prep(
|
|||
* to an empty extent list in preparation for the atomic mapping
|
||||
* exchange.
|
||||
*/
|
||||
if (ip_local) {
|
||||
struct xfs_ifork *ifp;
|
||||
|
||||
ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK);
|
||||
xfs_idestroy_fork(ifp);
|
||||
ifp->if_format = XFS_DINODE_FMT_EXTENTS;
|
||||
ifp->if_nextents = 0;
|
||||
ifp->if_bytes = 0;
|
||||
ifp->if_data = NULL;
|
||||
ifp->if_height = 0;
|
||||
|
||||
xfs_trans_log_inode(sc->tp, sc->ip,
|
||||
XFS_ILOG_CORE | XFS_ILOG_DDATA);
|
||||
}
|
||||
if (ip_local)
|
||||
xrep_reset_fork_to_extents(sc, XFS_DATA_FORK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user