Commit f278eb3
block: hold ->invalidate_lock in blkdev_fallocate
When running ->fallocate(), blkdev_fallocate() should hold
mapping->invalidate_lock to prevent page cache from being accessed,
otherwise stale data may be read in page cache.
Without this patch, blktests block/009 fails sometimes. With this patch,
block/009 can pass always.
Also as Jan pointed out, no pages can be created in the discarded area
while you are holding the invalidate_lock, so remove the 2nd
truncate_bdev_range().
Cc: Jan Kara <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>1 parent 5afedf6 commit f278eb3
1 file changed
+10
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
553 | 554 | | |
554 | 555 | | |
555 | 556 | | |
556 | | - | |
| 557 | + | |
| 558 | + | |
557 | 559 | | |
558 | 560 | | |
559 | 561 | | |
| |||
580 | 582 | | |
581 | 583 | | |
582 | 584 | | |
| 585 | + | |
| 586 | + | |
583 | 587 | | |
584 | 588 | | |
585 | 589 | | |
586 | | - | |
| 590 | + | |
587 | 591 | | |
588 | 592 | | |
589 | 593 | | |
| |||
600 | 604 | | |
601 | 605 | | |
602 | 606 | | |
603 | | - | |
| 607 | + | |
604 | 608 | | |
605 | | - | |
606 | | - | |
607 | 609 | | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
614 | 613 | | |
615 | 614 | | |
616 | 615 | | |
| |||
0 commit comments