Re: [PATCH v2 02/26] block: Annotate the block device functions

Marco Elver
2026-03-27T18:18:06Z

On Thu, 26 Mar 2026 at 16:55, Bart Van Assche <bvanassche@acm.org> wrote:
>
> On 3/25/26 11:25 PM, Christoph Hellwig wrote:
> > On Wed, Mar 25, 2026 at 02:44:43PM -0700, Bart Van Assche wrote:
> >> mutex_lock(&bdev->bd_holder_lock);
> >> - if (bdev->bd_holder_ops && bdev->bd_holder_ops->mark_dead)
> >> + if (bdev->bd_holder_ops && bdev->bd_holder_ops->mark_dead) {
> >> bdev->bd_holder_ops->mark_dead(bdev, surprise);
> >> - else {
> >> + /* bdev->bd_holder_ops->mark_dead() released bd_holder_lock */
> >> + __release(&bdev->bd_holder_lock);
> >
> > This sounds like ->mark_dead also needs matching annotations. Or
> > can we have a way to annotate the expexcted lock context changes on
> > indirect function calls, as that would be very useful in general.
>
> (+Marco)
>
> Agreed that this would be useful.
>
> Marco, is my understanding correct that Clang does not yet support
> adding lock context annotations to function pointers and hence that
> adding this support would require modifying the Clang compiler?

No that's not supported (yet). There are various design options, each
with their own pros/cons: the one question is if attributes should
behave more like type qualifiers in this case (enforces functions to
match), or just be a best-effort thing (functions may not match
function pointer).