• Alexander Viro's avatar
    [PATCH] blkdev_put() data corruption · 31fc3053
    Alexander Viro authored
    	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...
    31fc3053
block_dev.c 21.3 KB