]> git.hungrycats.org Git - linux/commit
[PATCH] blkdev_put() data corruption
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Tue, 17 Feb 2004 08:49:03 +0000 (00:49 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Tue, 17 Feb 2004 08:49:03 +0000 (00:49 -0800)
commit31fc305350a860bbe8d2aed6c707a7edc66aa049
treec5fe0b908147f6c7a9670949649562a07e44478b
parentd6c561cedcbd025198ce21731ccc1eae70e10a3d
[PATCH] blkdev_put() data corruption

We used to have sync_blockdev() on each normal (== non-raw)
blkdev_put() + kill_bdev() on the final blkdev_put().  That worked
fine until we'd moved sync_blockdev() to the final blkdev_put().

Now we have a nasty scenario:

open block device
open raw device
write on block device # data ends up in cache
close block device # no sync here, we still have the sucker opened
close raw device # no sync here either
# ... and cache is killed by kill_bdev()

IOW, if we postpone sync to final close, we must do it regardless of
kind of close.  Otherwise we are in for data corruption and yes, it is easy
to trigger.  Fix is obvious...
fs/block_dev.c