block: rescan partitions on invalidated devices on -ENOMEDIA too
authorTejun Heo <tj@kernel.org>
Fri, 29 Apr 2011 08:15:20 +0000 (10:15 +0200)
committerSteve Conklin <sconklin@canonical.com>
Fri, 15 Jul 2011 17:20:49 +0000 (12:20 -0500)
commit1e929d2534e96286ccde24c0eb4afcd00aa05d75
treeb0fe4cc4f8695c6e2faac06ba7e7ff1708dc1b93
parent2b4208383d114d202d38eb3b04ff7b844de8eefa
block: rescan partitions on invalidated devices on -ENOMEDIA too

BugLink: http://bugs.launchpad.net/bugs/793702

commit 02e352287a40bd456eb78df705bf888bc3161d3f upstream.

__blkdev_get() doesn't rescan partitions if disk->fops->open() fails,
which leads to ghost partition devices lingering after medimum removal
is known to both the kernel and userland.  The behavior also creates a
subtle inconsistency where O_NONBLOCK open, which doesn't fail even if
there's no medium, clears the ghots partitions, which is exploited to
work around the problem from userland.

Fix it by updating __blkdev_get() to issue partition rescan after
-ENOMEDIA too.

This was reported in the following bz.

 https://bugzilla.kernel.org/show_bug.cgi?id=13029

Stable: 2.6.38

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: David Zeuthen <zeuthen@gmail.com>
Reported-by: Martin Pitt <martin.pitt@ubuntu.com>
Reported-by: Kay Sievers <kay.sievers@vrfy.org>
Tested-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
fs/block_dev.c