From: Namhyung Kim <namhyung@gmail.com>
To: Neil Brown <neilb@suse.de>
Cc: linux-raid@vger.kernel.org
Subject: [PATCH 2/5] md/raid5: factor out dev_need_read()
Date: Wed, 22 Jun 2011 13:50:27 +0900 [thread overview]
Message-ID: <1308718230-2536-3-git-send-email-namhyung@gmail.com> (raw)
In-Reply-To: <1308718230-2536-1-git-send-email-namhyung@gmail.com>
Factor out common condition checking code to dev_need_read()
in the hope that it would improve readability somewhat.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
drivers/md/raid5.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 0f71aa9a07c5..892a95fe6e8f 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2313,6 +2313,15 @@ handle_failed_stripe(raid5_conf_t *conf, struct stripe_head *sh,
md_wakeup_thread(conf->mddev->thread);
}
+static bool dev_need_read(struct r5dev *dev)
+{
+ if (dev->toread ||
+ (dev->towrite && !test_bit(R5_OVERWRITE, &dev->flags)))
+ return true;
+
+ return false;
+}
+
/* fetch_block5 - checks the given member device to see if its data needs
* to be read or computed to satisfy a request.
*
@@ -2328,13 +2337,9 @@ static int fetch_block5(struct stripe_head *sh, struct stripe_head_state *s,
/* is the data in this block needed, and can we get it? */
if (!test_bit(R5_LOCKED, &dev->flags) &&
!test_bit(R5_UPTODATE, &dev->flags) &&
- (dev->toread ||
- (dev->towrite && !test_bit(R5_OVERWRITE, &dev->flags)) ||
+ (dev_need_read(dev) ||
s->syncing || s->expanding ||
- (s->failed &&
- (failed_dev->toread ||
- (failed_dev->towrite &&
- !test_bit(R5_OVERWRITE, &failed_dev->flags)))))) {
+ (s->failed && dev_need_read(failed_dev)))) {
/* We would like to get this block, possibly by computing it,
* otherwise read it if the backing disk is insync
*/
@@ -2401,8 +2406,7 @@ static int fetch_block6(struct stripe_head *sh, struct stripe_head_state *s,
if (!test_bit(R5_LOCKED, &dev->flags) &&
!test_bit(R5_UPTODATE, &dev->flags) &&
- (dev->toread ||
- (dev->towrite && !test_bit(R5_OVERWRITE, &dev->flags)) ||
+ (dev_need_read(dev) ||
s->syncing || s->expanding ||
(s->failed >= 1 &&
(fdev[0]->toread || s->to_write)) ||
--
1.7.5.2
next prev parent reply other threads:[~2011-06-22 4:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-22 4:50 [PATCH 0/5] misc cleanups for RAID5 Namhyung Kim
2011-06-22 4:50 ` [PATCH 1/5] md/raid5: use kmem_cache_zalloc() Namhyung Kim
2011-06-22 4:50 ` Namhyung Kim [this message]
2011-06-22 4:50 ` [PATCH 3/5] md/raid5: factor out dev_need_for_write() Namhyung Kim
2011-06-22 4:50 ` [PATCH 4/5] md/raid5: use r5_for_each_bio() Namhyung Kim
2011-06-22 4:50 ` [PATCH 5/5] md/raid5: get rid of duplicated call to bio_data_dir() Namhyung Kim
2011-06-23 0:55 ` [PATCH 0/5] misc cleanups for RAID5 NeilBrown
2011-06-23 7:30 ` Namhyung Kim
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=1308718230-2536-3-git-send-email-namhyung@gmail.com \
--to=namhyung@gmail.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/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 NNTP newsgroup(s).