When looking for blocks to allocate, don't limit the nuber of blocks we are
looking for by the number of available blocks: this defeats the following check
whether enough blocks are still available and it will lead to nonsensical
"0-block allocations" when a resource group is out of free blocks.

Fixes: ff7f4cb46116 ("GFS2: Consolidate free block searching functions")
Signed-off-by: Andreas Gruenbacher <[email protected]>
---
 fs/gfs2/rgrp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index d96e76e91769..dba15d25ff96 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1571,7 +1571,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct 
gfs2_inode *ip,
                extlen = 1;
        else {
                extlen = max_t(u32, atomic_read(&ip->i_sizehint), ap->target);
-               extlen = clamp(extlen, (u32)RGRP_RSRV_MINBLKS, free_blocks);
+               extlen = max_t(u32, extlen, RGRP_RSRV_MINBLKS);
        }
        if ((rgd->rd_free_clone < rgd->rd_reserved) || (free_blocks < extlen))
                return;
-- 
2.26.2

Reply via email to