Commit 732436ef authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: convert XFS_IFORK_PTR to a static inline helper

We're about to make this logic do a bit more, so convert the macro to a
static inline function for better typechecking and fewer shouty macros.
No functional changes here.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 0f38063d
...@@ -1056,7 +1056,7 @@ xfs_attr_shortform_verify( ...@@ -1056,7 +1056,7 @@ xfs_attr_shortform_verify(
int64_t size; int64_t size;
ASSERT(ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL); ASSERT(ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL);
ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK); ifp = xfs_ifork_ptr(ip, XFS_ATTR_FORK);
sfp = (struct xfs_attr_shortform *)ifp->if_u1.if_data; sfp = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
size = ifp->if_bytes; size = ifp->if_bytes;
......
...@@ -128,7 +128,7 @@ xfs_bmbt_lookup_first( ...@@ -128,7 +128,7 @@ xfs_bmbt_lookup_first(
*/ */
static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork) static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
return whichfork != XFS_COW_FORK && return whichfork != XFS_COW_FORK &&
ifp->if_format == XFS_DINODE_FMT_EXTENTS && ifp->if_format == XFS_DINODE_FMT_EXTENTS &&
...@@ -140,7 +140,7 @@ static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork) ...@@ -140,7 +140,7 @@ static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork)
*/ */
static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork) static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
return whichfork != XFS_COW_FORK && return whichfork != XFS_COW_FORK &&
ifp->if_format == XFS_DINODE_FMT_BTREE && ifp->if_format == XFS_DINODE_FMT_BTREE &&
...@@ -319,7 +319,7 @@ xfs_bmap_check_leaf_extents( ...@@ -319,7 +319,7 @@ xfs_bmap_check_leaf_extents(
int whichfork) /* data or attr fork */ int whichfork) /* data or attr fork */
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_btree_block *block; /* current btree block */ struct xfs_btree_block *block; /* current btree block */
xfs_fsblock_t bno; /* block # of "block" */ xfs_fsblock_t bno; /* block # of "block" */
struct xfs_buf *bp; /* buffer for "block" */ struct xfs_buf *bp; /* buffer for "block" */
...@@ -538,7 +538,7 @@ xfs_bmap_btree_to_extents( ...@@ -538,7 +538,7 @@ xfs_bmap_btree_to_extents(
int *logflagsp, /* inode logging flags */ int *logflagsp, /* inode logging flags */
int whichfork) /* data or attr fork */ int whichfork) /* data or attr fork */
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_btree_block *rblock = ifp->if_broot; struct xfs_btree_block *rblock = ifp->if_broot;
struct xfs_btree_block *cblock;/* child btree block */ struct xfs_btree_block *cblock;/* child btree block */
...@@ -616,7 +616,7 @@ xfs_bmap_extents_to_btree( ...@@ -616,7 +616,7 @@ xfs_bmap_extents_to_btree(
mp = ip->i_mount; mp = ip->i_mount;
ASSERT(whichfork != XFS_COW_FORK); ASSERT(whichfork != XFS_COW_FORK);
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
ASSERT(ifp->if_format == XFS_DINODE_FMT_EXTENTS); ASSERT(ifp->if_format == XFS_DINODE_FMT_EXTENTS);
/* /*
...@@ -745,7 +745,7 @@ xfs_bmap_local_to_extents_empty( ...@@ -745,7 +745,7 @@ xfs_bmap_local_to_extents_empty(
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork) int whichfork)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
ASSERT(whichfork != XFS_COW_FORK); ASSERT(whichfork != XFS_COW_FORK);
ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
...@@ -785,7 +785,7 @@ xfs_bmap_local_to_extents( ...@@ -785,7 +785,7 @@ xfs_bmap_local_to_extents(
* So sending the data fork of a regular inode is invalid. * So sending the data fork of a regular inode is invalid.
*/ */
ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK)); ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK));
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
if (!ifp->if_bytes) { if (!ifp->if_bytes) {
...@@ -1116,7 +1116,7 @@ xfs_iread_bmbt_block( ...@@ -1116,7 +1116,7 @@ xfs_iread_bmbt_block(
xfs_extnum_t num_recs; xfs_extnum_t num_recs;
xfs_extnum_t j; xfs_extnum_t j;
int whichfork = cur->bc_ino.whichfork; int whichfork = cur->bc_ino.whichfork;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
block = xfs_btree_get_block(cur, level, &bp); block = xfs_btree_get_block(cur, level, &bp);
...@@ -1164,7 +1164,7 @@ xfs_iread_extents( ...@@ -1164,7 +1164,7 @@ xfs_iread_extents(
int whichfork) int whichfork)
{ {
struct xfs_iread_state ir; struct xfs_iread_state ir;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
int error; int error;
...@@ -1208,7 +1208,7 @@ xfs_bmap_first_unused( ...@@ -1208,7 +1208,7 @@ xfs_bmap_first_unused(
xfs_fileoff_t *first_unused, /* unused block */ xfs_fileoff_t *first_unused, /* unused block */
int whichfork) /* data or attr fork */ int whichfork) /* data or attr fork */
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
xfs_fileoff_t lastaddr = 0; xfs_fileoff_t lastaddr = 0;
...@@ -1255,7 +1255,7 @@ xfs_bmap_last_before( ...@@ -1255,7 +1255,7 @@ xfs_bmap_last_before(
xfs_fileoff_t *last_block, /* last block */ xfs_fileoff_t *last_block, /* last block */
int whichfork) /* data or attr fork */ int whichfork) /* data or attr fork */
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
int error; int error;
...@@ -1289,7 +1289,7 @@ xfs_bmap_last_extent( ...@@ -1289,7 +1289,7 @@ xfs_bmap_last_extent(
struct xfs_bmbt_irec *rec, struct xfs_bmbt_irec *rec,
int *is_empty) int *is_empty)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
int error; int error;
...@@ -1355,7 +1355,7 @@ xfs_bmap_last_offset( ...@@ -1355,7 +1355,7 @@ xfs_bmap_last_offset(
xfs_fileoff_t *last_block, xfs_fileoff_t *last_block,
int whichfork) int whichfork)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_bmbt_irec rec; struct xfs_bmbt_irec rec;
int is_empty; int is_empty;
int error; int error;
...@@ -1389,7 +1389,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1389,7 +1389,7 @@ xfs_bmap_add_extent_delay_real(
int whichfork) int whichfork)
{ {
struct xfs_mount *mp = bma->ip->i_mount; struct xfs_mount *mp = bma->ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
struct xfs_bmbt_irec *new = &bma->got; struct xfs_bmbt_irec *new = &bma->got;
int error; /* error return value */ int error; /* error return value */
int i; /* temp state */ int i; /* temp state */
...@@ -1955,7 +1955,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -1955,7 +1955,7 @@ xfs_bmap_add_extent_unwritten_real(
*logflagsp = 0; *logflagsp = 0;
cur = *curp; cur = *curp;
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
ASSERT(!isnullstartblock(new->br_startblock)); ASSERT(!isnullstartblock(new->br_startblock));
...@@ -2480,7 +2480,7 @@ xfs_bmap_add_extent_hole_delay( ...@@ -2480,7 +2480,7 @@ xfs_bmap_add_extent_hole_delay(
uint32_t state = xfs_bmap_fork_to_state(whichfork); uint32_t state = xfs_bmap_fork_to_state(whichfork);
xfs_filblks_t temp; /* temp for indirect calculations */ xfs_filblks_t temp; /* temp for indirect calculations */
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
ASSERT(isnullstartblock(new->br_startblock)); ASSERT(isnullstartblock(new->br_startblock));
/* /*
...@@ -2616,7 +2616,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2616,7 +2616,7 @@ xfs_bmap_add_extent_hole_real(
int *logflagsp, int *logflagsp,
uint32_t flags) uint32_t flags)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_btree_cur *cur = *curp; struct xfs_btree_cur *cur = *curp;
int error; /* error return value */ int error; /* error return value */
...@@ -3867,7 +3867,7 @@ xfs_bmapi_read( ...@@ -3867,7 +3867,7 @@ xfs_bmapi_read(
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
int whichfork = xfs_bmapi_whichfork(flags); int whichfork = xfs_bmapi_whichfork(flags);
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
xfs_fileoff_t obno; xfs_fileoff_t obno;
xfs_fileoff_t end; xfs_fileoff_t end;
...@@ -3960,7 +3960,7 @@ xfs_bmapi_reserve_delalloc( ...@@ -3960,7 +3960,7 @@ xfs_bmapi_reserve_delalloc(
int eof) int eof)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
xfs_extlen_t alen; xfs_extlen_t alen;
xfs_extlen_t indlen; xfs_extlen_t indlen;
int error; int error;
...@@ -4087,7 +4087,7 @@ xfs_bmapi_allocate( ...@@ -4087,7 +4087,7 @@ xfs_bmapi_allocate(
{ {
struct xfs_mount *mp = bma->ip->i_mount; struct xfs_mount *mp = bma->ip->i_mount;
int whichfork = xfs_bmapi_whichfork(bma->flags); int whichfork = xfs_bmapi_whichfork(bma->flags);
struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
int tmp_logflags = 0; int tmp_logflags = 0;
int error; int error;
...@@ -4186,7 +4186,7 @@ xfs_bmapi_convert_unwritten( ...@@ -4186,7 +4186,7 @@ xfs_bmapi_convert_unwritten(
uint32_t flags) uint32_t flags)
{ {
int whichfork = xfs_bmapi_whichfork(flags); int whichfork = xfs_bmapi_whichfork(flags);
struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
int tmp_logflags = 0; int tmp_logflags = 0;
int error; int error;
...@@ -4263,7 +4263,7 @@ xfs_bmapi_minleft( ...@@ -4263,7 +4263,7 @@ xfs_bmapi_minleft(
struct xfs_inode *ip, struct xfs_inode *ip,
int fork) int fork)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, fork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, fork);
if (tp && tp->t_firstblock != NULLFSBLOCK) if (tp && tp->t_firstblock != NULLFSBLOCK)
return 0; return 0;
...@@ -4284,7 +4284,7 @@ xfs_bmapi_finish( ...@@ -4284,7 +4284,7 @@ xfs_bmapi_finish(
int whichfork, int whichfork,
int error) int error)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
if ((bma->logflags & xfs_ilog_fext(whichfork)) && if ((bma->logflags & xfs_ilog_fext(whichfork)) &&
ifp->if_format != XFS_DINODE_FMT_EXTENTS) ifp->if_format != XFS_DINODE_FMT_EXTENTS)
...@@ -4323,7 +4323,7 @@ xfs_bmapi_write( ...@@ -4323,7 +4323,7 @@ xfs_bmapi_write(
}; };
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
int whichfork = xfs_bmapi_whichfork(flags); int whichfork = xfs_bmapi_whichfork(flags);
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
xfs_fileoff_t end; /* end of mapped file region */ xfs_fileoff_t end; /* end of mapped file region */
bool eof = false; /* after the end of extents */ bool eof = false; /* after the end of extents */
int error; /* error return */ int error; /* error return */
...@@ -4504,7 +4504,7 @@ xfs_bmapi_convert_delalloc( ...@@ -4504,7 +4504,7 @@ xfs_bmapi_convert_delalloc(
struct iomap *iomap, struct iomap *iomap,
unsigned int *seq) unsigned int *seq)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset);
struct xfs_bmalloca bma = { NULL }; struct xfs_bmalloca bma = { NULL };
...@@ -4641,7 +4641,7 @@ xfs_bmapi_remap( ...@@ -4641,7 +4641,7 @@ xfs_bmapi_remap(
int whichfork = xfs_bmapi_whichfork(flags); int whichfork = xfs_bmapi_whichfork(flags);
int logflags = 0, error; int logflags = 0, error;
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
ASSERT(len > 0); ASSERT(len > 0);
ASSERT(len <= (xfs_filblks_t)XFS_MAX_BMBT_EXTLEN); ASSERT(len <= (xfs_filblks_t)XFS_MAX_BMBT_EXTLEN);
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
...@@ -4798,7 +4798,7 @@ xfs_bmap_del_extent_delay( ...@@ -4798,7 +4798,7 @@ xfs_bmap_del_extent_delay(
struct xfs_bmbt_irec *del) struct xfs_bmbt_irec *del)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_bmbt_irec new; struct xfs_bmbt_irec new;
int64_t da_old, da_new, da_diff = 0; int64_t da_old, da_new, da_diff = 0;
xfs_fileoff_t del_endoff, got_endoff; xfs_fileoff_t del_endoff, got_endoff;
...@@ -4925,7 +4925,7 @@ xfs_bmap_del_extent_cow( ...@@ -4925,7 +4925,7 @@ xfs_bmap_del_extent_cow(
struct xfs_bmbt_irec *del) struct xfs_bmbt_irec *del)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_COW_FORK);
struct xfs_bmbt_irec new; struct xfs_bmbt_irec new;
xfs_fileoff_t del_endoff, got_endoff; xfs_fileoff_t del_endoff, got_endoff;
uint32_t state = BMAP_COWFORK; uint32_t state = BMAP_COWFORK;
...@@ -5023,7 +5023,7 @@ xfs_bmap_del_extent_real( ...@@ -5023,7 +5023,7 @@ xfs_bmap_del_extent_real(
mp = ip->i_mount; mp = ip->i_mount;
XFS_STATS_INC(mp, xs_del_exlist); XFS_STATS_INC(mp, xs_del_exlist);
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
ASSERT(del->br_blockcount > 0); ASSERT(del->br_blockcount > 0);
xfs_iext_get_extent(ifp, icur, &got); xfs_iext_get_extent(ifp, icur, &got);
ASSERT(got.br_startoff <= del->br_startoff); ASSERT(got.br_startoff <= del->br_startoff);
...@@ -5289,7 +5289,7 @@ __xfs_bunmapi( ...@@ -5289,7 +5289,7 @@ __xfs_bunmapi(
whichfork = xfs_bmapi_whichfork(flags); whichfork = xfs_bmapi_whichfork(flags);
ASSERT(whichfork != XFS_COW_FORK); ASSERT(whichfork != XFS_COW_FORK);
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp))) if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)))
return -EFSCORRUPTED; return -EFSCORRUPTED;
if (xfs_is_shutdown(mp)) if (xfs_is_shutdown(mp))
...@@ -5630,7 +5630,7 @@ xfs_bmse_merge( ...@@ -5630,7 +5630,7 @@ xfs_bmse_merge(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
int *logflags) /* output */ int *logflags) /* output */
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_bmbt_irec new; struct xfs_bmbt_irec new;
xfs_filblks_t blockcount; xfs_filblks_t blockcount;
int error, i; int error, i;
...@@ -5751,7 +5751,7 @@ xfs_bmap_collapse_extents( ...@@ -5751,7 +5751,7 @@ xfs_bmap_collapse_extents(
{ {
int whichfork = XFS_DATA_FORK; int whichfork = XFS_DATA_FORK;
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_btree_cur *cur = NULL; struct xfs_btree_cur *cur = NULL;
struct xfs_bmbt_irec got, prev; struct xfs_bmbt_irec got, prev;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
...@@ -5866,7 +5866,7 @@ xfs_bmap_insert_extents( ...@@ -5866,7 +5866,7 @@ xfs_bmap_insert_extents(
{ {
int whichfork = XFS_DATA_FORK; int whichfork = XFS_DATA_FORK;
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_btree_cur *cur = NULL; struct xfs_btree_cur *cur = NULL;
struct xfs_bmbt_irec got, next; struct xfs_bmbt_irec got, next;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
...@@ -5966,7 +5966,7 @@ xfs_bmap_split_extent( ...@@ -5966,7 +5966,7 @@ xfs_bmap_split_extent(
xfs_fileoff_t split_fsb) xfs_fileoff_t split_fsb)
{ {
int whichfork = XFS_DATA_FORK; int whichfork = XFS_DATA_FORK;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_btree_cur *cur = NULL; struct xfs_btree_cur *cur = NULL;
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_bmbt_irec new; /* split extent */ struct xfs_bmbt_irec new; /* split extent */
......
...@@ -304,7 +304,7 @@ xfs_bmbt_get_minrecs( ...@@ -304,7 +304,7 @@ xfs_bmbt_get_minrecs(
if (level == cur->bc_nlevels - 1) { if (level == cur->bc_nlevels - 1) {
struct xfs_ifork *ifp; struct xfs_ifork *ifp;
ifp = XFS_IFORK_PTR(cur->bc_ino.ip, ifp = xfs_ifork_ptr(cur->bc_ino.ip,
cur->bc_ino.whichfork); cur->bc_ino.whichfork);
return xfs_bmbt_maxrecs(cur->bc_mp, return xfs_bmbt_maxrecs(cur->bc_mp,
...@@ -322,7 +322,7 @@ xfs_bmbt_get_maxrecs( ...@@ -322,7 +322,7 @@ xfs_bmbt_get_maxrecs(
if (level == cur->bc_nlevels - 1) { if (level == cur->bc_nlevels - 1) {
struct xfs_ifork *ifp; struct xfs_ifork *ifp;
ifp = XFS_IFORK_PTR(cur->bc_ino.ip, ifp = xfs_ifork_ptr(cur->bc_ino.ip,
cur->bc_ino.whichfork); cur->bc_ino.whichfork);
return xfs_bmbt_maxrecs(cur->bc_mp, return xfs_bmbt_maxrecs(cur->bc_mp,
...@@ -550,7 +550,7 @@ xfs_bmbt_init_cursor( ...@@ -550,7 +550,7 @@ xfs_bmbt_init_cursor(
struct xfs_inode *ip, /* inode owning the btree */ struct xfs_inode *ip, /* inode owning the btree */
int whichfork) /* data or attr fork */ int whichfork) /* data or attr fork */
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
ASSERT(whichfork != XFS_COW_FORK); ASSERT(whichfork != XFS_COW_FORK);
...@@ -664,7 +664,7 @@ xfs_bmbt_change_owner( ...@@ -664,7 +664,7 @@ xfs_bmbt_change_owner(
ASSERT(tp || buffer_list); ASSERT(tp || buffer_list);
ASSERT(!(tp && buffer_list)); ASSERT(!(tp && buffer_list));
ASSERT(XFS_IFORK_PTR(ip, whichfork)->if_format == XFS_DINODE_FMT_BTREE); ASSERT(xfs_ifork_ptr(ip, whichfork)->if_format == XFS_DINODE_FMT_BTREE);
cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork); cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork);
cur->bc_ino.flags |= XFS_BTCUR_BMBT_INVALID_OWNER; cur->bc_ino.flags |= XFS_BTCUR_BMBT_INVALID_OWNER;
......
...@@ -722,7 +722,7 @@ xfs_btree_ifork_ptr( ...@@ -722,7 +722,7 @@ xfs_btree_ifork_ptr(
if (cur->bc_flags & XFS_BTREE_STAGING) if (cur->bc_flags & XFS_BTREE_STAGING)
return cur->bc_ino.ifake->if_fork; return cur->bc_ino.ifake->if_fork;
return XFS_IFORK_PTR(cur->bc_ino.ip, cur->bc_ino.whichfork); return xfs_ifork_ptr(cur->bc_ino.ip, cur->bc_ino.whichfork);
} }
/* /*
...@@ -3556,7 +3556,7 @@ xfs_btree_kill_iroot( ...@@ -3556,7 +3556,7 @@ xfs_btree_kill_iroot(
{ {
int whichfork = cur->bc_ino.whichfork; int whichfork = cur->bc_ino.whichfork;
struct xfs_inode *ip = cur->bc_ino.ip; struct xfs_inode *ip = cur->bc_ino.ip;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_btree_block *block; struct xfs_btree_block *block;
struct xfs_btree_block *cblock; struct xfs_btree_block *cblock;
union xfs_btree_key *kp; union xfs_btree_key *kp;
......
...@@ -1071,7 +1071,7 @@ xfs_dir2_sf_to_block( ...@@ -1071,7 +1071,7 @@ xfs_dir2_sf_to_block(
struct xfs_trans *tp = args->trans; struct xfs_trans *tp = args->trans;
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
struct xfs_mount *mp = dp->i_mount; struct xfs_mount *mp = dp->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(dp, XFS_DATA_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(dp, XFS_DATA_FORK);
struct xfs_da_geometry *geo = args->geo; struct xfs_da_geometry *geo = args->geo;
xfs_dir2_db_t blkno; /* dir-relative block # (0) */ xfs_dir2_db_t blkno; /* dir-relative block # (0) */
xfs_dir2_data_hdr_t *hdr; /* block header */ xfs_dir2_data_hdr_t *hdr; /* block header */
......
...@@ -710,7 +710,7 @@ xfs_dir2_sf_verify( ...@@ -710,7 +710,7 @@ xfs_dir2_sf_verify(
struct xfs_inode *ip) struct xfs_inode *ip)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
struct xfs_dir2_sf_hdr *sfp; struct xfs_dir2_sf_hdr *sfp;
struct xfs_dir2_sf_entry *sfep; struct xfs_dir2_sf_entry *sfep;
struct xfs_dir2_sf_entry *next_sfep; struct xfs_dir2_sf_entry *next_sfep;
......
...@@ -35,7 +35,7 @@ xfs_init_local_fork( ...@@ -35,7 +35,7 @@ xfs_init_local_fork(
const void *data, const void *data,
int64_t size) int64_t size)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
int mem_size = size; int mem_size = size;
bool zero_terminate; bool zero_terminate;
...@@ -102,7 +102,7 @@ xfs_iformat_extents( ...@@ -102,7 +102,7 @@ xfs_iformat_extents(
int whichfork) int whichfork)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
int state = xfs_bmap_fork_to_state(whichfork); int state = xfs_bmap_fork_to_state(whichfork);
xfs_extnum_t nex = xfs_dfork_nextents(dip, whichfork); xfs_extnum_t nex = xfs_dfork_nextents(dip, whichfork);
int size = nex * sizeof(xfs_bmbt_rec_t); int size = nex * sizeof(xfs_bmbt_rec_t);
...@@ -173,7 +173,7 @@ xfs_iformat_btree( ...@@ -173,7 +173,7 @@ xfs_iformat_btree(
int size; int size;
int level; int level;
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
dfp = (xfs_bmdr_block_t *)XFS_DFORK_PTR(dip, whichfork); dfp = (xfs_bmdr_block_t *)XFS_DFORK_PTR(dip, whichfork);
size = XFS_BMAP_BROOT_SPACE(mp, dfp); size = XFS_BMAP_BROOT_SPACE(mp, dfp);
nrecs = be16_to_cpu(dfp->bb_numrecs); nrecs = be16_to_cpu(dfp->bb_numrecs);
...@@ -370,7 +370,7 @@ xfs_iroot_realloc( ...@@ -370,7 +370,7 @@ xfs_iroot_realloc(
return; return;
} }
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
if (rec_diff > 0) { if (rec_diff > 0) {
/* /*
* If there wasn't any memory allocated before, just * If there wasn't any memory allocated before, just
...@@ -480,7 +480,7 @@ xfs_idata_realloc( ...@@ -480,7 +480,7 @@ xfs_idata_realloc(
int64_t byte_diff, int64_t byte_diff,
int whichfork) int whichfork)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
int64_t new_size = ifp->if_bytes + byte_diff; int64_t new_size = ifp->if_bytes + byte_diff;
ASSERT(new_size >= 0); ASSERT(new_size >= 0);
...@@ -539,7 +539,7 @@ xfs_iextents_copy( ...@@ -539,7 +539,7 @@ xfs_iextents_copy(
int whichfork) int whichfork)
{ {
int state = xfs_bmap_fork_to_state(whichfork); int state = xfs_bmap_fork_to_state(whichfork);
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
struct xfs_bmbt_irec rec; struct xfs_bmbt_irec rec;
int64_t copied = 0; int64_t copied = 0;
...@@ -591,7 +591,7 @@ xfs_iflush_fork( ...@@ -591,7 +591,7 @@ xfs_iflush_fork(
if (!iip) if (!iip)
return; return;
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
/* /*
* This can happen if we gave up in iformat in an error path, * This can happen if we gave up in iformat in an error path,
* for the attribute fork. * for the attribute fork.
...@@ -731,7 +731,7 @@ xfs_iext_count_may_overflow( ...@@ -731,7 +731,7 @@ xfs_iext_count_may_overflow(
int whichfork, int whichfork,
int nr_to_add) int nr_to_add)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
uint64_t max_exts; uint64_t max_exts;
uint64_t nr_exts; uint64_t nr_exts;
......
...@@ -81,12 +81,6 @@ struct xfs_ifork { ...@@ -81,12 +81,6 @@ struct xfs_ifork {
#define XFS_IFORK_Q(ip) ((ip)->i_forkoff != 0) #define XFS_IFORK_Q(ip) ((ip)->i_forkoff != 0)
#define XFS_IFORK_BOFF(ip) ((int)((ip)->i_forkoff << 3)) #define XFS_IFORK_BOFF(ip) ((int)((ip)->i_forkoff << 3))
#define XFS_IFORK_PTR(ip,w) \
((w) == XFS_DATA_FORK ? \
&(ip)->i_df : \
((w) == XFS_ATTR_FORK ? \
(ip)->i_afp : \
(ip)->i_cowfp))
#define XFS_IFORK_DSIZE(ip) \ #define XFS_IFORK_DSIZE(ip) \
(XFS_IFORK_Q(ip) ? XFS_IFORK_BOFF(ip) : XFS_LITINO((ip)->i_mount)) (XFS_IFORK_Q(ip) ? XFS_IFORK_BOFF(ip) : XFS_LITINO((ip)->i_mount))
#define XFS_IFORK_ASIZE(ip) \ #define XFS_IFORK_ASIZE(ip) \
......
...@@ -204,7 +204,7 @@ xfs_failaddr_t ...@@ -204,7 +204,7 @@ xfs_failaddr_t
xfs_symlink_shortform_verify( xfs_symlink_shortform_verify(
struct xfs_inode *ip) struct xfs_inode *ip)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
char *sfp = (char *)ifp->if_u1.if_data; char *sfp = (char *)ifp->if_u1.if_data;
int size = ifp->if_bytes; int size = ifp->if_bytes;
char *endp = sfp + size; char *endp = sfp + size;
......
...@@ -377,7 +377,7 @@ xchk_bmapbt_rec( ...@@ -377,7 +377,7 @@ xchk_bmapbt_rec(
struct xfs_inode *ip = bs->cur->bc_ino.ip; struct xfs_inode *ip = bs->cur->bc_ino.ip;
struct xfs_buf *bp = NULL; struct xfs_buf *bp = NULL;
struct xfs_btree_block *block; struct xfs_btree_block *block;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, info->whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, info->whichfork);
uint64_t owner; uint64_t owner;
int i; int i;
...@@ -426,7 +426,7 @@ xchk_bmap_btree( ...@@ -426,7 +426,7 @@ xchk_bmap_btree(
struct xchk_bmap_info *info) struct xchk_bmap_info *info)
{ {
struct xfs_owner_info oinfo; struct xfs_owner_info oinfo;
struct xfs_ifork *ifp = XFS_IFORK_PTR(sc->ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(sc->ip, whichfork);
struct xfs_mount *mp = sc->mp; struct xfs_mount *mp = sc->mp;
struct xfs_inode *ip = sc->ip; struct xfs_inode *ip = sc->ip;
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
...@@ -478,7 +478,7 @@ xchk_bmap_check_rmap( ...@@ -478,7 +478,7 @@ xchk_bmap_check_rmap(
return 0; return 0;
/* Now look up the bmbt record. */ /* Now look up the bmbt record. */
ifp = XFS_IFORK_PTR(sc->ip, sbcri->whichfork); ifp = xfs_ifork_ptr(sc->ip, sbcri->whichfork);
if (!ifp) { if (!ifp) {
xchk_fblock_set_corrupt(sc, sbcri->whichfork, xchk_fblock_set_corrupt(sc, sbcri->whichfork,
rec->rm_offset); rec->rm_offset);
...@@ -563,7 +563,7 @@ xchk_bmap_check_rmaps( ...@@ -563,7 +563,7 @@ xchk_bmap_check_rmaps(
struct xfs_scrub *sc, struct xfs_scrub *sc,
int whichfork) int whichfork)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(sc->ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(sc->ip, whichfork);
struct xfs_perag *pag; struct xfs_perag *pag;
xfs_agnumber_t agno; xfs_agnumber_t agno;
bool zero_size; bool zero_size;
...@@ -578,7 +578,7 @@ xchk_bmap_check_rmaps( ...@@ -578,7 +578,7 @@ xchk_bmap_check_rmaps(
if (XFS_IS_REALTIME_INODE(sc->ip) && whichfork == XFS_DATA_FORK) if (XFS_IS_REALTIME_INODE(sc->ip) && whichfork == XFS_DATA_FORK)
return 0; return 0;
ASSERT(XFS_IFORK_PTR(sc->ip, whichfork) != NULL); ASSERT(xfs_ifork_ptr(sc->ip, whichfork) != NULL);
/* /*
* Only do this for complex maps that are in btree format, or for * Only do this for complex maps that are in btree format, or for
...@@ -624,7 +624,7 @@ xchk_bmap( ...@@ -624,7 +624,7 @@ xchk_bmap(
struct xchk_bmap_info info = { NULL }; struct xchk_bmap_info info = { NULL };
struct xfs_mount *mp = sc->mp; struct xfs_mount *mp = sc->mp;
struct xfs_inode *ip = sc->ip; struct xfs_inode *ip = sc->ip;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
xfs_fileoff_t endoff; xfs_fileoff_t endoff;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
int error = 0; int error = 0;
...@@ -689,7 +689,7 @@ xchk_bmap( ...@@ -689,7 +689,7 @@ xchk_bmap(
/* Scrub extent records. */ /* Scrub extent records. */
info.lastoff = 0; info.lastoff = 0;
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
for_each_xfs_iext(ifp, &icur, &irec) { for_each_xfs_iext(ifp, &icur, &irec) {
if (xchk_should_terminate(sc, &error) || if (xchk_should_terminate(sc, &error) ||
(sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
......
...@@ -482,7 +482,7 @@ xchk_da_btree( ...@@ -482,7 +482,7 @@ xchk_da_btree(
int error; int error;
/* Skip short format data structures; no btree to scan. */ /* Skip short format data structures; no btree to scan. */
if (!xfs_ifork_has_extents(XFS_IFORK_PTR(sc->ip, whichfork))) if (!xfs_ifork_has_extents(xfs_ifork_ptr(sc->ip, whichfork)))
return 0; return 0;
/* Set up initial da state. */ /* Set up initial da state. */
......
...@@ -667,7 +667,7 @@ xchk_directory_blocks( ...@@ -667,7 +667,7 @@ xchk_directory_blocks(
{ {
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_da_args args; struct xfs_da_args args;
struct xfs_ifork *ifp = XFS_IFORK_PTR(sc->ip, XFS_DATA_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK);
struct xfs_mount *mp = sc->mp; struct xfs_mount *mp = sc->mp;
xfs_fileoff_t leaf_lblk; xfs_fileoff_t leaf_lblk;
xfs_fileoff_t free_lblk; xfs_fileoff_t free_lblk;
......
...@@ -185,7 +185,7 @@ xchk_quota_data_fork( ...@@ -185,7 +185,7 @@ xchk_quota_data_fork(
/* Check for data fork problems that apply only to quota files. */ /* Check for data fork problems that apply only to quota files. */
max_dqid_off = ((xfs_dqid_t)-1) / qi->qi_dqperchunk; max_dqid_off = ((xfs_dqid_t)-1) / qi->qi_dqperchunk;
ifp = XFS_IFORK_PTR(sc->ip, XFS_DATA_FORK); ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK);
for_each_xfs_iext(ifp, &icur, &irec) { for_each_xfs_iext(ifp, &icur, &irec) {
if (xchk_should_terminate(sc, &error)) if (xchk_should_terminate(sc, &error))
break; break;
......
...@@ -41,7 +41,7 @@ xchk_symlink( ...@@ -41,7 +41,7 @@ xchk_symlink(
if (!S_ISLNK(VFS_I(ip)->i_mode)) if (!S_ISLNK(VFS_I(ip)->i_mode))
return -ENOENT; return -ENOENT;
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
len = ip->i_disk_size; len = ip->i_disk_size;
/* Plausible size? */ /* Plausible size? */
......
...@@ -256,7 +256,7 @@ xfs_bmap_count_blocks( ...@@ -256,7 +256,7 @@ xfs_bmap_count_blocks(
xfs_filblks_t *count) xfs_filblks_t *count)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
xfs_extlen_t btblocks = 0; xfs_extlen_t btblocks = 0;
int error; int error;
...@@ -439,7 +439,7 @@ xfs_getbmap( ...@@ -439,7 +439,7 @@ xfs_getbmap(
whichfork = XFS_COW_FORK; whichfork = XFS_COW_FORK;
else else
whichfork = XFS_DATA_FORK; whichfork = XFS_DATA_FORK;
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = xfs_ifork_ptr(ip, whichfork);
xfs_ilock(ip, XFS_IOLOCK_SHARED); xfs_ilock(ip, XFS_IOLOCK_SHARED);
switch (whichfork) { switch (whichfork) {
......
...@@ -248,7 +248,7 @@ xfs_dir2_leaf_readbuf( ...@@ -248,7 +248,7 @@ xfs_dir2_leaf_readbuf(
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
struct xfs_buf *bp = NULL; struct xfs_buf *bp = NULL;
struct xfs_da_geometry *geo = args->geo; struct xfs_da_geometry *geo = args->geo;
struct xfs_ifork *ifp = XFS_IFORK_PTR(dp, XFS_DATA_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(dp, XFS_DATA_FORK);
struct xfs_bmbt_irec map; struct xfs_bmbt_irec map;
struct blk_plug plug; struct blk_plug plug;
xfs_dir2_off_t new_off; xfs_dir2_off_t new_off;
......
...@@ -1774,7 +1774,7 @@ xfs_check_delalloc( ...@@ -1774,7 +1774,7 @@ xfs_check_delalloc(
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork) int whichfork)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
......
...@@ -1293,8 +1293,8 @@ xfs_itruncate_clear_reflink_flags( ...@@ -1293,8 +1293,8 @@ xfs_itruncate_clear_reflink_flags(
if (!xfs_is_reflink_inode(ip)) if (!xfs_is_reflink_inode(ip))
return; return;
dfork = XFS_IFORK_PTR(ip, XFS_DATA_FORK); dfork = xfs_ifork_ptr(ip, XFS_DATA_FORK);
cfork = XFS_IFORK_PTR(ip, XFS_COW_FORK); cfork = xfs_ifork_ptr(ip, XFS_COW_FORK);
if (dfork->if_bytes == 0 && cfork->if_bytes == 0) if (dfork->if_bytes == 0 && cfork->if_bytes == 0)
ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
if (cfork->if_bytes == 0) if (cfork->if_bytes == 0)
...@@ -1643,7 +1643,7 @@ xfs_inode_needs_inactive( ...@@ -1643,7 +1643,7 @@ xfs_inode_needs_inactive(
struct xfs_inode *ip) struct xfs_inode *ip)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *cow_ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); struct xfs_ifork *cow_ifp = xfs_ifork_ptr(ip, XFS_COW_FORK);
/* /*
* If the inode is already free, then there can be nothing * If the inode is already free, then there can be nothing
......
...@@ -77,6 +77,24 @@ typedef struct xfs_inode { ...@@ -77,6 +77,24 @@ typedef struct xfs_inode {
struct list_head i_ioend_list; struct list_head i_ioend_list;
} xfs_inode_t; } xfs_inode_t;
static inline struct xfs_ifork *
xfs_ifork_ptr(
struct xfs_inode *ip,
int whichfork)
{
switch (whichfork) {
case XFS_DATA_FORK:
return &ip->i_df;
case XFS_ATTR_FORK:
return ip->i_afp;
case XFS_COW_FORK:
return ip->i_cowfp;
default:
ASSERT(0);
return NULL;
}
}
/* Convert from vfs inode to xfs inode */ /* Convert from vfs inode to xfs inode */
static inline struct xfs_inode *XFS_I(struct inode *inode) static inline struct xfs_inode *XFS_I(struct inode *inode)
{ {
......
...@@ -991,7 +991,7 @@ xfs_fill_fsxattr( ...@@ -991,7 +991,7 @@ xfs_fill_fsxattr(
struct fileattr *fa) struct fileattr *fa)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
fileattr_fill_xflags(fa, xfs_ip2xflags(ip)); fileattr_fill_xflags(fa, xfs_ip2xflags(ip));
......
...@@ -159,7 +159,7 @@ xfs_iomap_eof_align_last_fsb( ...@@ -159,7 +159,7 @@ xfs_iomap_eof_align_last_fsb(
struct xfs_inode *ip, struct xfs_inode *ip,
xfs_fileoff_t end_fsb) xfs_fileoff_t end_fsb)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
xfs_extlen_t extsz = xfs_get_extsz_hint(ip); xfs_extlen_t extsz = xfs_get_extsz_hint(ip);
xfs_extlen_t align = xfs_eof_alignment(ip); xfs_extlen_t align = xfs_eof_alignment(ip);
struct xfs_bmbt_irec irec; struct xfs_bmbt_irec irec;
...@@ -370,7 +370,7 @@ xfs_iomap_prealloc_size( ...@@ -370,7 +370,7 @@ xfs_iomap_prealloc_size(
struct xfs_iext_cursor ncur = *icur; struct xfs_iext_cursor ncur = *icur;
struct xfs_bmbt_irec prev, got; struct xfs_bmbt_irec prev, got;
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset);
int64_t freesp; int64_t freesp;
xfs_fsblock_t qblocks; xfs_fsblock_t qblocks;
......
...@@ -1154,7 +1154,7 @@ xfs_qm_dqusage_adjust( ...@@ -1154,7 +1154,7 @@ xfs_qm_dqusage_adjust(
ASSERT(ip->i_delayed_blks == 0); ASSERT(ip->i_delayed_blks == 0);
if (XFS_IS_REALTIME_INODE(ip)) { if (XFS_IS_REALTIME_INODE(ip)) {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK); error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
if (error) if (error)
......
...@@ -453,7 +453,7 @@ xfs_reflink_cancel_cow_blocks( ...@@ -453,7 +453,7 @@ xfs_reflink_cancel_cow_blocks(
xfs_fileoff_t end_fsb, xfs_fileoff_t end_fsb,
bool cancel_real) bool cancel_real)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_COW_FORK);
struct xfs_bmbt_irec got, del; struct xfs_bmbt_irec got, del;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
int error = 0; int error = 0;
...@@ -594,7 +594,7 @@ xfs_reflink_end_cow_extent( ...@@ -594,7 +594,7 @@ xfs_reflink_end_cow_extent(
struct xfs_bmbt_irec got, del, data; struct xfs_bmbt_irec got, del, data;
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_COW_FORK);
unsigned int resblks; unsigned int resblks;
int nmaps; int nmaps;
int error; int error;
...@@ -1425,7 +1425,7 @@ xfs_reflink_inode_has_shared_extents( ...@@ -1425,7 +1425,7 @@ xfs_reflink_inode_has_shared_extents(
bool found; bool found;
int error; int error;
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK); error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
if (error) if (error)
return error; return error;
......
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