* [PATCH] xfs: more do_div cleanups
@ 2017-04-19 20:55 Eric Sandeen
2017-04-19 22:26 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2017-04-19 20:55 UTC (permalink / raw)
To: linux-xfs
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>
---
Lightly tested via cross-compile to parisc as well as
(incomplete) xfstests testing.
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index bfc00de..fce43fb 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4856,7 +4856,7 @@ static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork)
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);
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index c141791..5c9e3d6 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1222,11 +1222,8 @@
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;
}
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 7f351f7..dea4e2b 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -311,7 +311,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;
}
@@ -319,7 +319,7 @@ void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
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);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs: more do_div cleanups
2017-04-19 20:55 [PATCH] xfs: more do_div cleanups Eric Sandeen
@ 2017-04-19 22:26 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2017-04-19 22:26 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs
On Wed, Apr 19, 2017 at 03:55:49PM -0500, Eric Sandeen wrote:
> 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>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
>
> Lightly tested via cross-compile to parisc as well as
> (incomplete) xfstests testing.
>
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index bfc00de..fce43fb 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4856,7 +4856,7 @@ static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork)
> 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);
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index c141791..5c9e3d6 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1222,11 +1222,8 @@
> 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;
> }
> diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
> index 7f351f7..dea4e2b 100644
> --- a/fs/xfs/xfs_mount.h
> +++ b/fs/xfs/xfs_mount.h
> @@ -311,7 +311,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;
> }
> @@ -319,7 +319,7 @@ void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
> 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);
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-19 22:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 20:55 [PATCH] xfs: more do_div cleanups Eric Sandeen
2017-04-19 22:26 ` Darrick J. Wong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.