[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1406382514-8662-3-git-send-email-tytso@mit.edu>
Date: Sat, 26 Jul 2014 09:48:30 -0400
From: Theodore Ts'o <tytso@....edu>
To: Ext4 Developers List <linux-ext4@...r.kernel.org>
Cc: Theodore Ts'o <tytso@....edu>
Subject: [PATCH 2/6] libext2fs: fix rb_resize_bmap to handle the padding bits
The bits between end and real_end are set as a safety measure for the
kernel when it uses the bit scan instructions. We need to take this
into account when shrinking or growing the block allocation bitmap,
before we can safely use rbtree bitmaps in resize2fs.
Signed-off-by: Theodore Ts'o <tytso@....edu>
---
lib/ext2fs/blkmap64_rb.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c
index a1dde6d..fdbd330 100644
--- a/lib/ext2fs/blkmap64_rb.c
+++ b/lib/ext2fs/blkmap64_rb.c
@@ -299,21 +299,19 @@ static errcode_t rb_resize_bmap(ext2fs_generic_bitmap bmap,
{
struct ext2fs_rb_private *bp;
- if (new_real_end >= bmap->real_end) {
- bmap->end = new_end;
- bmap->real_end = new_real_end;
- return 0;
- }
-
bp = (struct ext2fs_rb_private *) bmap->private;
bp->rcursor = NULL;
bp->wcursor = NULL;
- /* truncate tree to new_real_end size */
- rb_truncate(new_real_end, &bp->root);
+ rb_truncate(((new_end < bmap->end) ? new_end : bmap->end) - bmap->start,
+ &bp->root);
bmap->end = new_end;
bmap->real_end = new_real_end;
+
+ if (bmap->end < bmap->real_end)
+ rb_insert_extent(bmap->end + 1 - bmap->start,
+ bmap->real_end - bmap->end, bp);
return 0;
}
--
2.0.0
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists