]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
md/raid5: Don't read ->active_stripes if it's not needed
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 11 Aug 2022 17:14:17 +0000 (11:14 -0600)
committerSong Liu <song@kernel.org>
Thu, 22 Sep 2022 07:05:04 +0000 (00:05 -0700)
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>
drivers/md/raid5.c

index 84f9418433649788a77f72c217ff878053e6e692..e0514bda76957fae1b5ae18e5c9917cc8338ed9c 100644 (file)
@@ -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,