| 317 | } |
| 318 | |
| 319 | NTSTATUS |
| 320 | Ext2FlushVcb(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 |
no test coverage detected