aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2022-08-11 11:14:17 -0600
committerSong Liu <song@kernel.org>2022-09-22 00:05:04 -0700
commitf9287c3e93f00d3236c4c81bf76dae43afd903b9 (patch)
tree5e8e54d42d7422880e21544f665c88b7353b9fe9 /drivers/md
parentmd/raid5: Cleanup prototype of raid5_get_active_stripe() (diff)
downloadlinux-dev-f9287c3e93f00d3236c4c81bf76dae43afd903b9.tar.xz
linux-dev-f9287c3e93f00d3236c4c81bf76dae43afd903b9.zip
md/raid5: Don't read ->active_stripes if it's not needed
The atomic_read() is not needed in many cases so only do the read after the first checks are done. Suggested-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Song Liu <song@kernel.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid5.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 84f941843364..e0514bda7695 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -789,15 +789,14 @@ struct stripe_request_ctx {
*/
static bool is_inactive_blocked(struct r5conf *conf, int hash)
{
- int active = atomic_read(&conf->active_stripes);
-
if (list_empty(conf->inactive_list + hash))
return false;
if (!test_bit(R5_INACTIVE_BLOCKED, &conf->cache_state))
return true;
- return active < (conf->max_nr_stripes * 3 / 4);
+ return (atomic_read(&conf->active_stripes) <
+ (conf->max_nr_stripes * 3 / 4));
}
struct stripe_head *raid5_get_active_stripe(struct r5conf *conf,