Re: [PATCH v6 2/3] zram: fix deadlock with sysfs attribute usage and module removal

From: Luis Chamberlain
Date: Tue Jul 27 2021 - 13:35:23 EST

On Fri, Jul 23, 2021 at 10:49:19AM -0700, Luis Chamberlain wrote:
> We are talking about sysfs files and you're argument is that
> try_module_get() should lock the module, and so cannot be used
> in sysfs files. My point is that such module lock is inferred:
> 1) Sysfs files are created by a module, that same module is responsible
> for removing the same sysfs files.
> 2) The module can only be removed and gone, once *all* sysfs files are
> removed first.
> 3) If any of the module's sysfs files are present the module must
> still be present
> 4) kernfs ensures that if a file is opened the file will not be
> removed until any pending operation completes
> 5) If a sysfs file is used to write something, that means the
> sysfs file has not yet been removed, and we know it will
> remain in existance throughout its entire operation
> 6) When a sysfs file operation is being run, the module must
> always exist


I'm inclined to believe my original generic solution would be better
again [0]. Specially since we can drop the dev_type_get() / dev_type_put()