Skip to contentSkip to conversation

xfs: fix incorrect test in xfs_alloc_ag_vextent_lastblock

PATCH In review Darrick J. Wong 3 participants 3 messages Mar 16, 2020 – Mar 17, 2020 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix incorrect test in xfs_alloc_ag_vextent_lastblock

From: Darrick J. Wong <[email protected]>

When I lifted the code in xfs_alloc_ag_vextent_lastblock out of a loop, I forgot to convert all the accesses to len to be pointer dereferences.

Coverity-id: 1457918

Fixes 5113f8ec3753ed ("xfs: clean up weird while loop in xfs_alloc_ag_vextent_near")
---
 fs/xfs/libxfs/xfs_alloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -1
index 337822115bbc..203e74fa64aa 100644
@@ -1514,7 +1514,7 @@ xfs_alloc_ag_vextent_lastblock(
 	 * maxlen, go to the start of this block, and skip all those smaller
 	 * than minlen.
 	 */
-	if (len || args->alignment > 1) {
+	if (*len || args->alignment > 1) {
 		acur->cnt->bc_ptrs[0] = 1;
 		do {
 			error = xfs_alloc_get_rec(acur->cnt, bno, len, &i);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

When I lifted the code in xfs_alloc_ag_vextent_lastblock out of a loop, I forgot to convert all the accesses to len to be pointer dereferences.

Coverity-id: 1457918

Fixes 5113f8ec3753ed ("xfs: clean up weird while loop in xfs_alloc_ag_vextent_near")

---

Quoted 17 lines
 fs/xfs/libxfs/xfs_alloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -1
index 337822115bbc..203e74fa64aa 100644
@@ -1514,7 +1514,7 @@ xfs_alloc_ag_vextent_lastblock(
 	 * maxlen, go to the start of this block, and skip all those smaller
 	 * than minlen.
 	 */
-	if (len || args->alignment > 1) {
+	if (*len || args->alignment > 1) {
 		acur->cnt->bc_ptrs[0] = 1;
 		do {
 			error = xfs_alloc_get_rec(acur->cnt, bno, len, &i);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Darrick J. Wong

fs/xfs/libxfs/xfs_alloc.c xfs_alloc_ag_vextent_lastblock( · line 1520

Quoted 13 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_alloc.c +1 -1
index 337822115bbc..203e74fa64aa 100644
@@ -1514,7 +1514,7 @@ xfs_alloc_ag_vextent_lastblock(
 	 * maxlen, go to the start of this block, and skip all those smaller
 	 * than minlen.
 	 */
-	if (len || args->alignment > 1) {
+	if (*len || args->alignment > 1) {
 		acur->cnt->bc_ptrs[0] = 1;
 		do {
 			error = xfs_alloc_get_rec(acur->cnt, bno, len, &i);

The change definitivelly restores the old behavior. Looks good: