Linux-Raid Archives mirror
 help / color / mirror / Atom feed
From: tada keisuke <keisuke1.tada@kioxia.com>
To: "song@kernel.org" <song@kernel.org>,
	"yukuai3@huawei.com" <yukuai3@huawei.com>
Cc: "linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 04/11] md: minimize execution of zero check for nr_pending
Date: Tue, 26 Mar 2024 10:29:31 +0000	[thread overview]
Message-ID: <5319159bd74f4c4c9979c748b216b2f8@kioxia.com> (raw)

This patch depends on patch 02.

The Faulty flag is required for the if statement to be true.
A rdev in Faulty state does not issue I/O commands.
So, nr_pending is also not increased.
Therefore, decrement and zero check of nr_pending can be separated and still be consistent.

Signed-off-by: Keisuke TADA <keisuke1.tada@kioxia.com>
Signed-off-by: Toshifumi OHTAKE <toshifumi.ootake@kioxia.com>
---
 drivers/md/md.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/md/md.h b/drivers/md/md.h
index b990be0981bc..ed7e36212d58 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -236,11 +236,6 @@ static inline unsigned int nr_pending_read(struct md_rdev *rdev)
 	return atomic_read(&rdev->nr_pending);
 }
 
-static inline bool nr_pending_dec_and_test(struct md_rdev *rdev)
-{
-	return atomic_dec_and_test(&rdev->nr_pending);
-}
-
 static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors,
 			      sector_t *first_bad, int *bad_sectors)
 {
@@ -875,9 +870,12 @@ static inline bool is_rdev_broken(struct md_rdev *rdev)
 static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
 {
 	int faulty = test_bit(Faulty, &rdev->flags);
-	if (nr_pending_dec_and_test(rdev) && faulty) {
-		set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
-		md_wakeup_thread(mddev->thread);
+	nr_pending_dec(rdev);
+	if (faulty) {
+		if (nr_pending_is_zero(rdev)) {
+			set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
+			md_wakeup_thread(mddev->thread);
+		}
 	}
 }
 
-- 
2.34.1


                 reply	other threads:[~2024-03-26 12:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5319159bd74f4c4c9979c748b216b2f8@kioxia.com \
    --to=keisuke1.tada@kioxia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).