Commit 4e529339 authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong

xfs: factor out nodiscard helpers

The changes to skip discards of speculative preallocation and
unwritten extents introduced several new wrapper functions through
the bunmapi -> extent free codepath to reduce churn in all of the
associated callers. In several cases, these wrappers simply toggle a
single flag to skip or not skip discards for the resulting blocks.

The explicit _nodiscard() wrappers for such an isolated set of
callers is a bit overkill. Kill off these wrappers and replace with
the calls to the underlying functions in the contexts that need to
control discard behavior. Retain the wrappers that preserve the
original calling conventions to serve the original purpose of
reducing code churn.

This is a refactoring patch and does not change behavior.
Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 67482129
...@@ -210,17 +210,6 @@ xfs_free_extent( ...@@ -210,17 +210,6 @@ xfs_free_extent(
return __xfs_free_extent(tp, bno, len, oinfo, type, false); return __xfs_free_extent(tp, bno, len, oinfo, type, false);
} }
static inline int
xfs_free_extent_nodiscard(
struct xfs_trans *tp,
xfs_fsblock_t bno,
xfs_extlen_t len,
struct xfs_owner_info *oinfo,
enum xfs_ag_resv_type type)
{
return __xfs_free_extent(tp, bno, len, oinfo, type, true);
}
int /* error */ int /* error */
xfs_alloc_lookup_le( xfs_alloc_lookup_le(
struct xfs_btree_cur *cur, /* btree cursor */ struct xfs_btree_cur *cur, /* btree cursor */
......
...@@ -5116,15 +5116,10 @@ xfs_bmap_del_extent_real( ...@@ -5116,15 +5116,10 @@ xfs_bmap_del_extent_real(
if (error) if (error)
goto done; goto done;
} else { } else {
if ((bflags & XFS_BMAPI_NODISCARD) || __xfs_bmap_add_free(mp, dfops, del->br_startblock,
(del->br_state == XFS_EXT_UNWRITTEN)) { del->br_blockcount, NULL,
xfs_bmap_add_free_nodiscard(mp, dfops, (bflags & XFS_BMAPI_NODISCARD) ||
del->br_startblock, del->br_blockcount, del->br_state == XFS_EXT_UNWRITTEN);
NULL);
} else {
xfs_bmap_add_free(mp, dfops, del->br_startblock,
del->br_blockcount, NULL);
}
} }
} }
......
...@@ -260,17 +260,6 @@ xfs_bmap_add_free( ...@@ -260,17 +260,6 @@ xfs_bmap_add_free(
__xfs_bmap_add_free(mp, dfops, bno, len, oinfo, false); __xfs_bmap_add_free(mp, dfops, bno, len, oinfo, false);
} }
static inline void
xfs_bmap_add_free_nodiscard(
struct xfs_mount *mp,
struct xfs_defer_ops *dfops,
xfs_fsblock_t bno,
xfs_filblks_t len,
struct xfs_owner_info *oinfo)
{
__xfs_bmap_add_free(mp, dfops, bno, len, oinfo, true);
}
enum xfs_bmap_intent_type { enum xfs_bmap_intent_type {
XFS_BMAP_MAP = 1, XFS_BMAP_MAP = 1,
XFS_BMAP_UNMAP, XFS_BMAP_UNMAP,
......
...@@ -871,8 +871,8 @@ xfs_free_eofblocks( ...@@ -871,8 +871,8 @@ xfs_free_eofblocks(
* contents of the file are flushed to disk then the files * contents of the file are flushed to disk then the files
* may be full of holes (ie NULL files bug). * may be full of holes (ie NULL files bug).
*/ */
error = xfs_itruncate_extents_nodiscard(&tp, ip, XFS_DATA_FORK, error = xfs_itruncate_extents_flags(&tp, ip, XFS_DATA_FORK,
XFS_ISIZE(ip)); XFS_ISIZE(ip), XFS_BMAPI_NODISCARD);
if (error) { if (error) {
/* /*
* If we get an error at this point we simply don't * If we get an error at this point we simply don't
......
...@@ -1548,12 +1548,12 @@ xfs_itruncate_clear_reflink_flags( ...@@ -1548,12 +1548,12 @@ xfs_itruncate_clear_reflink_flags(
* dirty on error so that transactions can be easily aborted if possible. * dirty on error so that transactions can be easily aborted if possible.
*/ */
int int
__xfs_itruncate_extents( xfs_itruncate_extents_flags(
struct xfs_trans **tpp, struct xfs_trans **tpp,
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork, int whichfork,
xfs_fsize_t new_size, xfs_fsize_t new_size,
bool skip_discard) int flags)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp = *tpp; struct xfs_trans *tp = *tpp;
...@@ -1564,7 +1564,6 @@ __xfs_itruncate_extents( ...@@ -1564,7 +1564,6 @@ __xfs_itruncate_extents(
xfs_filblks_t unmap_len; xfs_filblks_t unmap_len;
int error = 0; int error = 0;
int done = 0; int done = 0;
int flags;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
ASSERT(!atomic_read(&VFS_I(ip)->i_count) || ASSERT(!atomic_read(&VFS_I(ip)->i_count) ||
...@@ -1577,9 +1576,7 @@ __xfs_itruncate_extents( ...@@ -1577,9 +1576,7 @@ __xfs_itruncate_extents(
trace_xfs_itruncate_extents_start(ip, new_size); trace_xfs_itruncate_extents_start(ip, new_size);
flags = xfs_bmapi_aflag(whichfork); flags |= xfs_bmapi_aflag(whichfork);
if (skip_discard)
flags |= XFS_BMAPI_NODISCARD;
/* /*
* Since it is possible for space to become allocated beyond * Since it is possible for space to become allocated beyond
......
...@@ -415,8 +415,8 @@ uint xfs_ilock_attr_map_shared(struct xfs_inode *); ...@@ -415,8 +415,8 @@ uint xfs_ilock_attr_map_shared(struct xfs_inode *);
uint xfs_ip2xflags(struct xfs_inode *); uint xfs_ip2xflags(struct xfs_inode *);
int xfs_ifree(struct xfs_trans *, xfs_inode_t *, int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
struct xfs_defer_ops *); struct xfs_defer_ops *);
int __xfs_itruncate_extents(struct xfs_trans **, struct xfs_inode *, int xfs_itruncate_extents_flags(struct xfs_trans **,
int, xfs_fsize_t, bool); struct xfs_inode *, int, xfs_fsize_t, int);
void xfs_iext_realloc(xfs_inode_t *, int, int); void xfs_iext_realloc(xfs_inode_t *, int, int);
void xfs_iunpin_wait(xfs_inode_t *); void xfs_iunpin_wait(xfs_inode_t *);
...@@ -440,17 +440,7 @@ xfs_itruncate_extents( ...@@ -440,17 +440,7 @@ xfs_itruncate_extents(
int whichfork, int whichfork,
xfs_fsize_t new_size) xfs_fsize_t new_size)
{ {
return __xfs_itruncate_extents(tpp, ip, whichfork, new_size, false); return xfs_itruncate_extents_flags(tpp, ip, whichfork, new_size, 0);
}
static inline int
xfs_itruncate_extents_nodiscard(
struct xfs_trans **tpp,
struct xfs_inode *ip,
int whichfork,
xfs_fsize_t new_size)
{
return __xfs_itruncate_extents(tpp, ip, whichfork, new_size, true);
} }
/* from xfs_file.c */ /* from xfs_file.c */
......
...@@ -80,13 +80,8 @@ xfs_trans_free_extent( ...@@ -80,13 +80,8 @@ xfs_trans_free_extent(
trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno, ext_len); trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno, ext_len);
if (skip_discard) error = __xfs_free_extent(tp, start_block, ext_len,
error = xfs_free_extent_nodiscard(tp, start_block, ext_len, oinfo, XFS_AG_RESV_NONE, skip_discard);
oinfo, XFS_AG_RESV_NONE);
else
error = xfs_free_extent(tp, start_block, ext_len, oinfo,
XFS_AG_RESV_NONE);
/* /*
* Mark the transaction dirty, even on error. This ensures the * Mark the transaction dirty, even on error. This ensures the
* transaction is aborted, which: * transaction is aborted, which:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment