Re: [PATCH RESEND v4 1/4] kernfs: make ->attr.open RCU protected.

From: Tejun Heo
Date: Mon Jun 13 2022 - 15:16:21 EST


On Mon, Jun 13, 2022 at 01:56:43PM +1000, Imran Khan wrote:
> Agree. I did over think this and went for the safest interface that I could
> think of in each of the use cases. I will remove
> kernfs_check_open_node_protected and use kernfs_deref_open_node_protected in its
> place as well. This will cover all accesses under kernfs_open_file_mutex.
>
> But we will still need kernfs_deref_open_node for cases where
> !list_empty(&of->list) ensures safe access of ->attr.open and where we can't
> ensure holding of kernfs_open_file_mutex. So we will need 2 deref accessors.
> Right? Just asking this because you mentioned above to come up with one deref
> accessor that can be used in all three use cases
>
> Please let me if this sounds okay. I can send updated patch-set with these
> changes in place.

Just merge all three into one accessor. You can list both the !list_empty
condition and lock held conditions on the same rcu_dereference_check() call.

Thanks.

--
tejun