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

Function Ext2FlushVcb

Ext4Fsd/ext3/generic.c:319–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319NTSTATUS
320Ext2FlushVcb(IN PEXT2_VCB Vcb)
321{
322 LARGE_INTEGER s = {0}, o;
323 struct ext4_sb_info *sbi = &Vcb->sbi;
324 struct rb_node *node;
325 struct buffer_head *bh;
326
327 if (!IsFlagOn(Vcb->Flags, VCB_GD_LOADED)) {
328 CcFlushCache(&Vcb->SectionObject, NULL, 0, NULL);
329 goto errorout;
330 }
331
332 ASSERT(ExIsResourceAcquiredExclusiveLite(&Vcb->MainResource));
333
334 __try {
335
336 /* acqurie gd block */
337 ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
338
339 /* acquire bd lock to avoid bh creation */
340 ExAcquireResourceExclusiveLite(&Vcb->bd.bd_bh_lock, TRUE);
341
342 /* drop unused bh */
343 Ext2DropBH(Vcb);
344
345 /* flush volume with all outstanding bh skipped */
346
347 node = rb_first(&Vcb->bd.bd_bh_root);
348 while (node) {
349
350 bh = container_of(node, struct buffer_head, b_rb_node);
351 node = rb_next(node);
352
353 o.QuadPart = bh->b_blocknr << BLOCK_BITS;
354 ASSERT(o.QuadPart >= s.QuadPart);
355
356 if (o.QuadPart == s.QuadPart) {
357 s.QuadPart = s.QuadPart + bh->b_size;
358 continue;
359 }
360
361 if (o.QuadPart > s.QuadPart) {
362 Ext2FlushRange(Vcb, s, o);
363 s.QuadPart = (bh->b_blocknr << BLOCK_BITS) + bh->b_size;
364 continue;
365 }
366 }
367
368 o = Vcb->PartitionInformation.PartitionLength;
369 Ext2FlushRange(Vcb, s, o);
370
371 } __finally {
372
373 ExReleaseResourceLite(&Vcb->bd.bd_bh_lock);
374 ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
375 }
376

Callers 2

Ext2FlushVolumeFunction · 0.85
Ext2FloppyFlushFunction · 0.85

Calls 4

Ext2DropBHFunction · 0.85
rb_firstFunction · 0.85
rb_nextFunction · 0.85
Ext2FlushRangeFunction · 0.85

Tested by

no test coverage detected