Skip to content

Commit

Permalink
bdi: register sysfs bdi device only once per queue
Browse files Browse the repository at this point in the history
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.

[[email protected]: add a WARN_ON so we know which drivers are misbehaving]
Tested-by: Peter Korsgaard <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Signed-off-by: Kay Sievers <[email protected]>
Cc: David Woodhouse <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kaysievers authored and torvalds committed Dec 2, 2008
1 parent 1b79cd0 commit f1d0b06
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/backing-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f1d0b06

Please sign in to comment.