]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xfs: more do_div cleanups
authorEric Sandeen <sandeen@redhat.com>
Wed, 19 Apr 2017 22:19:32 +0000 (15:19 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 25 Apr 2017 16:40:41 +0000 (09:40 -0700)
On some architectures do_div does the pointer compare
trick to make sure that we've sent it an unsigned 64-bit
number.  (Why unsigned?  I don't know.)

Fix up the few places that squawk about this; in
xfs_bmap_wants_extents() we just used a bare int64_t so change
that to unsigned.

In xfs_adjust_extent_unmap_boundaries() all we wanted was the
mod, and we have an xfs-specific function to handle that w/o
side effects, which includes proper casting for do_div.

In xfs_daddr_to_ag[b]no, we were using the wrong type anyway;
XFS_BB_TO_FSBT returns a block in the filesystem, so use
xfs_rfsblock_t not xfs_daddr_t, and gain the unsignedness
from that type as a bonus.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/xfs_bmap_util.c
fs/xfs/xfs_mount.h

index 7f42f6067eb5e68d60fea0a18dcf4d7769f4609a..0fdff08145c19654f65e86121f813fc58fd429e0 100644 (file)
@@ -4887,7 +4887,7 @@ xfs_bmap_del_extent_delay(
        ASSERT(got_endoff >= del_endoff);
 
        if (isrt) {
-               int64_t rtexts = XFS_FSB_TO_B(mp, del->br_blockcount);
+               uint64_t rtexts = XFS_FSB_TO_B(mp, del->br_blockcount);
 
                do_div(rtexts, mp->m_sb.sb_rextsize);
                xfs_mod_frextents(mp, rtexts);
index de94798f1c1b2baa55d6e23fceb1329670400a36..7ac80a1facf2cc78549dae9947bec01db90aafb9 100644 (file)
@@ -1206,11 +1206,8 @@ xfs_adjust_extent_unmap_boundaries(
                return error;
 
        if (nimap && imap.br_startblock != HOLESTARTBLOCK) {
-               xfs_daddr_t     block;
-
                ASSERT(imap.br_startblock != DELAYSTARTBLOCK);
-               block = imap.br_startblock;
-               mod = do_div(block, mp->m_sb.sb_rextsize);
+               mod = do_mod(imap.br_startblock, mp->m_sb.sb_rextsize);
                if (mod)
                        *startoffset_fsb += mp->m_sb.sb_rextsize - mod;
        }
index 22b2185e93a0c4aa4edcd25411bed006d4fbe715..9fa312a41c930cc188ec14f43097b0400a07bb27 100644 (file)
@@ -313,7 +313,7 @@ void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
 static inline xfs_agnumber_t
 xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
 {
-       xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
+       xfs_rfsblock_t ld = XFS_BB_TO_FSBT(mp, d);
        do_div(ld, mp->m_sb.sb_agblocks);
        return (xfs_agnumber_t) ld;
 }
@@ -321,7 +321,7 @@ xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
 static inline xfs_agblock_t
 xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
 {
-       xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
+       xfs_rfsblock_t ld = XFS_BB_TO_FSBT(mp, d);
        return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks);
 }