Skip to contentSkip to conversation

gfs2: Fix loop in gfs2_rbm_find

PATCH New Andreas Gruenbacher 1 participant 2 messages Dec 4, 2018

Subsystems (2)
lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Fix loop in gfs2_rbm_find

In gfs2_rbm_find, fix the resource group wrap-around logic that commit e579ed4f44 broke. Without this fix, gfs2_rbm_find can end up in an infinite loop in the worst case.

Fixes e579ed4f44 ("GFS2: Introduce rbm field bii")
Cc stable at vger.kernel.org # v3.13+
---
 fs/gfs2/rgrp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/rgrp.c +1 -1
index b08a530433adf..8d79165703621 100644
@@ -1780,9 +1780,9 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext,
 			goto next_iter;
 		}
 		if (ret == -E2BIG) {
+			n += rbm->bii - initial_bii;
 			rbm->bii = 0;
 			rbm->offset = 0;
-			n += (rbm->bii - initial_bii);
 			goto res_covered_end_of_rgrp;
 		}
 		return ret;
Signature · 1 line
2.19.1.546.g028f9c799.dirty
author maintainer
#1 lore raw

PATCH 1/1 gfs2: Fix loop in gfs2_rbm_find

Quoted 4 lines · Andreas Gruenbacher

In gfs2_rbm_find, fix the resource group wrap-around logic that commit e579ed4f44 broke. Without this fix, gfs2_rbm_find can end up in an infinite loop in the worst case.

After some more review, it seems that the current mechanism of exclusive resource group locking and the combination of how gfs2_inplace_reserve and gfs2_alloc_blocks invoke gfs2_rbm_find prevents an infinite loop in gfs2_rbm_find. This fix still prevents unnecessary bitmap scanning though.

Andreas