* [PATCH] xfs: simplify xfs_calc_dquots_per_chunk
@ 2017-04-05 21:03 Eric Sandeen
2017-04-06 23:23 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2017-04-05 21:03 UTC (permalink / raw)
To: linux-xfs
ndquots is a 32-bit value, and we don't care
about the remainder; there is no reason to use do_div
here, it seems to be the result of a decade+ historical
accident.
Worse, the do_div implementation in userspace breaks
when fed a 32-bit dividend, so we commented it out there
in any case.
Change to simple division, and then we can change
userspace to match, and mandate a 64-bit dividend in
the do_div() in userspace as well.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
tested w/ ./check -g quota
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index ac9a003..747085b 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -35,13 +35,8 @@
xfs_calc_dquots_per_chunk(
unsigned int nbblks) /* basic block units */
{
- unsigned int ndquots;
-
ASSERT(nbblks > 0);
- ndquots = BBTOB(nbblks);
- do_div(ndquots, sizeof(xfs_dqblk_t));
-
- return ndquots;
+ return BBTOB(nbblks) / sizeof(xfs_dqblk_t);
}
/*
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs: simplify xfs_calc_dquots_per_chunk
2017-04-05 21:03 [PATCH] xfs: simplify xfs_calc_dquots_per_chunk Eric Sandeen
@ 2017-04-06 23:23 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2017-04-06 23:23 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs
On Wed, Apr 05, 2017 at 04:03:17PM -0500, Eric Sandeen wrote:
> ndquots is a 32-bit value, and we don't care
> about the remainder; there is no reason to use do_div
> here, it seems to be the result of a decade+ historical
> accident.
>
> Worse, the do_div implementation in userspace breaks
> when fed a 32-bit dividend, so we commented it out there
> in any case.
>
> Change to simple division, and then we can change
> userspace to match, and mandate a 64-bit dividend in
> the do_div() in userspace as well.
This looks fine since nbblks is (unsigned int) and BBTOB doesn't cast to
a 64-bit quantity, therefore 64-bit division isn't ncessary. This
passes compilation on i386 and armhf, so I guess I'll go test it.
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> tested w/ ./check -g quota
>
> diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
> index ac9a003..747085b 100644
> --- a/fs/xfs/libxfs/xfs_dquot_buf.c
> +++ b/fs/xfs/libxfs/xfs_dquot_buf.c
> @@ -35,13 +35,8 @@
> xfs_calc_dquots_per_chunk(
> unsigned int nbblks) /* basic block units */
> {
> - unsigned int ndquots;
> -
> ASSERT(nbblks > 0);
> - ndquots = BBTOB(nbblks);
> - do_div(ndquots, sizeof(xfs_dqblk_t));
> -
> - return ndquots;
> + return BBTOB(nbblks) / sizeof(xfs_dqblk_t);
> }
>
> /*
>
> --
> 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-06 23:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-05 21:03 [PATCH] xfs: simplify xfs_calc_dquots_per_chunk Eric Sandeen
2017-04-06 23:23 ` 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.