Commit 8096b1eb authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Ben Myers

xfs: remove the if_ext_max field in struct xfs_ifork

We spent a lot of effort to maintain this field, but it always equals to the
fork size divided by the constant size of an extent.  The prime use of it is
to assert that the two stay in sync.  Just divide the fork size by the extent
size in the few places that we actually use it and remove the overhead
of maintaining it.  Also introduce a few helpers to consolidate the places
where we actually care about the value.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 3d2b3129
...@@ -271,10 +271,6 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) ...@@ -271,10 +271,6 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
dp = args->dp; dp = args->dp;
mp = dp->i_mount; mp = dp->i_mount;
dp->i_d.di_forkoff = forkoff; dp->i_d.di_forkoff = forkoff;
dp->i_df.if_ext_max =
XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
dp->i_afp->if_ext_max =
XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
ifp = dp->i_afp; ifp = dp->i_afp;
ASSERT(ifp->if_flags & XFS_IFINLINE); ASSERT(ifp->if_flags & XFS_IFINLINE);
...@@ -326,7 +322,6 @@ xfs_attr_fork_reset( ...@@ -326,7 +322,6 @@ xfs_attr_fork_reset(
ASSERT(ip->i_d.di_anextents == 0); ASSERT(ip->i_d.di_anextents == 0);
ASSERT(ip->i_afp == NULL); ASSERT(ip->i_afp == NULL);
ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t);
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
} }
...@@ -389,10 +384,6 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) ...@@ -389,10 +384,6 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
(args->op_flags & XFS_DA_OP_ADDNAME) || (args->op_flags & XFS_DA_OP_ADDNAME) ||
!(mp->m_flags & XFS_MOUNT_ATTR2) || !(mp->m_flags & XFS_MOUNT_ATTR2) ||
dp->i_d.di_format == XFS_DINODE_FMT_BTREE); dp->i_d.di_format == XFS_DINODE_FMT_BTREE);
dp->i_afp->if_ext_max =
XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
dp->i_df.if_ext_max =
XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
xfs_trans_log_inode(args->trans, dp, xfs_trans_log_inode(args->trans, dp,
XFS_ILOG_CORE | XFS_ILOG_ADATA); XFS_ILOG_CORE | XFS_ILOG_ADATA);
} }
......
...@@ -249,7 +249,27 @@ xfs_bmbt_lookup_ge( ...@@ -249,7 +249,27 @@ xfs_bmbt_lookup_ge(
} }
/* /*
* Update the record referred to by cur to the value given * Check if the inode needs to be converted to btree format.
*/
static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork)
{
return XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS &&
XFS_IFORK_NEXTENTS(ip, whichfork) >
XFS_IFORK_MAXEXT(ip, whichfork);
}
/*
* Check if the inode should be converted to extent format.
*/
static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork)
{
return XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE &&
XFS_IFORK_NEXTENTS(ip, whichfork) <=
XFS_IFORK_MAXEXT(ip, whichfork);
}
/*
* Update the record referred to by cur to the value given
* by [off, bno, len, state]. * by [off, bno, len, state].
* This either works (return 0) or gets an EFSCORRUPTED error. * This either works (return 0) or gets an EFSCORRUPTED error.
*/ */
...@@ -683,8 +703,8 @@ xfs_bmap_add_extent_delay_real( ...@@ -683,8 +703,8 @@ xfs_bmap_add_extent_delay_real(
goto done; goto done;
XFS_WANT_CORRUPTED_GOTO(i == 1, done); XFS_WANT_CORRUPTED_GOTO(i == 1, done);
} }
if (bma->ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
bma->ip->i_d.di_nextents > bma->ip->i_df.if_ext_max) { if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
bma->firstblock, bma->flist, bma->firstblock, bma->flist,
&bma->cur, 1, &tmp_rval, XFS_DATA_FORK); &bma->cur, 1, &tmp_rval, XFS_DATA_FORK);
...@@ -767,8 +787,8 @@ xfs_bmap_add_extent_delay_real( ...@@ -767,8 +787,8 @@ xfs_bmap_add_extent_delay_real(
goto done; goto done;
XFS_WANT_CORRUPTED_GOTO(i == 1, done); XFS_WANT_CORRUPTED_GOTO(i == 1, done);
} }
if (bma->ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
bma->ip->i_d.di_nextents > bma->ip->i_df.if_ext_max) { if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
bma->firstblock, bma->flist, &bma->cur, 1, bma->firstblock, bma->flist, &bma->cur, 1,
&tmp_rval, XFS_DATA_FORK); &tmp_rval, XFS_DATA_FORK);
...@@ -836,8 +856,8 @@ xfs_bmap_add_extent_delay_real( ...@@ -836,8 +856,8 @@ xfs_bmap_add_extent_delay_real(
goto done; goto done;
XFS_WANT_CORRUPTED_GOTO(i == 1, done); XFS_WANT_CORRUPTED_GOTO(i == 1, done);
} }
if (bma->ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
bma->ip->i_d.di_nextents > bma->ip->i_df.if_ext_max) { if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
bma->firstblock, bma->flist, &bma->cur, bma->firstblock, bma->flist, &bma->cur,
1, &tmp_rval, XFS_DATA_FORK); 1, &tmp_rval, XFS_DATA_FORK);
...@@ -884,8 +904,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -884,8 +904,7 @@ xfs_bmap_add_extent_delay_real(
} }
/* convert to a btree if necessary */ /* convert to a btree if necessary */
if (XFS_IFORK_FORMAT(bma->ip, XFS_DATA_FORK) == XFS_DINODE_FMT_EXTENTS && if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
XFS_IFORK_NEXTENTS(bma->ip, XFS_DATA_FORK) > ifp->if_ext_max) {
int tmp_logflags; /* partial log flag return val */ int tmp_logflags; /* partial log flag return val */
ASSERT(bma->cur == NULL); ASSERT(bma->cur == NULL);
...@@ -1421,8 +1440,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -1421,8 +1440,7 @@ xfs_bmap_add_extent_unwritten_real(
} }
/* convert to a btree if necessary */ /* convert to a btree if necessary */
if (XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) == XFS_DINODE_FMT_EXTENTS && if (xfs_bmap_needs_btree(ip, XFS_DATA_FORK)) {
XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > ifp->if_ext_max) {
int tmp_logflags; /* partial log flag return val */ int tmp_logflags; /* partial log flag return val */
ASSERT(cur == NULL); ASSERT(cur == NULL);
...@@ -1812,8 +1830,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -1812,8 +1830,7 @@ xfs_bmap_add_extent_hole_real(
} }
/* convert to a btree if necessary */ /* convert to a btree if necessary */
if (XFS_IFORK_FORMAT(bma->ip, whichfork) == XFS_DINODE_FMT_EXTENTS && if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
XFS_IFORK_NEXTENTS(bma->ip, whichfork) > ifp->if_ext_max) {
int tmp_logflags; /* partial log flag return val */ int tmp_logflags; /* partial log flag return val */
ASSERT(bma->cur == NULL); ASSERT(bma->cur == NULL);
...@@ -3037,8 +3054,7 @@ xfs_bmap_extents_to_btree( ...@@ -3037,8 +3054,7 @@ xfs_bmap_extents_to_btree(
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS); ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS);
ASSERT(ifp->if_ext_max ==
XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
/* /*
* Make space in the inode incore. * Make space in the inode incore.
*/ */
...@@ -3184,13 +3200,8 @@ xfs_bmap_forkoff_reset( ...@@ -3184,13 +3200,8 @@ xfs_bmap_forkoff_reset(
ip->i_d.di_format != XFS_DINODE_FMT_BTREE) { ip->i_d.di_format != XFS_DINODE_FMT_BTREE) {
uint dfl_forkoff = xfs_default_attroffset(ip) >> 3; uint dfl_forkoff = xfs_default_attroffset(ip) >> 3;
if (dfl_forkoff > ip->i_d.di_forkoff) { if (dfl_forkoff > ip->i_d.di_forkoff)
ip->i_d.di_forkoff = dfl_forkoff; ip->i_d.di_forkoff = dfl_forkoff;
ip->i_df.if_ext_max =
XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t);
ip->i_afp->if_ext_max =
XFS_IFORK_ASIZE(ip) / sizeof(xfs_bmbt_rec_t);
}
} }
} }
...@@ -3430,8 +3441,6 @@ xfs_bmap_add_attrfork( ...@@ -3430,8 +3441,6 @@ xfs_bmap_add_attrfork(
int error; /* error return value */ int error; /* error return value */
ASSERT(XFS_IFORK_Q(ip) == 0); ASSERT(XFS_IFORK_Q(ip) == 0);
ASSERT(ip->i_df.if_ext_max ==
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));
mp = ip->i_mount; mp = ip->i_mount;
ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); ASSERT(!XFS_NOT_DQATTACHED(mp, ip));
...@@ -3486,12 +3495,9 @@ xfs_bmap_add_attrfork( ...@@ -3486,12 +3495,9 @@ xfs_bmap_add_attrfork(
error = XFS_ERROR(EINVAL); error = XFS_ERROR(EINVAL);
goto error1; goto error1;
} }
ip->i_df.if_ext_max =
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
ASSERT(ip->i_afp == NULL); ASSERT(ip->i_afp == NULL);
ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP); ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP);
ip->i_afp->if_ext_max =
XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
ip->i_afp->if_flags = XFS_IFEXTENTS; ip->i_afp->if_flags = XFS_IFEXTENTS;
logflags = 0; logflags = 0;
xfs_bmap_init(&flist, &firstblock); xfs_bmap_init(&flist, &firstblock);
...@@ -3535,20 +3541,17 @@ xfs_bmap_add_attrfork( ...@@ -3535,20 +3541,17 @@ xfs_bmap_add_attrfork(
} else } else
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
} }
if ((error = xfs_bmap_finish(&tp, &flist, &committed)))
error = xfs_bmap_finish(&tp, &flist, &committed);
if (error)
goto error2; goto error2;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
ASSERT(ip->i_df.if_ext_max ==
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));
return error;
error2: error2:
xfs_bmap_cancel(&flist); xfs_bmap_cancel(&flist);
error1: error1:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
error0: error0:
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
ASSERT(ip->i_df.if_ext_max ==
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));
return error; return error;
} }
...@@ -4379,8 +4382,6 @@ xfs_bmapi_read( ...@@ -4379,8 +4382,6 @@ xfs_bmapi_read(
XFS_STATS_INC(xs_blk_mapr); XFS_STATS_INC(xs_blk_mapr);
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(ifp->if_ext_max ==
XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
if (!(ifp->if_flags & XFS_IFEXTENTS)) { if (!(ifp->if_flags & XFS_IFEXTENTS)) {
error = xfs_iread_extents(NULL, ip, whichfork); error = xfs_iread_extents(NULL, ip, whichfork);
...@@ -4871,8 +4872,6 @@ xfs_bmapi_write( ...@@ -4871,8 +4872,6 @@ xfs_bmapi_write(
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(ifp->if_ext_max ==
XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
XFS_STATS_INC(xs_blk_mapw); XFS_STATS_INC(xs_blk_mapw);
...@@ -4981,8 +4980,7 @@ xfs_bmapi_write( ...@@ -4981,8 +4980,7 @@ xfs_bmapi_write(
/* /*
* Transform from btree to extents, give it cur. * Transform from btree to extents, give it cur.
*/ */
if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE && if (xfs_bmap_wants_extents(ip, whichfork)) {
XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max) {
int tmp_logflags = 0; int tmp_logflags = 0;
ASSERT(bma.cur); ASSERT(bma.cur);
...@@ -4992,10 +4990,10 @@ xfs_bmapi_write( ...@@ -4992,10 +4990,10 @@ xfs_bmapi_write(
if (error) if (error)
goto error0; goto error0;
} }
ASSERT(ifp->if_ext_max ==
XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE || ASSERT(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE ||
XFS_IFORK_NEXTENTS(ip, whichfork) > ifp->if_ext_max); XFS_IFORK_NEXTENTS(ip, whichfork) >
XFS_IFORK_MAXEXT(ip, whichfork));
error = 0; error = 0;
error0: error0:
/* /*
...@@ -5095,8 +5093,7 @@ xfs_bunmapi( ...@@ -5095,8 +5093,7 @@ xfs_bunmapi(
ASSERT(len > 0); ASSERT(len > 0);
ASSERT(nexts >= 0); ASSERT(nexts >= 0);
ASSERT(ifp->if_ext_max ==
XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
if (!(ifp->if_flags & XFS_IFEXTENTS) && if (!(ifp->if_flags & XFS_IFEXTENTS) &&
(error = xfs_iread_extents(tp, ip, whichfork))) (error = xfs_iread_extents(tp, ip, whichfork)))
return error; return error;
...@@ -5322,7 +5319,8 @@ xfs_bunmapi( ...@@ -5322,7 +5319,8 @@ xfs_bunmapi(
*/ */
if (!wasdel && xfs_trans_get_block_res(tp) == 0 && if (!wasdel && xfs_trans_get_block_res(tp) == 0 &&
XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS && XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS &&
XFS_IFORK_NEXTENTS(ip, whichfork) >= ifp->if_ext_max && XFS_IFORK_NEXTENTS(ip, whichfork) >= /* Note the >= */
XFS_IFORK_MAXEXT(ip, whichfork) &&
del.br_startoff > got.br_startoff && del.br_startoff > got.br_startoff &&
del.br_startoff + del.br_blockcount < del.br_startoff + del.br_blockcount <
got.br_startoff + got.br_blockcount) { got.br_startoff + got.br_blockcount) {
...@@ -5353,13 +5351,11 @@ xfs_bunmapi( ...@@ -5353,13 +5351,11 @@ xfs_bunmapi(
} }
} }
*done = bno == (xfs_fileoff_t)-1 || bno < start || lastx < 0; *done = bno == (xfs_fileoff_t)-1 || bno < start || lastx < 0;
ASSERT(ifp->if_ext_max ==
XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
/* /*
* Convert to a btree if necessary. * Convert to a btree if necessary.
*/ */
if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS && if (xfs_bmap_needs_btree(ip, whichfork)) {
XFS_IFORK_NEXTENTS(ip, whichfork) > ifp->if_ext_max) {
ASSERT(cur == NULL); ASSERT(cur == NULL);
error = xfs_bmap_extents_to_btree(tp, ip, firstblock, flist, error = xfs_bmap_extents_to_btree(tp, ip, firstblock, flist,
&cur, 0, &tmp_logflags, whichfork); &cur, 0, &tmp_logflags, whichfork);
...@@ -5370,8 +5366,7 @@ xfs_bunmapi( ...@@ -5370,8 +5366,7 @@ xfs_bunmapi(
/* /*
* transform from btree to extents, give it cur * transform from btree to extents, give it cur
*/ */
else if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE && else if (xfs_bmap_wants_extents(ip, whichfork)) {
XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max) {
ASSERT(cur != NULL); ASSERT(cur != NULL);
error = xfs_bmap_btree_to_extents(tp, ip, cur, &tmp_logflags, error = xfs_bmap_btree_to_extents(tp, ip, cur, &tmp_logflags,
whichfork); whichfork);
...@@ -5382,8 +5377,6 @@ xfs_bunmapi( ...@@ -5382,8 +5377,6 @@ xfs_bunmapi(
/* /*
* transform from extents to local? * transform from extents to local?
*/ */
ASSERT(ifp->if_ext_max ==
XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
error = 0; error = 0;
error0: error0:
/* /*
......
...@@ -163,12 +163,14 @@ xfs_swap_extents_check_format( ...@@ -163,12 +163,14 @@ xfs_swap_extents_check_format(
/* Check temp in extent form to max in target */ /* Check temp in extent form to max in target */
if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) > ip->i_df.if_ext_max) XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) >
XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
return EINVAL; return EINVAL;
/* Check target in extent form to max in temp */ /* Check target in extent form to max in temp */
if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > tip->i_df.if_ext_max) XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) >
XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
return EINVAL; return EINVAL;
/* /*
...@@ -180,18 +182,25 @@ xfs_swap_extents_check_format( ...@@ -180,18 +182,25 @@ xfs_swap_extents_check_format(
* (a common defrag case) which will occur when the temp inode is in * (a common defrag case) which will occur when the temp inode is in
* extent format... * extent format...
*/ */
if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE && if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
((XFS_IFORK_BOFF(ip) && if (XFS_IFORK_BOFF(ip) &&
tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip)) || tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip))
XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= ip->i_df.if_ext_max)) return EINVAL;
return EINVAL; if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
return EINVAL;
}
/* Reciprocal target->temp btree format checks */ /* Reciprocal target->temp btree format checks */
if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE && if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
((XFS_IFORK_BOFF(tip) && if (XFS_IFORK_BOFF(tip) &&
ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip)) || ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip))
XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= tip->i_df.if_ext_max)) return EINVAL;
return EINVAL;
if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
return EINVAL;
}
return 0; return 0;
} }
...@@ -348,16 +357,6 @@ xfs_swap_extents( ...@@ -348,16 +357,6 @@ xfs_swap_extents(
*ifp = *tifp; /* struct copy */ *ifp = *tifp; /* struct copy */
*tifp = *tempifp; /* struct copy */ *tifp = *tempifp; /* struct copy */
/*
* Fix the in-memory data fork values that are dependent on the fork
* offset in the inode. We can't assume they remain the same as attr2
* has dynamic fork offsets.
*/
ifp->if_ext_max = XFS_IFORK_SIZE(ip, XFS_DATA_FORK) /
(uint)sizeof(xfs_bmbt_rec_t);
tifp->if_ext_max = XFS_IFORK_SIZE(tip, XFS_DATA_FORK) /
(uint)sizeof(xfs_bmbt_rec_t);
/* /*
* Fix the on-disk inode values * Fix the on-disk inode values
*/ */
......
...@@ -450,8 +450,6 @@ xfs_iget( ...@@ -450,8 +450,6 @@ xfs_iget(
*ipp = ip; *ipp = ip;
ASSERT(ip->i_df.if_ext_max ==
XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t));
/* /*
* If we have a real type for an on-disk inode, we can set ops(&unlock) * If we have a real type for an on-disk inode, we can set ops(&unlock)
* now. If it's a new inode being created, xfs_ialloc will handle it. * now. If it's a new inode being created, xfs_ialloc will handle it.
......
...@@ -299,11 +299,8 @@ xfs_iformat( ...@@ -299,11 +299,8 @@ xfs_iformat(
{ {
xfs_attr_shortform_t *atp; xfs_attr_shortform_t *atp;
int size; int size;
int error; int error = 0;
xfs_fsize_t di_size; xfs_fsize_t di_size;
ip->i_df.if_ext_max =
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
error = 0;
if (unlikely(be32_to_cpu(dip->di_nextents) + if (unlikely(be32_to_cpu(dip->di_nextents) +
be16_to_cpu(dip->di_anextents) > be16_to_cpu(dip->di_anextents) >
...@@ -409,10 +406,10 @@ xfs_iformat( ...@@ -409,10 +406,10 @@ xfs_iformat(
} }
if (!XFS_DFORK_Q(dip)) if (!XFS_DFORK_Q(dip))
return 0; return 0;
ASSERT(ip->i_afp == NULL); ASSERT(ip->i_afp == NULL);
ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP | KM_NOFS); ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP | KM_NOFS);
ip->i_afp->if_ext_max =
XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
switch (dip->di_aformat) { switch (dip->di_aformat) {
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip);
...@@ -604,10 +601,11 @@ xfs_iformat_btree( ...@@ -604,10 +601,11 @@ xfs_iformat_btree(
* or the number of extents is greater than the number of * or the number of extents is greater than the number of
* blocks. * blocks.
*/ */
if (unlikely(XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max if (unlikely(XFS_IFORK_NEXTENTS(ip, whichfork) <=
|| XFS_BMDR_SPACE_CALC(nrecs) > XFS_IFORK_MAXEXT(ip, whichfork) ||
XFS_DFORK_SIZE(dip, ip->i_mount, whichfork) XFS_BMDR_SPACE_CALC(nrecs) >
|| XFS_IFORK_NEXTENTS(ip, whichfork) > ip->i_d.di_nblocks)) { XFS_DFORK_SIZE(dip, ip->i_mount, whichfork) ||
XFS_IFORK_NEXTENTS(ip, whichfork) > ip->i_d.di_nblocks)) {
xfs_warn(ip->i_mount, "corrupt inode %Lu (btree).", xfs_warn(ip->i_mount, "corrupt inode %Lu (btree).",
(unsigned long long) ip->i_ino); (unsigned long long) ip->i_ino);
XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW,
...@@ -835,12 +833,6 @@ xfs_iread( ...@@ -835,12 +833,6 @@ xfs_iread(
* with the uninitialized part of it. * with the uninitialized part of it.
*/ */
ip->i_d.di_mode = 0; ip->i_d.di_mode = 0;
/*
* Initialize the per-fork minima and maxima for a new
* inode here. xfs_iformat will do it for old inodes.
*/
ip->i_df.if_ext_max =
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
} }
/* /*
...@@ -1740,8 +1732,6 @@ xfs_ifree( ...@@ -1740,8 +1732,6 @@ xfs_ifree(
ip->i_d.di_flags = 0; ip->i_d.di_flags = 0;
ip->i_d.di_dmevmask = 0; ip->i_d.di_dmevmask = 0;
ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */ ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
ip->i_df.if_ext_max =
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS; ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS; ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
/* /*
...@@ -2408,7 +2398,7 @@ xfs_iflush( ...@@ -2408,7 +2398,7 @@ xfs_iflush(
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
ASSERT(!completion_done(&ip->i_flush)); ASSERT(!completion_done(&ip->i_flush));
ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
ip->i_d.di_nextents > ip->i_df.if_ext_max); ip->i_d.di_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK));
iip = ip->i_itemp; iip = ip->i_itemp;
mp = ip->i_mount; mp = ip->i_mount;
...@@ -2524,7 +2514,7 @@ xfs_iflush_int( ...@@ -2524,7 +2514,7 @@ xfs_iflush_int(
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
ASSERT(!completion_done(&ip->i_flush)); ASSERT(!completion_done(&ip->i_flush));
ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
ip->i_d.di_nextents > ip->i_df.if_ext_max); ip->i_d.di_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK));
iip = ip->i_itemp; iip = ip->i_itemp;
mp = ip->i_mount; mp = ip->i_mount;
......
...@@ -66,7 +66,6 @@ typedef struct xfs_ifork { ...@@ -66,7 +66,6 @@ typedef struct xfs_ifork {
struct xfs_btree_block *if_broot; /* file's incore btree root */ struct xfs_btree_block *if_broot; /* file's incore btree root */
short if_broot_bytes; /* bytes allocated for root */ short if_broot_bytes; /* bytes allocated for root */
unsigned char if_flags; /* per-fork flags */ unsigned char if_flags; /* per-fork flags */
unsigned char if_ext_max; /* max # of extent records */
union { union {
xfs_bmbt_rec_host_t *if_extents;/* linear map file exts */ xfs_bmbt_rec_host_t *if_extents;/* linear map file exts */
xfs_ext_irec_t *if_ext_irec; /* irec map file exts */ xfs_ext_irec_t *if_ext_irec; /* irec map file exts */
...@@ -206,7 +205,8 @@ typedef struct xfs_icdinode { ...@@ -206,7 +205,8 @@ typedef struct xfs_icdinode {
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
((ip)->i_d.di_nextents = (n)) : \ ((ip)->i_d.di_nextents = (n)) : \
((ip)->i_d.di_anextents = (n))) ((ip)->i_d.di_anextents = (n)))
#define XFS_IFORK_MAXEXT(ip, w) \
(XFS_IFORK_SIZE(ip, w) / sizeof(xfs_bmbt_rec_t))
#ifdef __KERNEL__ #ifdef __KERNEL__
......
...@@ -79,8 +79,6 @@ xfs_inode_item_size( ...@@ -79,8 +79,6 @@ xfs_inode_item_size(
break; break;
case XFS_DINODE_FMT_BTREE: case XFS_DINODE_FMT_BTREE:
ASSERT(ip->i_df.if_ext_max ==
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));
iip->ili_format.ilf_fields &= iip->ili_format.ilf_fields &=
~(XFS_ILOG_DDATA | XFS_ILOG_DEXT | ~(XFS_ILOG_DDATA | XFS_ILOG_DEXT |
XFS_ILOG_DEV | XFS_ILOG_UUID); XFS_ILOG_DEV | XFS_ILOG_UUID);
......
...@@ -1568,7 +1568,6 @@ DECLARE_EVENT_CLASS(xfs_swap_extent_class, ...@@ -1568,7 +1568,6 @@ DECLARE_EVENT_CLASS(xfs_swap_extent_class,
__field(xfs_ino_t, ino) __field(xfs_ino_t, ino)
__field(int, format) __field(int, format)
__field(int, nex) __field(int, nex)
__field(int, max_nex)
__field(int, broot_size) __field(int, broot_size)
__field(int, fork_off) __field(int, fork_off)
), ),
...@@ -1578,18 +1577,16 @@ DECLARE_EVENT_CLASS(xfs_swap_extent_class, ...@@ -1578,18 +1577,16 @@ DECLARE_EVENT_CLASS(xfs_swap_extent_class,
__entry->ino = ip->i_ino; __entry->ino = ip->i_ino;
__entry->format = ip->i_d.di_format; __entry->format = ip->i_d.di_format;
__entry->nex = ip->i_d.di_nextents; __entry->nex = ip->i_d.di_nextents;
__entry->max_nex = ip->i_df.if_ext_max;
__entry->broot_size = ip->i_df.if_broot_bytes; __entry->broot_size = ip->i_df.if_broot_bytes;
__entry->fork_off = XFS_IFORK_BOFF(ip); __entry->fork_off = XFS_IFORK_BOFF(ip);
), ),
TP_printk("dev %d:%d ino 0x%llx (%s), %s format, num_extents %d, " TP_printk("dev %d:%d ino 0x%llx (%s), %s format, num_extents %d, "
"Max in-fork extents %d, broot size %d, fork offset %d", "broot size %d, fork offset %d",
MAJOR(__entry->dev), MINOR(__entry->dev), MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->ino, __entry->ino,
__print_symbolic(__entry->which, XFS_SWAPEXT_INODES), __print_symbolic(__entry->which, XFS_SWAPEXT_INODES),
__print_symbolic(__entry->format, XFS_INODE_FORMAT_STR), __print_symbolic(__entry->format, XFS_INODE_FORMAT_STR),
__entry->nex, __entry->nex,
__entry->max_nex,
__entry->broot_size, __entry->broot_size,
__entry->fork_off) __entry->fork_off)
) )
......
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