MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / Ext2FreeBlock

Function Ext2FreeBlock

Ext4Fsd/ext3/generic.c:1173–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1171}
1172
1173NTSTATUS
1174Ext2FreeBlock(
1175 IN PEXT2_IRP_CONTEXT IrpContext,
1176 IN PEXT2_VCB Vcb,
1177 IN ULONG Block,
1178 IN ULONG Number
1179)
1180{
1181 struct super_block *sb = &Vcb->sb;
1182 PEXT2_GROUP_DESC gd;
1183 struct buffer_head *gb = NULL;
1184 struct buffer_head bh;
1185 ext4_fsblk_t bitmap_blk;
1186
1187 RTL_BITMAP BlockBitmap;
1188 LARGE_INTEGER Offset;
1189
1190 PBCB BitmapBcb;
1191 PVOID BitmapCache;
1192
1193 ULONG Group;
1194 ULONG Index;
1195 ULONG Length;
1196 ULONG Count;
1197
1198 NTSTATUS Status = STATUS_UNSUCCESSFUL;
1199
1200 ExAcquireResourceExclusiveLite(&Vcb->MetaBlock, TRUE);
1201
1202 DEBUG(DL_INF, ("Ext2FreeBlock: Block %xh - %x to be freed.\n",
1203 Block, Block + Number));
1204
1205 Group = (Block - EXT2_FIRST_DATA_BLOCK) / BLOCKS_PER_GROUP;
1206 Index = (Block - EXT2_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
1207
1208Again:
1209
1210 if (gb)
1211 fini_bh(&gb);
1212
1213 if ( Block < EXT2_FIRST_DATA_BLOCK ||
1214 Block >= TOTAL_BLOCKS ||
1215 Group >= Vcb->sbi.s_groups_count) {
1216
1217 DbgBreak();
1218 Status = STATUS_SUCCESS;
1219
1220 } else {
1221
1222 gd = ext4_get_group_desc(sb, Group, &gb);
1223 if (!gd) {
1224 DbgBreak();
1225 Status = STATUS_INSUFFICIENT_RESOURCES;
1226 goto errorout;
1227 }
1228 bitmap_blk = ext4_block_bitmap(sb, gd);
1229
1230 /* check the block is valid or not */

Callers 5

Ext2ExpandLastFunction · 0.85
Ext2TruncateBlockFunction · 0.85
Ext2TruncateIndirectFastFunction · 0.85
ext4_free_blocksFunction · 0.85
ext4_free_blocksFunction · 0.85

Calls 9

fini_bhFunction · 0.85
ext4_get_group_descFunction · 0.85
ext4_block_bitmapFunction · 0.85
ext4_free_blks_setFunction · 0.85
Ext2AddVcbExtentFunction · 0.85
Ext2SaveGroupFunction · 0.85
Ext2RemoveBlockExtentFunction · 0.85
Ext2UpdateVcbStatFunction · 0.85

Tested by

no test coverage detected