bdi: register sysfs bdi device only once per queue
authorKay Sievers <kay.sievers@vrfy.org>
Tue, 2 Dec 2008 18:31:50 +0000 (10:31 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 13 Aug 2010 20:50:38 +0000 (13:50 -0700)
commite3af6cabe0a0c3f00c5b6b6a8324f8c48963c9a9
tree22647dcb05e0d743ca262fb932a3ef39624e7802
parent411643192e5ba25993b5221326abac6d96df4ad0
bdi: register sysfs bdi device only once per queue

commit f1d0b063d993527754f062c589b73f125024d216 upstream.

Devices which share the same queue, like floppies and mtd devices, get
registered multiple times in the bdi interface, but bdi accounts only the
last registered device of the devices sharing one queue.

On remove, all earlier registered devices leak, stay around in sysfs, and
cause "duplicate filename" errors if the devices are re-created.

This prevents the creation of multiple bdi interfaces per queue, and the
bdi device will carry the dev_t name of the block device which is the
first one registered, of the pool of devices using the same queue.

[akpm@linux-foundation.org: add a WARN_ON so we know which drivers are misbehaving]
Tested-by: Peter Korsgaard <jacmet@sunsite.dk>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
mm/backing-dev.c