Commit c34d570d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: cleanup use of the XFS_ALLOC_ flags

Always set XFS_ALLOC_USERDATA for data fork allocations, and check it
in xfs_alloc_is_userdata instead of the current obsfucated check.
Also remove the xfs_alloc_is_userdata and xfs_alloc_allow_busy_reuse
helpers to make the code a little easier to understand.
Signed-off-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 fd638f1d
...@@ -331,7 +331,7 @@ xfs_alloc_compute_diff( ...@@ -331,7 +331,7 @@ xfs_alloc_compute_diff(
xfs_extlen_t newlen1=0; /* length with newbno1 */ xfs_extlen_t newlen1=0; /* length with newbno1 */
xfs_extlen_t newlen2=0; /* length with newbno2 */ xfs_extlen_t newlen2=0; /* length with newbno2 */
xfs_agblock_t wantend; /* end of target extent */ xfs_agblock_t wantend; /* end of target extent */
bool userdata = xfs_alloc_is_userdata(datatype); bool userdata = datatype & XFS_ALLOC_USERDATA;
ASSERT(freelen >= wantlen); ASSERT(freelen >= wantlen);
freeend = freebno + freelen; freeend = freebno + freelen;
...@@ -1041,9 +1041,9 @@ xfs_alloc_ag_vextent_small( ...@@ -1041,9 +1041,9 @@ xfs_alloc_ag_vextent_small(
goto out; goto out;
xfs_extent_busy_reuse(args->mp, args->agno, fbno, 1, xfs_extent_busy_reuse(args->mp, args->agno, fbno, 1,
xfs_alloc_allow_busy_reuse(args->datatype)); (args->datatype & XFS_ALLOC_NOBUSY));
if (xfs_alloc_is_userdata(args->datatype)) { if (args->datatype & XFS_ALLOC_USERDATA) {
struct xfs_buf *bp; struct xfs_buf *bp;
bp = xfs_btree_get_bufs(args->mp, args->tp, args->agno, fbno); bp = xfs_btree_get_bufs(args->mp, args->tp, args->agno, fbno);
...@@ -2381,7 +2381,7 @@ xfs_alloc_fix_freelist( ...@@ -2381,7 +2381,7 @@ xfs_alloc_fix_freelist(
* somewhere else if we are not being asked to try harder at this * somewhere else if we are not being asked to try harder at this
* point * point
*/ */
if (pag->pagf_metadata && xfs_alloc_is_userdata(args->datatype) && if (pag->pagf_metadata && (args->datatype & XFS_ALLOC_USERDATA) &&
(flags & XFS_ALLOC_FLAG_TRYLOCK)) { (flags & XFS_ALLOC_FLAG_TRYLOCK)) {
ASSERT(!(flags & XFS_ALLOC_FLAG_FREEING)); ASSERT(!(flags & XFS_ALLOC_FLAG_FREEING));
goto out_agbp_relse; goto out_agbp_relse;
......
...@@ -84,18 +84,6 @@ typedef struct xfs_alloc_arg { ...@@ -84,18 +84,6 @@ typedef struct xfs_alloc_arg {
#define XFS_ALLOC_INITIAL_USER_DATA (1 << 1)/* special case start of file */ #define XFS_ALLOC_INITIAL_USER_DATA (1 << 1)/* special case start of file */
#define XFS_ALLOC_NOBUSY (1 << 2)/* Busy extents not allowed */ #define XFS_ALLOC_NOBUSY (1 << 2)/* Busy extents not allowed */
static inline bool
xfs_alloc_is_userdata(int datatype)
{
return (datatype & ~XFS_ALLOC_NOBUSY) != 0;
}
static inline bool
xfs_alloc_allow_busy_reuse(int datatype)
{
return (datatype & XFS_ALLOC_NOBUSY) == 0;
}
/* freespace limit calculations */ /* freespace limit calculations */
#define XFS_ALLOC_AGFL_RESERVE 4 #define XFS_ALLOC_AGFL_RESERVE 4
unsigned int xfs_alloc_set_aside(struct xfs_mount *mp); unsigned int xfs_alloc_set_aside(struct xfs_mount *mp);
......
...@@ -3022,7 +3022,7 @@ xfs_bmap_adjacent( ...@@ -3022,7 +3022,7 @@ xfs_bmap_adjacent(
mp = ap->ip->i_mount; mp = ap->ip->i_mount;
nullfb = ap->tp->t_firstblock == NULLFSBLOCK; nullfb = ap->tp->t_firstblock == NULLFSBLOCK;
rt = XFS_IS_REALTIME_INODE(ap->ip) && rt = XFS_IS_REALTIME_INODE(ap->ip) &&
xfs_alloc_is_userdata(ap->datatype); (ap->datatype & XFS_ALLOC_USERDATA);
fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp,
ap->tp->t_firstblock); ap->tp->t_firstblock);
/* /*
...@@ -3375,7 +3375,7 @@ xfs_bmap_btalloc( ...@@ -3375,7 +3375,7 @@ xfs_bmap_btalloc(
if (ap->flags & XFS_BMAPI_COWFORK) if (ap->flags & XFS_BMAPI_COWFORK)
align = xfs_get_cowextsz_hint(ap->ip); align = xfs_get_cowextsz_hint(ap->ip);
else if (xfs_alloc_is_userdata(ap->datatype)) else if (ap->datatype & XFS_ALLOC_USERDATA)
align = xfs_get_extsz_hint(ap->ip); align = xfs_get_extsz_hint(ap->ip);
if (align) { if (align) {
error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
...@@ -3390,7 +3390,7 @@ xfs_bmap_btalloc( ...@@ -3390,7 +3390,7 @@ xfs_bmap_btalloc(
fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp,
ap->tp->t_firstblock); ap->tp->t_firstblock);
if (nullfb) { if (nullfb) {
if (xfs_alloc_is_userdata(ap->datatype) && if ((ap->datatype & XFS_ALLOC_USERDATA) &&
xfs_inode_is_filestream(ap->ip)) { xfs_inode_is_filestream(ap->ip)) {
ag = xfs_filestream_lookup_ag(ap->ip); ag = xfs_filestream_lookup_ag(ap->ip);
ag = (ag != NULLAGNUMBER) ? ag : 0; ag = (ag != NULLAGNUMBER) ? ag : 0;
...@@ -3430,7 +3430,7 @@ xfs_bmap_btalloc( ...@@ -3430,7 +3430,7 @@ xfs_bmap_btalloc(
* enough for the request. If one isn't found, then adjust * enough for the request. If one isn't found, then adjust
* the minimum allocation size to the largest space found. * the minimum allocation size to the largest space found.
*/ */
if (xfs_alloc_is_userdata(ap->datatype) && if ((ap->datatype & XFS_ALLOC_USERDATA) &&
xfs_inode_is_filestream(ap->ip)) xfs_inode_is_filestream(ap->ip))
error = xfs_bmap_btalloc_filestreams(ap, &args, &blen); error = xfs_bmap_btalloc_filestreams(ap, &args, &blen);
else else
...@@ -3973,10 +3973,9 @@ xfs_bmap_alloc_userdata( ...@@ -3973,10 +3973,9 @@ xfs_bmap_alloc_userdata(
*/ */
bma->datatype = XFS_ALLOC_NOBUSY; bma->datatype = XFS_ALLOC_NOBUSY;
if (whichfork == XFS_DATA_FORK) { if (whichfork == XFS_DATA_FORK) {
bma->datatype |= XFS_ALLOC_USERDATA;
if (bma->offset == 0) if (bma->offset == 0)
bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
else
bma->datatype |= XFS_ALLOC_USERDATA;
if (mp->m_dalign && bma->length >= mp->m_dalign) { if (mp->m_dalign && bma->length >= mp->m_dalign) {
error = xfs_bmap_isaeof(bma, whichfork); error = xfs_bmap_isaeof(bma, whichfork);
......
...@@ -367,7 +367,7 @@ xfs_extent_busy_trim( ...@@ -367,7 +367,7 @@ xfs_extent_busy_trim(
* If this is a metadata allocation, try to reuse the busy * If this is a metadata allocation, try to reuse the busy
* extent instead of trimming the allocation. * extent instead of trimming the allocation.
*/ */
if (!xfs_alloc_is_userdata(args->datatype) && if (!(args->datatype & XFS_ALLOC_USERDATA) &&
!(busyp->flags & XFS_EXTENT_BUSY_DISCARDED)) { !(busyp->flags & XFS_EXTENT_BUSY_DISCARDED)) {
if (!xfs_extent_busy_update_extent(args->mp, args->pag, if (!xfs_extent_busy_update_extent(args->mp, args->pag,
busyp, fbno, flen, busyp, fbno, flen,
......
...@@ -374,7 +374,7 @@ xfs_filestream_new_ag( ...@@ -374,7 +374,7 @@ xfs_filestream_new_ag(
startag = (item->ag + 1) % mp->m_sb.sb_agcount; startag = (item->ag + 1) % mp->m_sb.sb_agcount;
} }
if (xfs_alloc_is_userdata(ap->datatype)) if (ap->datatype & XFS_ALLOC_USERDATA)
flags |= XFS_PICK_USERDATA; flags |= XFS_PICK_USERDATA;
if (ap->tp->t_flags & XFS_TRANS_LOWMODE) if (ap->tp->t_flags & XFS_TRANS_LOWMODE)
flags |= XFS_PICK_LOWSPACE; flags |= XFS_PICK_LOWSPACE;
......
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