]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
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)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 2 Dec 2008 23:50:40 +0000 (15:50 -0800)
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>
mm/backing-dev.c

index f2e574dbc30089d778880d2ad178d5dd48174034..2a56124dbc28effcbda0a48c2268d1b7f763ee91 100644 (file)
@@ -176,6 +176,9 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
        int ret = 0;
        struct device *dev;
 
+       if (WARN_ON(bdi->dev))
+               goto exit;
+
        va_start(args, fmt);
        dev = device_create_vargs(bdi_class, parent, MKDEV(0, 0), bdi, fmt, args);
        va_end(args);