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;
......
This diff is collapsed.
...@@ -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