]> git.karo-electronics.de Git - karo-tx-linux.git/commit
block: Fix race during disk initialization
authorJan Kara <jack@suse.cz>
Thu, 16 Sep 2010 18:36:36 +0000 (20:36 +0200)
committerAndi Kleen <ak@linux.intel.com>
Tue, 14 Dec 2010 22:40:00 +0000 (23:40 +0100)
commit381709fcb98acf7803be64ceab5e49e2fc0dbbdb
tree0cbb5565c3b3b034dff5a92026c2ff3b0756ae59
parent97d388bb0a4d7e5acc7274645382adac50260096
block: Fix race during disk initialization

commit 01ea50638bc04ca5259f5711fcdedefcdde1cf43 upstream.

When a new disk is being discovered, add_disk() first ties the bdev to gendisk
(via register_disk()->blkdev_get()) and only after that calls
bdi_register_bdev(). Because register_disk() also creates disk's kobject, it
can happen that userspace manages to open and modify the device's data (or
inode) before its BDI is properly initialized leading to a warning in
__mark_inode_dirty().

Fix the problem by registering BDI early enough.

This patch addresses https://bugzilla.kernel.org/show_bug.cgi?id=16312

Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
block/genhd.c