mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 22:21:21 +00:00
xfs: provide helper for counting extents from if_bytes
The open-coded pattern: ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t) is all over the xfs code; provide a new helper xfs_iext_count(ifp) to count the number of inline extents in an inode fork. [dchinner: pick up several missed conversions] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
parent
4dfce57db6
commit
5d829300be
8 changed files with 64 additions and 67 deletions
|
@ -515,7 +515,7 @@ xfs_bmap_trace_exlist(
|
||||||
state |= BMAP_ATTRFORK;
|
state |= BMAP_ATTRFORK;
|
||||||
|
|
||||||
ifp = XFS_IFORK_PTR(ip, whichfork);
|
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||||
ASSERT(cnt == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)));
|
ASSERT(cnt == xfs_iext_count(ifp));
|
||||||
for (idx = 0; idx < cnt; idx++)
|
for (idx = 0; idx < cnt; idx++)
|
||||||
trace_xfs_extlist(ip, idx, whichfork, caller_ip);
|
trace_xfs_extlist(ip, idx, whichfork, caller_ip);
|
||||||
}
|
}
|
||||||
|
@ -811,7 +811,7 @@ try_another_ag:
|
||||||
XFS_BTREE_LONG_PTRS);
|
XFS_BTREE_LONG_PTRS);
|
||||||
|
|
||||||
arp = XFS_BMBT_REC_ADDR(mp, ablock, 1);
|
arp = XFS_BMBT_REC_ADDR(mp, ablock, 1);
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
for (cnt = i = 0; i < nextents; i++) {
|
for (cnt = i = 0; i < nextents; i++) {
|
||||||
ep = xfs_iext_get_ext(ifp, i);
|
ep = xfs_iext_get_ext(ifp, i);
|
||||||
if (!isnullstartblock(xfs_bmbt_get_startblock(ep))) {
|
if (!isnullstartblock(xfs_bmbt_get_startblock(ep))) {
|
||||||
|
@ -1296,7 +1296,7 @@ xfs_bmap_read_extents(
|
||||||
/*
|
/*
|
||||||
* Here with bp and block set to the leftmost leaf node in the tree.
|
* Here with bp and block set to the leftmost leaf node in the tree.
|
||||||
*/
|
*/
|
||||||
room = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
room = xfs_iext_count(ifp);
|
||||||
i = 0;
|
i = 0;
|
||||||
/*
|
/*
|
||||||
* Loop over all leaf nodes. Copy information to the extent records.
|
* Loop over all leaf nodes. Copy information to the extent records.
|
||||||
|
@ -1361,7 +1361,7 @@ xfs_bmap_read_extents(
|
||||||
return error;
|
return error;
|
||||||
block = XFS_BUF_TO_BLOCK(bp);
|
block = XFS_BUF_TO_BLOCK(bp);
|
||||||
}
|
}
|
||||||
ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)));
|
ASSERT(i == xfs_iext_count(ifp));
|
||||||
ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork));
|
ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork));
|
||||||
XFS_BMAP_TRACE_EXLIST(ip, i, whichfork);
|
XFS_BMAP_TRACE_EXLIST(ip, i, whichfork);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1404,7 +1404,7 @@ xfs_bmap_search_multi_extents(
|
||||||
if (lastx > 0) {
|
if (lastx > 0) {
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx - 1), prevp);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx - 1), prevp);
|
||||||
}
|
}
|
||||||
if (lastx < (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) {
|
if (lastx < xfs_iext_count(ifp)) {
|
||||||
xfs_bmbt_get_all(ep, gotp);
|
xfs_bmbt_get_all(ep, gotp);
|
||||||
*eofp = 0;
|
*eofp = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1497,7 +1497,7 @@ xfs_bmap_first_unused(
|
||||||
(error = xfs_iread_extents(tp, ip, whichfork)))
|
(error = xfs_iread_extents(tp, ip, whichfork)))
|
||||||
return error;
|
return error;
|
||||||
lowest = *first_unused;
|
lowest = *first_unused;
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) {
|
for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) {
|
||||||
xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, idx);
|
xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, idx);
|
||||||
off = xfs_bmbt_get_startoff(ep);
|
off = xfs_bmbt_get_startoff(ep);
|
||||||
|
@ -1582,7 +1582,7 @@ xfs_bmap_last_extent(
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
if (nextents == 0) {
|
if (nextents == 0) {
|
||||||
*is_empty = 1;
|
*is_empty = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1735,7 +1735,7 @@ xfs_bmap_add_extent_delay_real(
|
||||||
&bma->ip->i_d.di_nextents);
|
&bma->ip->i_d.di_nextents);
|
||||||
|
|
||||||
ASSERT(bma->idx >= 0);
|
ASSERT(bma->idx >= 0);
|
||||||
ASSERT(bma->idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
|
ASSERT(bma->idx <= xfs_iext_count(ifp));
|
||||||
ASSERT(!isnullstartblock(new->br_startblock));
|
ASSERT(!isnullstartblock(new->br_startblock));
|
||||||
ASSERT(!bma->cur ||
|
ASSERT(!bma->cur ||
|
||||||
(bma->cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL));
|
(bma->cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL));
|
||||||
|
@ -1794,7 +1794,7 @@ xfs_bmap_add_extent_delay_real(
|
||||||
* Don't set contiguous if the combined extent would be too large.
|
* Don't set contiguous if the combined extent would be too large.
|
||||||
* Also check for all-three-contiguous being too large.
|
* Also check for all-three-contiguous being too large.
|
||||||
*/
|
*/
|
||||||
if (bma->idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
|
if (bma->idx < xfs_iext_count(ifp) - 1) {
|
||||||
state |= BMAP_RIGHT_VALID;
|
state |= BMAP_RIGHT_VALID;
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx + 1), &RIGHT);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx + 1), &RIGHT);
|
||||||
|
|
||||||
|
@ -2300,7 +2300,7 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
|
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
|
||||||
|
|
||||||
ASSERT(*idx >= 0);
|
ASSERT(*idx >= 0);
|
||||||
ASSERT(*idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
|
ASSERT(*idx <= xfs_iext_count(ifp));
|
||||||
ASSERT(!isnullstartblock(new->br_startblock));
|
ASSERT(!isnullstartblock(new->br_startblock));
|
||||||
|
|
||||||
XFS_STATS_INC(mp, xs_add_exlist);
|
XFS_STATS_INC(mp, xs_add_exlist);
|
||||||
|
@ -2356,7 +2356,7 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
* Don't set contiguous if the combined extent would be too large.
|
* Don't set contiguous if the combined extent would be too large.
|
||||||
* Also check for all-three-contiguous being too large.
|
* Also check for all-three-contiguous being too large.
|
||||||
*/
|
*/
|
||||||
if (*idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
|
if (*idx < xfs_iext_count(&ip->i_df) - 1) {
|
||||||
state |= BMAP_RIGHT_VALID;
|
state |= BMAP_RIGHT_VALID;
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx + 1), &RIGHT);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx + 1), &RIGHT);
|
||||||
if (isnullstartblock(RIGHT.br_startblock))
|
if (isnullstartblock(RIGHT.br_startblock))
|
||||||
|
@ -2836,7 +2836,7 @@ xfs_bmap_add_extent_hole_delay(
|
||||||
* Check and set flags if the current (right) segment exists.
|
* Check and set flags if the current (right) segment exists.
|
||||||
* If it doesn't exist, we're converting the hole at end-of-file.
|
* If it doesn't exist, we're converting the hole at end-of-file.
|
||||||
*/
|
*/
|
||||||
if (*idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
|
if (*idx < xfs_iext_count(ifp)) {
|
||||||
state |= BMAP_RIGHT_VALID;
|
state |= BMAP_RIGHT_VALID;
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx), &right);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx), &right);
|
||||||
|
|
||||||
|
@ -2966,7 +2966,7 @@ xfs_bmap_add_extent_hole_real(
|
||||||
ifp = XFS_IFORK_PTR(bma->ip, whichfork);
|
ifp = XFS_IFORK_PTR(bma->ip, whichfork);
|
||||||
|
|
||||||
ASSERT(bma->idx >= 0);
|
ASSERT(bma->idx >= 0);
|
||||||
ASSERT(bma->idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
|
ASSERT(bma->idx <= xfs_iext_count(ifp));
|
||||||
ASSERT(!isnullstartblock(new->br_startblock));
|
ASSERT(!isnullstartblock(new->br_startblock));
|
||||||
ASSERT(!bma->cur ||
|
ASSERT(!bma->cur ||
|
||||||
!(bma->cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL));
|
!(bma->cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL));
|
||||||
|
@ -2992,7 +2992,7 @@ xfs_bmap_add_extent_hole_real(
|
||||||
* Check and set flags if this segment has a current value.
|
* Check and set flags if this segment has a current value.
|
||||||
* Not true if we're inserting into the "hole" at eof.
|
* Not true if we're inserting into the "hole" at eof.
|
||||||
*/
|
*/
|
||||||
if (bma->idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
|
if (bma->idx < xfs_iext_count(ifp)) {
|
||||||
state |= BMAP_RIGHT_VALID;
|
state |= BMAP_RIGHT_VALID;
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx), &right);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx), &right);
|
||||||
if (isnullstartblock(right.br_startblock))
|
if (isnullstartblock(right.br_startblock))
|
||||||
|
@ -4221,7 +4221,7 @@ xfs_bmapi_read(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Else go on to the next record. */
|
/* Else go on to the next record. */
|
||||||
if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
|
if (++lastx < xfs_iext_count(ifp))
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got);
|
||||||
else
|
else
|
||||||
eof = 1;
|
eof = 1;
|
||||||
|
@ -4733,7 +4733,7 @@ xfs_bmapi_write(
|
||||||
|
|
||||||
/* Else go on to the next record. */
|
/* Else go on to the next record. */
|
||||||
bma.prev = bma.got;
|
bma.prev = bma.got;
|
||||||
if (++bma.idx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t)) {
|
if (++bma.idx < xfs_iext_count(ifp)) {
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma.idx),
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma.idx),
|
||||||
&bma.got);
|
&bma.got);
|
||||||
} else
|
} else
|
||||||
|
@ -4885,7 +4885,7 @@ xfs_bmap_del_extent_delay(
|
||||||
da_new = 0;
|
da_new = 0;
|
||||||
|
|
||||||
ASSERT(*idx >= 0);
|
ASSERT(*idx >= 0);
|
||||||
ASSERT(*idx < ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
|
ASSERT(*idx <= xfs_iext_count(ifp));
|
||||||
ASSERT(del->br_blockcount > 0);
|
ASSERT(del->br_blockcount > 0);
|
||||||
ASSERT(got->br_startoff <= del->br_startoff);
|
ASSERT(got->br_startoff <= del->br_startoff);
|
||||||
ASSERT(got_endoff >= del_endoff);
|
ASSERT(got_endoff >= del_endoff);
|
||||||
|
@ -5013,7 +5013,7 @@ xfs_bmap_del_extent_cow(
|
||||||
got_endoff = got->br_startoff + got->br_blockcount;
|
got_endoff = got->br_startoff + got->br_blockcount;
|
||||||
|
|
||||||
ASSERT(*idx >= 0);
|
ASSERT(*idx >= 0);
|
||||||
ASSERT(*idx < ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
|
ASSERT(*idx <= xfs_iext_count(ifp));
|
||||||
ASSERT(del->br_blockcount > 0);
|
ASSERT(del->br_blockcount > 0);
|
||||||
ASSERT(got->br_startoff <= del->br_startoff);
|
ASSERT(got->br_startoff <= del->br_startoff);
|
||||||
ASSERT(got_endoff >= del_endoff);
|
ASSERT(got_endoff >= del_endoff);
|
||||||
|
@ -5119,8 +5119,7 @@ xfs_bmap_del_extent(
|
||||||
state |= BMAP_COWFORK;
|
state |= BMAP_COWFORK;
|
||||||
|
|
||||||
ifp = XFS_IFORK_PTR(ip, whichfork);
|
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||||
ASSERT((*idx >= 0) && (*idx < ifp->if_bytes /
|
ASSERT((*idx >= 0) && (*idx < xfs_iext_count(ifp)));
|
||||||
(uint)sizeof(xfs_bmbt_rec_t)));
|
|
||||||
ASSERT(del->br_blockcount > 0);
|
ASSERT(del->br_blockcount > 0);
|
||||||
ep = xfs_iext_get_ext(ifp, *idx);
|
ep = xfs_iext_get_ext(ifp, *idx);
|
||||||
xfs_bmbt_get_all(ep, &got);
|
xfs_bmbt_get_all(ep, &got);
|
||||||
|
@ -5445,7 +5444,6 @@ __xfs_bunmapi(
|
||||||
int logflags; /* transaction logging flags */
|
int logflags; /* transaction logging flags */
|
||||||
xfs_extlen_t mod; /* rt extent offset */
|
xfs_extlen_t mod; /* rt extent offset */
|
||||||
xfs_mount_t *mp; /* mount structure */
|
xfs_mount_t *mp; /* mount structure */
|
||||||
xfs_extnum_t nextents; /* number of file extents */
|
|
||||||
xfs_bmbt_irec_t prev; /* previous extent record */
|
xfs_bmbt_irec_t prev; /* previous extent record */
|
||||||
xfs_fileoff_t start; /* first file offset deleted */
|
xfs_fileoff_t start; /* first file offset deleted */
|
||||||
int tmp_logflags; /* partial logging flags */
|
int tmp_logflags; /* partial logging flags */
|
||||||
|
@ -5477,8 +5475,7 @@ __xfs_bunmapi(
|
||||||
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;
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
if (xfs_iext_count(ifp) == 0) {
|
||||||
if (nextents == 0) {
|
|
||||||
*rlen = 0;
|
*rlen = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -5963,7 +5960,7 @@ xfs_bmse_shift_one(
|
||||||
|
|
||||||
mp = ip->i_mount;
|
mp = ip->i_mount;
|
||||||
ifp = XFS_IFORK_PTR(ip, whichfork);
|
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||||
total_extents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
|
total_extents = xfs_iext_count(ifp);
|
||||||
|
|
||||||
xfs_bmbt_get_all(gotp, &got);
|
xfs_bmbt_get_all(gotp, &got);
|
||||||
|
|
||||||
|
@ -6140,7 +6137,7 @@ xfs_bmap_shift_extents(
|
||||||
* are collapsing out, so we cannot use the count of real extents here.
|
* are collapsing out, so we cannot use the count of real extents here.
|
||||||
* Instead we have to calculate it from the incore fork.
|
* Instead we have to calculate it from the incore fork.
|
||||||
*/
|
*/
|
||||||
total_extents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
|
total_extents = xfs_iext_count(ifp);
|
||||||
if (total_extents == 0) {
|
if (total_extents == 0) {
|
||||||
*done = 1;
|
*done = 1;
|
||||||
goto del_cursor;
|
goto del_cursor;
|
||||||
|
@ -6200,7 +6197,7 @@ xfs_bmap_shift_extents(
|
||||||
* count can change. Update the total and grade the next record.
|
* count can change. Update the total and grade the next record.
|
||||||
*/
|
*/
|
||||||
if (direction == SHIFT_LEFT) {
|
if (direction == SHIFT_LEFT) {
|
||||||
total_extents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
|
total_extents = xfs_iext_count(ifp);
|
||||||
stop_extent = total_extents;
|
stop_extent = total_extents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -775,6 +775,13 @@ xfs_idestroy_fork(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Count number of incore extents based on if_bytes */
|
||||||
|
xfs_extnum_t
|
||||||
|
xfs_iext_count(struct xfs_ifork *ifp)
|
||||||
|
{
|
||||||
|
return ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert in-core extents to on-disk form
|
* Convert in-core extents to on-disk form
|
||||||
*
|
*
|
||||||
|
@ -803,7 +810,7 @@ xfs_iextents_copy(
|
||||||
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
|
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
|
||||||
ASSERT(ifp->if_bytes > 0);
|
ASSERT(ifp->if_bytes > 0);
|
||||||
|
|
||||||
nrecs = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nrecs = xfs_iext_count(ifp);
|
||||||
XFS_BMAP_TRACE_EXLIST(ip, nrecs, whichfork);
|
XFS_BMAP_TRACE_EXLIST(ip, nrecs, whichfork);
|
||||||
ASSERT(nrecs > 0);
|
ASSERT(nrecs > 0);
|
||||||
|
|
||||||
|
@ -941,7 +948,7 @@ xfs_iext_get_ext(
|
||||||
xfs_extnum_t idx) /* index of target extent */
|
xfs_extnum_t idx) /* index of target extent */
|
||||||
{
|
{
|
||||||
ASSERT(idx >= 0);
|
ASSERT(idx >= 0);
|
||||||
ASSERT(idx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t));
|
ASSERT(idx < xfs_iext_count(ifp));
|
||||||
|
|
||||||
if ((ifp->if_flags & XFS_IFEXTIREC) && (idx == 0)) {
|
if ((ifp->if_flags & XFS_IFEXTIREC) && (idx == 0)) {
|
||||||
return ifp->if_u1.if_ext_irec->er_extbuf;
|
return ifp->if_u1.if_ext_irec->er_extbuf;
|
||||||
|
@ -1017,7 +1024,7 @@ xfs_iext_add(
|
||||||
int new_size; /* size of extents after adding */
|
int new_size; /* size of extents after adding */
|
||||||
xfs_extnum_t nextents; /* number of extents in file */
|
xfs_extnum_t nextents; /* number of extents in file */
|
||||||
|
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
ASSERT((idx >= 0) && (idx <= nextents));
|
ASSERT((idx >= 0) && (idx <= nextents));
|
||||||
byte_diff = ext_diff * sizeof(xfs_bmbt_rec_t);
|
byte_diff = ext_diff * sizeof(xfs_bmbt_rec_t);
|
||||||
new_size = ifp->if_bytes + byte_diff;
|
new_size = ifp->if_bytes + byte_diff;
|
||||||
|
@ -1241,7 +1248,7 @@ xfs_iext_remove(
|
||||||
trace_xfs_iext_remove(ip, idx, state, _RET_IP_);
|
trace_xfs_iext_remove(ip, idx, state, _RET_IP_);
|
||||||
|
|
||||||
ASSERT(ext_diff > 0);
|
ASSERT(ext_diff > 0);
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
new_size = (nextents - ext_diff) * sizeof(xfs_bmbt_rec_t);
|
new_size = (nextents - ext_diff) * sizeof(xfs_bmbt_rec_t);
|
||||||
|
|
||||||
if (new_size == 0) {
|
if (new_size == 0) {
|
||||||
|
@ -1270,7 +1277,7 @@ xfs_iext_remove_inline(
|
||||||
|
|
||||||
ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
|
ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
|
||||||
ASSERT(idx < XFS_INLINE_EXTS);
|
ASSERT(idx < XFS_INLINE_EXTS);
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
ASSERT(((nextents - ext_diff) > 0) &&
|
ASSERT(((nextents - ext_diff) > 0) &&
|
||||||
(nextents - ext_diff) < XFS_INLINE_EXTS);
|
(nextents - ext_diff) < XFS_INLINE_EXTS);
|
||||||
|
|
||||||
|
@ -1309,7 +1316,7 @@ xfs_iext_remove_direct(
|
||||||
ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
|
ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
|
||||||
new_size = ifp->if_bytes -
|
new_size = ifp->if_bytes -
|
||||||
(ext_diff * sizeof(xfs_bmbt_rec_t));
|
(ext_diff * sizeof(xfs_bmbt_rec_t));
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
|
|
||||||
if (new_size == 0) {
|
if (new_size == 0) {
|
||||||
xfs_iext_destroy(ifp);
|
xfs_iext_destroy(ifp);
|
||||||
|
@ -1546,7 +1553,7 @@ xfs_iext_indirect_to_direct(
|
||||||
int size; /* size of file extents */
|
int size; /* size of file extents */
|
||||||
|
|
||||||
ASSERT(ifp->if_flags & XFS_IFEXTIREC);
|
ASSERT(ifp->if_flags & XFS_IFEXTIREC);
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
ASSERT(nextents <= XFS_LINEAR_EXTS);
|
ASSERT(nextents <= XFS_LINEAR_EXTS);
|
||||||
size = nextents * sizeof(xfs_bmbt_rec_t);
|
size = nextents * sizeof(xfs_bmbt_rec_t);
|
||||||
|
|
||||||
|
@ -1620,7 +1627,7 @@ xfs_iext_bno_to_ext(
|
||||||
xfs_extnum_t nextents; /* number of file extents */
|
xfs_extnum_t nextents; /* number of file extents */
|
||||||
xfs_fileoff_t startoff = 0; /* start offset of extent */
|
xfs_fileoff_t startoff = 0; /* start offset of extent */
|
||||||
|
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
if (nextents == 0) {
|
if (nextents == 0) {
|
||||||
*idxp = 0;
|
*idxp = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1733,8 +1740,8 @@ xfs_iext_idx_to_irec(
|
||||||
|
|
||||||
ASSERT(ifp->if_flags & XFS_IFEXTIREC);
|
ASSERT(ifp->if_flags & XFS_IFEXTIREC);
|
||||||
ASSERT(page_idx >= 0);
|
ASSERT(page_idx >= 0);
|
||||||
ASSERT(page_idx <= ifp->if_bytes / sizeof(xfs_bmbt_rec_t));
|
ASSERT(page_idx <= xfs_iext_count(ifp));
|
||||||
ASSERT(page_idx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t) || realloc);
|
ASSERT(page_idx < xfs_iext_count(ifp) || realloc);
|
||||||
|
|
||||||
nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
|
nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
|
||||||
erp_idx = 0;
|
erp_idx = 0;
|
||||||
|
@ -1782,7 +1789,7 @@ xfs_iext_irec_init(
|
||||||
xfs_extnum_t nextents; /* number of extents in file */
|
xfs_extnum_t nextents; /* number of extents in file */
|
||||||
|
|
||||||
ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
|
ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
ASSERT(nextents <= XFS_LINEAR_EXTS);
|
ASSERT(nextents <= XFS_LINEAR_EXTS);
|
||||||
|
|
||||||
erp = kmem_alloc(sizeof(xfs_ext_irec_t), KM_NOFS);
|
erp = kmem_alloc(sizeof(xfs_ext_irec_t), KM_NOFS);
|
||||||
|
@ -1906,7 +1913,7 @@ xfs_iext_irec_compact(
|
||||||
|
|
||||||
ASSERT(ifp->if_flags & XFS_IFEXTIREC);
|
ASSERT(ifp->if_flags & XFS_IFEXTIREC);
|
||||||
nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
|
nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
|
|
||||||
if (nextents == 0) {
|
if (nextents == 0) {
|
||||||
xfs_iext_destroy(ifp);
|
xfs_iext_destroy(ifp);
|
||||||
|
|
|
@ -152,6 +152,7 @@ void xfs_init_local_fork(struct xfs_inode *, int, const void *, int);
|
||||||
|
|
||||||
struct xfs_bmbt_rec_host *
|
struct xfs_bmbt_rec_host *
|
||||||
xfs_iext_get_ext(struct xfs_ifork *, xfs_extnum_t);
|
xfs_iext_get_ext(struct xfs_ifork *, xfs_extnum_t);
|
||||||
|
xfs_extnum_t xfs_iext_count(struct xfs_ifork *);
|
||||||
void xfs_iext_insert(struct xfs_inode *, xfs_extnum_t, xfs_extnum_t,
|
void xfs_iext_insert(struct xfs_inode *, xfs_extnum_t, xfs_extnum_t,
|
||||||
struct xfs_bmbt_irec *, int);
|
struct xfs_bmbt_irec *, int);
|
||||||
void xfs_iext_add(struct xfs_ifork *, xfs_extnum_t, int);
|
void xfs_iext_add(struct xfs_ifork *, xfs_extnum_t, int);
|
||||||
|
|
|
@ -359,9 +359,7 @@ xfs_bmap_count_blocks(
|
||||||
mp = ip->i_mount;
|
mp = ip->i_mount;
|
||||||
ifp = XFS_IFORK_PTR(ip, whichfork);
|
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||||
if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) {
|
if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) {
|
||||||
xfs_bmap_count_leaves(ifp, 0,
|
xfs_bmap_count_leaves(ifp, 0, xfs_iext_count(ifp), count);
|
||||||
ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t),
|
|
||||||
count);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +424,7 @@ xfs_getbmapx_fix_eof_hole(
|
||||||
ifp = XFS_IFORK_PTR(ip, whichfork);
|
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||||
if (!moretocome &&
|
if (!moretocome &&
|
||||||
xfs_iext_bno_to_ext(ifp, fileblock, &lastx) &&
|
xfs_iext_bno_to_ext(ifp, fileblock, &lastx) &&
|
||||||
(lastx == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))-1))
|
(lastx == xfs_iext_count(ifp) - 1))
|
||||||
out->bmv_oflags |= BMV_OF_LAST;
|
out->bmv_oflags |= BMV_OF_LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1878,15 +1876,13 @@ xfs_swap_extent_forks(
|
||||||
|
|
||||||
switch (ip->i_d.di_format) {
|
switch (ip->i_d.di_format) {
|
||||||
case XFS_DINODE_FMT_EXTENTS:
|
case XFS_DINODE_FMT_EXTENTS:
|
||||||
/* If the extents fit in the inode, fix the
|
/*
|
||||||
* pointer. Otherwise it's already NULL or
|
* If the extents fit in the inode, fix the pointer. Otherwise
|
||||||
* pointing to the extent.
|
* it's already NULL or pointing to the extent.
|
||||||
*/
|
*/
|
||||||
nextents = ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(&ip->i_df);
|
||||||
if (nextents <= XFS_INLINE_EXTS) {
|
if (nextents <= XFS_INLINE_EXTS)
|
||||||
ifp->if_u1.if_extents =
|
ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext;
|
||||||
ifp->if_u2.if_inline_ext;
|
|
||||||
}
|
|
||||||
(*src_log_flags) |= XFS_ILOG_DEXT;
|
(*src_log_flags) |= XFS_ILOG_DEXT;
|
||||||
break;
|
break;
|
||||||
case XFS_DINODE_FMT_BTREE:
|
case XFS_DINODE_FMT_BTREE:
|
||||||
|
@ -1898,15 +1894,13 @@ xfs_swap_extent_forks(
|
||||||
|
|
||||||
switch (tip->i_d.di_format) {
|
switch (tip->i_d.di_format) {
|
||||||
case XFS_DINODE_FMT_EXTENTS:
|
case XFS_DINODE_FMT_EXTENTS:
|
||||||
/* If the extents fit in the inode, fix the
|
/*
|
||||||
* pointer. Otherwise it's already NULL or
|
* If the extents fit in the inode, fix the pointer. Otherwise
|
||||||
* pointing to the extent.
|
* it's already NULL or pointing to the extent.
|
||||||
*/
|
*/
|
||||||
nextents = tip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(&tip->i_df);
|
||||||
if (nextents <= XFS_INLINE_EXTS) {
|
if (nextents <= XFS_INLINE_EXTS)
|
||||||
tifp->if_u1.if_extents =
|
tifp->if_u1.if_extents = tifp->if_u2.if_inline_ext;
|
||||||
tifp->if_u2.if_inline_ext;
|
|
||||||
}
|
|
||||||
(*target_log_flags) |= XFS_ILOG_DEXT;
|
(*target_log_flags) |= XFS_ILOG_DEXT;
|
||||||
break;
|
break;
|
||||||
case XFS_DINODE_FMT_BTREE:
|
case XFS_DINODE_FMT_BTREE:
|
||||||
|
|
|
@ -164,7 +164,7 @@ xfs_inode_item_format_data_fork(
|
||||||
struct xfs_bmbt_rec *p;
|
struct xfs_bmbt_rec *p;
|
||||||
|
|
||||||
ASSERT(ip->i_df.if_u1.if_extents != NULL);
|
ASSERT(ip->i_df.if_u1.if_extents != NULL);
|
||||||
ASSERT(ip->i_df.if_bytes / sizeof(xfs_bmbt_rec_t) > 0);
|
ASSERT(xfs_iext_count(&ip->i_df) > 0);
|
||||||
|
|
||||||
p = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_IEXT);
|
p = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_IEXT);
|
||||||
data_bytes = xfs_iextents_copy(ip, p, XFS_DATA_FORK);
|
data_bytes = xfs_iextents_copy(ip, p, XFS_DATA_FORK);
|
||||||
|
@ -261,7 +261,7 @@ xfs_inode_item_format_attr_fork(
|
||||||
ip->i_afp->if_bytes > 0) {
|
ip->i_afp->if_bytes > 0) {
|
||||||
struct xfs_bmbt_rec *p;
|
struct xfs_bmbt_rec *p;
|
||||||
|
|
||||||
ASSERT(ip->i_afp->if_bytes / sizeof(xfs_bmbt_rec_t) ==
|
ASSERT(xfs_iext_count(ip->i_afp) ==
|
||||||
ip->i_d.di_anextents);
|
ip->i_d.di_anextents);
|
||||||
ASSERT(ip->i_afp->if_u1.if_extents != NULL);
|
ASSERT(ip->i_afp->if_u1.if_extents != NULL);
|
||||||
|
|
||||||
|
|
|
@ -910,16 +910,14 @@ xfs_ioc_fsgetxattr(
|
||||||
if (attr) {
|
if (attr) {
|
||||||
if (ip->i_afp) {
|
if (ip->i_afp) {
|
||||||
if (ip->i_afp->if_flags & XFS_IFEXTENTS)
|
if (ip->i_afp->if_flags & XFS_IFEXTENTS)
|
||||||
fa.fsx_nextents = ip->i_afp->if_bytes /
|
fa.fsx_nextents = xfs_iext_count(ip->i_afp);
|
||||||
sizeof(xfs_bmbt_rec_t);
|
|
||||||
else
|
else
|
||||||
fa.fsx_nextents = ip->i_d.di_anextents;
|
fa.fsx_nextents = ip->i_d.di_anextents;
|
||||||
} else
|
} else
|
||||||
fa.fsx_nextents = 0;
|
fa.fsx_nextents = 0;
|
||||||
} else {
|
} else {
|
||||||
if (ip->i_df.if_flags & XFS_IFEXTENTS)
|
if (ip->i_df.if_flags & XFS_IFEXTENTS)
|
||||||
fa.fsx_nextents = ip->i_df.if_bytes /
|
fa.fsx_nextents = xfs_iext_count(&ip->i_df);
|
||||||
sizeof(xfs_bmbt_rec_t);
|
|
||||||
else
|
else
|
||||||
fa.fsx_nextents = ip->i_d.di_nextents;
|
fa.fsx_nextents = ip->i_d.di_nextents;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ xfs_qm_get_rtblks(
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
rtblks = 0;
|
rtblks = 0;
|
||||||
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
|
nextents = xfs_iext_count(ifp);
|
||||||
for (idx = 0; idx < nextents; idx++)
|
for (idx = 0; idx < nextents; idx++)
|
||||||
rtblks += xfs_bmbt_get_blockcount(xfs_iext_get_ext(ifp, idx));
|
rtblks += xfs_bmbt_get_blockcount(xfs_iext_get_ext(ifp, idx));
|
||||||
*O_rtblks = (xfs_qcnt_t)rtblks;
|
*O_rtblks = (xfs_qcnt_t)rtblks;
|
||||||
|
|
|
@ -486,7 +486,7 @@ xfs_reflink_trim_irec_to_next_cow(
|
||||||
/* This is the extent before; try sliding up one. */
|
/* This is the extent before; try sliding up one. */
|
||||||
if (irec.br_startoff < offset_fsb) {
|
if (irec.br_startoff < offset_fsb) {
|
||||||
idx++;
|
idx++;
|
||||||
if (idx >= ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
|
if (idx >= xfs_iext_count(ifp))
|
||||||
return 0;
|
return 0;
|
||||||
gotp = xfs_iext_get_ext(ifp, idx);
|
gotp = xfs_iext_get_ext(ifp, idx);
|
||||||
xfs_bmbt_get_all(gotp, &irec);
|
xfs_bmbt_get_all(gotp, &irec);
|
||||||
|
@ -566,7 +566,7 @@ xfs_reflink_cancel_cow_blocks(
|
||||||
xfs_bmap_del_extent_cow(ip, &idx, &got, &del);
|
xfs_bmap_del_extent_cow(ip, &idx, &got, &del);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++idx >= ifp->if_bytes / sizeof(struct xfs_bmbt_rec))
|
if (++idx >= xfs_iext_count(ifp))
|
||||||
break;
|
break;
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &got);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &got);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue