Skip to contentSkip to conversation

gfs2: Fix gfs2_testbit to use clone bitmaps

PATCH Superseded Bob Peterson 1 participant 1 message Jul 10, 2018 1 message not in the archive GFS2 file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 gfs2: Fix gfs2_testbit to use clone bitmaps

In reply to a message not in the archive

Hi,

Function gfs2_testbit is called in three places. Two of those places, gfs2_alloc_extent and gfs2_unaligned_extlen, should be using the clone bitmaps, not the "real" bitmaps. Function gfs2_unaligned_extlen is used by the block reservations scheme to determine the length of an extent of free blocks. Before this patch, it wasn't using the clone bitmap, which means soon-to-be-freed blocks will be treated as free blocks for the purposes of an extent, and that's clearly wrong.

---
 fs/gfs2/rgrp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/gfs2/rgrp.c +3 -1
index 3821b3ab04fa..b248e83f5525 100644
@@ -130,10 +130,12 @@ static inline void gfs2_setbit(const struct gfs2_rbm *rbm, bool do_clone,
 static inline u8 gfs2_testbit(const struct gfs2_rbm *rbm)
 {
 	struct gfs2_bitmap *bi = rbm_bi(rbm);
-	const u8 *buffer = bi->bi_bh->b_data + bi->bi_offset;
+	const u8 *buffer;
 	const u8 *byte;
 	unsigned int bit;
 
+	buffer = bi->bi_clone ? bi->bi_clone : bi->bi_bh->b_data;
+	buffer += bi->bi_offset;
 	byte = buffer + (rbm->offset / GFS2_NBBY);
 	bit = (rbm->offset % GFS2_NBBY) * GFS2_BIT_SIZE;