]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use xfs_iext_get_extent in xfs_bmap_first_unused
authorChristoph Hellwig <hch@lst.de>
Wed, 18 Oct 2017 18:39:01 +0000 (13:39 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 18 Oct 2017 18:39:01 +0000 (13:39 -0500)
Source kernel commit: f2285c148c4167337d12452bebccadd2ad821d5d

Use the bmap abstraction instead of open-coding bmbt details here.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_bmap.c

index c56cffeb21424114e6601e114ced0489c868faaf..cb48bacbaa84cc964c5f43b9b32ef26f46c70a4a 100644 (file)
@@ -1350,7 +1350,6 @@ xfs_bmap_first_unused(
        xfs_fileoff_t   lastaddr;               /* last block number seen */
        xfs_fileoff_t   lowest;                 /* lowest useful block */
        xfs_fileoff_t   max;                    /* starting useful block */
-       xfs_fileoff_t   off;                    /* offset for this block */
        xfs_extnum_t    nextents;               /* number of extent entries */
 
        ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE ||
@@ -1367,16 +1366,19 @@ xfs_bmap_first_unused(
        lowest = *first_unused;
        nextents = xfs_iext_count(ifp);
        for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) {
-               xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, idx);
-               off = xfs_bmbt_get_startoff(ep);
+               struct xfs_bmbt_irec got;
+
+               xfs_iext_get_extent(ifp, idx, &got);
+
                /*
                 * See if the hole before this extent will work.
                 */
-               if (off >= lowest + len && off - max >= len) {
+               if (got.br_startoff >= lowest + len &&
+                   got.br_startoff - max >= len) {
                        *first_unused = max;
                        return 0;
                }
-               lastaddr = off + xfs_bmbt_get_blockcount(ep);
+               lastaddr = got.br_startoff + got.br_blockcount;
                max = XFS_FILEOFF_MAX(lastaddr, lowest);
        }
        *first_unused = max;