xfs: remove use of do_div with 32-bit dividend in quota debug code
diff mbox

Message ID e6022a70-8f09-633d-e99a-30186ea8c3d2@redhat.com
State Superseded
Headers show

Commit Message

Eric Sandeen April 15, 2017, 2:46 p.m. UTC
The kbuild test robot caught this; in debug code we have another
caller of do_div with a 32-bit dividend (j) which is caught now
that we are using the kernel-supplied do_div.

None of the values used here are 64-bit; just use simple division.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---


--
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

Comments

Bill O'Donnell April 17, 2017, 6:27 p.m. UTC | #1
On Sat, Apr 15, 2017 at 09:46:09AM -0500, Eric Sandeen wrote:
> The kbuild test robot caught this; in debug code we have another
> caller of do_div with a 32-bit dividend (j) which is caught now
> that we are using the kernel-supplied do_div.
> 
> None of the values used here are 64-bit; just use simple division.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks good.

Reviewed-by: Bill O'Donnell <billodo@redhat.com>

> ---
> 
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index b669b12..dedeb7f 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -851,8 +851,7 @@ struct xfs_qm_isolate {
>  	 * started afresh by xfs_qm_quotacheck.
>  	 */
>  #ifdef DEBUG
> -	j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
> -	do_div(j, sizeof(xfs_dqblk_t));
> +	j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) / sizeof(xfs_dqblk_t);
>  	ASSERT(mp->m_quotainfo->qi_dqperchunk == j);
>  #endif
>  	dqb = bp->b_addr;
> 
> --
> 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
--
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
Darrick J. Wong April 17, 2017, 6:59 p.m. UTC | #2
On Sat, Apr 15, 2017 at 09:46:09AM -0500, Eric Sandeen wrote:
> The kbuild test robot caught this; in debug code we have another
> caller of do_div with a 32-bit dividend (j) which is caught now
> that we are using the kernel-supplied do_div.
> 
> None of the values used here are 64-bit; just use simple division.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index b669b12..dedeb7f 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -851,8 +851,7 @@ struct xfs_qm_isolate {
>  	 * started afresh by xfs_qm_quotacheck.
>  	 */
>  #ifdef DEBUG
> -	j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
> -	do_div(j, sizeof(xfs_dqblk_t));
> +	j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) / sizeof(xfs_dqblk_t);

Uh...

#define XFS_FSB_TO_B(mp,fsbno)   ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
typedef    __int64_t       xfs_fsize_t;    /* bytes in a file */

So the macro resolves to a 64-bit value, which is then fed directly into
an integer division, which breaks the i386 build with the usual __divdi3
complaint.

--D

>  	ASSERT(mp->m_quotainfo->qi_dqperchunk == j);
>  #endif
>  	dqb = bp->b_addr;
> 
> --
> 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
--
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
Eric Sandeen April 19, 2017, 7:29 p.m. UTC | #3
On 4/17/17 1:59 PM, Darrick J. Wong wrote:
> On Sat, Apr 15, 2017 at 09:46:09AM -0500, Eric Sandeen wrote:
>> The kbuild test robot caught this; in debug code we have another
>> caller of do_div with a 32-bit dividend (j) which is caught now
>> that we are using the kernel-supplied do_div.
>>
>> None of the values used here are 64-bit; just use simple division.
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>>
>> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
>> index b669b12..dedeb7f 100644
>> --- a/fs/xfs/xfs_qm.c
>> +++ b/fs/xfs/xfs_qm.c
>> @@ -851,8 +851,7 @@ struct xfs_qm_isolate {
>>  	 * started afresh by xfs_qm_quotacheck.
>>  	 */
>>  #ifdef DEBUG
>> -	j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
>> -	do_div(j, sizeof(xfs_dqblk_t));
>> +	j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) / sizeof(xfs_dqblk_t);
> 
> Uh...
> 
> #define XFS_FSB_TO_B(mp,fsbno)   ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
> typedef    __int64_t       xfs_fsize_t;    /* bytes in a file */

Assigned to "int j", riiiiight.  hohum.
 
> So the macro resolves to a 64-bit value, which is then fed directly into
> an integer division, which breaks the i386 build with the usual __divdi3
> complaint.

sandeen--

> --D
> 
>>  	ASSERT(mp->m_quotainfo->qi_dqperchunk == j);
>>  #endif
>>  	dqb = bp->b_addr;
>>
>> --
>> 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
> --
> 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
> 
--
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

Patch
diff mbox

diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index b669b12..dedeb7f 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -851,8 +851,7 @@  struct xfs_qm_isolate {
 	 * started afresh by xfs_qm_quotacheck.
 	 */
 #ifdef DEBUG
-	j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
-	do_div(j, sizeof(xfs_dqblk_t));
+	j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) / sizeof(xfs_dqblk_t);
 	ASSERT(mp->m_quotainfo->qi_dqperchunk == j);
 #endif
 	dqb = bp->b_addr;