Re: bdi: register sysfs bdi device only once per queue

From: Peter Zijlstra
Date: Mon Nov 03 2008 - 11:08:42 EST


On Mon, 2008-11-03 at 16:53 +0100, Kay Sievers wrote:
> Andrew, can you pick this up this please?
>
> Thanks,
> Kay
>
>
> From: Kay Sievers <kay.sievers@xxxxxxxx>
> Subject: bdi: register sysfs bdi device only once per queue
>
> 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.

David, is there any reason the mtd devices do this?

> 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.
>
> Tested-By: Peter Korsgaard <jacmet@xxxxxxxxxx>
> Acked-By: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> Signed-Off-By: Kay Sievers <kay.sievers@xxxxxxxx>
> ---
>
> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index f2e574d..e6676e5 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -176,6 +176,9 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
> int ret = 0;
> struct device *dev;
>
> + if (bdi->dev)
> + goto exit;
> +
> va_start(args, fmt);
> dev = device_create_vargs(bdi_class, parent, MKDEV(0, 0), bdi, fmt, args);
> va_end(args);

Would it make sense to make it print something like, please fix me?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/