Skip to contentSkip to conversation

xfs: fix potential infinite loop in xfs_iomap_prealloc_size()

PATCH Applied Brian Foster 3 participants 3 messages Feb 22, 2013 – Mar 7, 2013 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix potential infinite loop in xfs_iomap_prealloc_size()

If freesp == 0, we could end up in an infinite loop while squashing the preallocation. Break the loop when we've killed the prealloc entirely.

---
Hi all,

Mark caught this while reviewing the quota throttling patchset. I figured it better that my set depend on this rather than vice versa, so I'll plan on a v5 for at least a rebase, but I'll wait a bit for further comments on v4.

Brian

 fs/xfs/xfs_iomap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/xfs/xfs_iomap.c +1 -1
index 912d83d..b0b0f44 100644
@@ -413,7 +413,7 @@ xfs_iomap_prealloc_size(
 		 * have a large file on a small filesystem and the above
 		 * lowspace thresholds are smaller than MAXEXTLEN.
 		 */
-		while (alloc_blocks >= freesp)
+		while (alloc_blocks && alloc_blocks >= freesp)
 			alloc_blocks >>= 4;
 	}
 
Signature · 6 lines
1.7.7.6

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Brian Foster

If freesp == 0, we could end up in an infinite loop while squashing the preallocation. Break the loop when we've killed the prealloc entirely.

Looks good.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs