Skip to content

Commit

Permalink
xfs: move more RT specific code under CONFIG_XFS_RT
Browse files Browse the repository at this point in the history
Various utility functions and interfaces that iterate internal
devices try to reference the realtime device even when RT support is
not compiled into the kernel.

Make sure this code is excluded from the CONFIG_XFS_RT=n build,
and where appropriate stub functions to return fatal errors if
they ever get called when RT support is not present.

Signed-Off-By: Dave Chinner <[email protected]>
Reviewed-by: Brian Foster <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
  • Loading branch information
Dave Chinner authored and djwong committed Oct 11, 2017
1 parent 20413e3 commit bb9c2e5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/xfs/xfs_bmap_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ xfs_zero_extent(
GFP_NOFS, 0);
}

#ifdef CONFIG_XFS_RT
int
xfs_bmap_rtalloc(
struct xfs_bmalloca *ap) /* bmap alloc argument struct */
Expand Down Expand Up @@ -190,6 +191,7 @@ xfs_bmap_rtalloc(
}
return 0;
}
#endif /* CONFIG_XFS_RT */

/*
* Check if the endoff is outside the last extent. If so the caller will grow
Expand Down
13 changes: 13 additions & 0 deletions fs/xfs/xfs_bmap_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ struct xfs_mount;
struct xfs_trans;
struct xfs_bmalloca;

#ifdef CONFIG_XFS_RT
int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
#else /* !CONFIG_XFS_RT */
/*
* Attempts to allocate RT extents when RT is disable indicates corruption and
* should trigger a shutdown.
*/
static inline int
xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
{
return -EFSCORRUPTED;
}
#endif /* CONFIG_XFS_RT */

int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
int whichfork, int *eof);
int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
Expand Down
12 changes: 12 additions & 0 deletions fs/xfs/xfs_fsmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ __xfs_getfsmap_rtdev(
return query_fn(tp, info);
}

#ifdef CONFIG_XFS_RT
/* Actually query the realtime bitmap. */
STATIC int
xfs_getfsmap_rtdev_rtbitmap_query(
Expand Down Expand Up @@ -561,6 +562,7 @@ xfs_getfsmap_rtdev_rtbitmap(
return __xfs_getfsmap_rtdev(tp, keys, xfs_getfsmap_rtdev_rtbitmap_query,
info);
}
#endif /* CONFIG_XFS_RT */

/* Execute a getfsmap query against the regular data device. */
STATIC int
Expand Down Expand Up @@ -795,7 +797,15 @@ xfs_getfsmap_check_keys(
return false;
}

/*
* There are only two devices if we didn't configure RT devices at build time.
*/
#ifdef CONFIG_XFS_RT
#define XFS_GETFSMAP_DEVS 3
#else
#define XFS_GETFSMAP_DEVS 2
#endif /* CONFIG_XFS_RT */

/*
* Get filesystem's extents as described in head, and format for
* output. Calls formatter to fill the user's buffer until all
Expand Down Expand Up @@ -853,10 +863,12 @@ xfs_getfsmap(
handlers[1].dev = new_encode_dev(mp->m_logdev_targp->bt_dev);
handlers[1].fn = xfs_getfsmap_logdev;
}
#ifdef CONFIG_XFS_RT
if (mp->m_rtdev_targp) {
handlers[2].dev = new_encode_dev(mp->m_rtdev_targp->bt_dev);
handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap;
}
#endif /* CONFIG_XFS_RT */

xfs_sort(handlers, XFS_GETFSMAP_DEVS, sizeof(struct xfs_getfsmap_dev),
xfs_getfsmap_dev_compare);
Expand Down

0 comments on commit bb9c2e5

Please sign in to comment.