md/raid5: Annotate rdev/replacement access when mddev_lock is held
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 7 Apr 2022 16:57:11 +0000 (10:57 -0600)
committerSong Liu <song@kernel.org>
Mon, 25 Apr 2022 21:00:37 +0000 (14:00 -0700)
commit9aeb7f99a134391e19ffad926cfb6a60d72139b4
treefcb2625caff1868e4d18280dc18c8d02bd49a709
parente38b0432550507a78d63c8da094e5f50820bdf92
md/raid5: Annotate rdev/replacement access when mddev_lock is held

The mddev_lock should be held during raid5_remove_disk() which is when
the rdev/replacement pointers are modified. So any access to these
pointers marked __rcu should be safe whenever the mddev_lock is held.

There are numerous such access that currently produce sparse warnings.
Add a helper function, rdev_mdlock_deref() that wraps
rcu_dereference_protected() in all these instances.

This annotation fixes a number of sparse warnings.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Song Liu <song@kernel.org>
drivers/md/raid5.c