Re: [PATCH 1/2] md: make devices disappear when they are no longerneeded.

From: Al Viro
Date: Mon Nov 24 2008 - 01:24:31 EST


On Mon, Nov 24, 2008 at 02:34:30PM +0900, Tejun Heo wrote:
> > Maybe...
> >
> > If genhd.c:disk_release called e.g.
> > disk->fops->final_put(disk)
> >
> > then I could possibly link in to that to destroy the md state when the
> > gendisk finally disappears.
> >
> > When I want to kill the gendisk I would call blk_unregister_region
> > directly (not through del_gendisk) to allow it to disappear.
> > If md_probe then gets called before the final_put, I'd need to
> > call blk_register_region again to re-install it.
> >
> > I think that would work.
> >
> > Would 'block_device_operations' be the right place for this
> > 'final_put' or 'final_release' ??
>
> I suppose so. Maybe just void (*release)(struct gendisk *) but Jens is
> the maintainer. Jens, what do you think?

First of all, release is already taken (with exactly that argument, BTW).
And doing that at freeing gendisk is a bad idea - md.ko might have been
long gone by the time you've got there, not to mention anything else...
IOW, it's too late; once the damn thing is not opened anymore (and nobody
is the middle of trying to open it), the module might be dead and gone,
so all uses of ->private_data and ->fops are illegal after that point.
--
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/