Skip to contentSkip to conversation

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

PATCH In review Eric Sandeen 4 participants 8 messages Apr 15, 2017 – Apr 19, 2017 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: remove use of do_div with 32-bit dividend in quota debug code

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.

---

fs/xfs/xfs_qm.c +1 -2
index b669b12..dedeb7f 100644
@@ -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;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Eric Sandeen

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.

Looks good.

Quoted 21 lines

---

fs/xfs/xfs_qm.c +1 -3
index b669b12..dedeb7f 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Eric Sandeen
Quoted 14 lines · Eric Sandeen

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.

---

fs/xfs/xfs_qm.c +0 -0
index b669b12..dedeb7f 100644

fs/xfs/xfs_qm.c struct xfs_qm_isolate { · line 854

Quoted 6 lines
fs/xfs/xfs_qm.c +1 -2
@@ -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

Quoted 8 lines
fs/xfs/xfs_qm.c +0 -1
 	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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 24 lines · Darrick J. Wong
Quoted 14 lines · Eric Sandeen

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.

---

fs/xfs/xfs_qm.c +0 -0
index b669b12..dedeb7f 100644

fs/xfs/xfs_qm.c struct xfs_qm_isolate { · line 854

Quoted 6 lines
fs/xfs/xfs_qm.c +1 -2
@@ -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...

Quoted 2 lines

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

Quoted 3 lines

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

Quoted 15 lines

--D

Quoted 8 lines
fs/xfs/xfs_qm.c +0 -1
 	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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

PATCH v2 1/1 xfs: remove use of do_div with 32-bit dividend in quota debug code

In reply to Eric Sandeen

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.

---

V2: now with less actual 64-bit division!

fs/xfs/xfs_qm.c +2 -2
index b669b12..6b42db4 100644
@@ -851,8 +851,8 @@ 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 = (int)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;
Reviewed-by on v2 1/1
#5 lore raw
Quoted 7 lines · Eric Sandeen

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.

Looks ok, will throw it on the testing pile...

(Seems to build ok on i386 too.)

--D

Quoted 25 lines

---

V2: now with less actual 64-bit division!

fs/xfs/xfs_qm.c +2 -3
index b669b12..6b42db4 100644
@@ -851,8 +851,8 @@ 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 = (int)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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v2 1/1
#6 lore raw
In reply to Eric Sandeen
Quoted 7 lines · Eric Sandeen

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.

looks even better now ;)

Reviewed-by Bill O'Donnell
Quoted 25 lines

---

V2: now with less actual 64-bit division!

fs/xfs/xfs_qm.c +2 -3
index b669b12..6b42db4 100644
@@ -851,8 +851,8 @@ 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 = (int)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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v2 1/1
#7 lore raw
In reply to Eric Sandeen
Quoted 7 lines · Eric Sandeen

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.

reviewed again, this time with proper email sig. ;)

Quoted 25 lines

---

V2: now with less actual 64-bit division!

fs/xfs/xfs_qm.c +2 -3
index b669b12..6b42db4 100644
@@ -851,8 +851,8 @@ 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 = (int)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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html