From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, Yuanhan Liu <yuanhan.liu@linux.intel.com>
Subject: [PATCH 2/4] raid10: change the code layout of raid10_mergeable_bvec() to make it look a bit nicer
Date: Thu, 31 May 2012 18:18:46 +0800 [thread overview]
Message-ID: <1338459528-24490-2-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1338459528-24490-1-git-send-email-yuanhan.liu@linux.intel.com>
This don't fix anything but just make function raid10_mergeable_bvec
look a bit nicer.
Minro note: this make 3 lines exceed 80 a bit(81).
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
drivers/md/raid10.c | 74 ++++++++++++++++++++++++--------------------------
1 files changed, 36 insertions(+), 38 deletions(-)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 987db37..83d0e65 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -626,6 +626,8 @@ static int raid10_mergeable_bvec(struct request_queue *q,
unsigned int chunk_sectors;
unsigned int bio_sectors = bvm->bi_size >> 9;
struct geom *geo = &conf->geo;
+ struct r10bio r10_bio;
+ int s;
chunk_sectors = (conf->geo.chunk_mask & conf->prev.chunk_mask) + 1;
if (conf->reshape_progress != MaxSector &&
@@ -644,48 +646,44 @@ static int raid10_mergeable_bvec(struct request_queue *q,
} else
max = biovec->bv_len;
- if (mddev->merge_check_needed) {
- struct r10bio r10_bio;
- int s;
- if (conf->reshape_progress != MaxSector) {
- /* Cannot give any guidance during reshape */
- if (max <= biovec->bv_len && bio_sectors == 0)
- return biovec->bv_len;
- return 0;
- }
- r10_bio.sector = sector;
- raid10_find_phys(conf, &r10_bio);
- rcu_read_lock();
- for (s = 0; s < conf->copies; s++) {
- int disk = r10_bio.devs[s].devnum;
- struct md_rdev *rdev = rcu_dereference(
- conf->mirrors[disk].rdev);
- if (rdev && !test_bit(Faulty, &rdev->flags)) {
- struct request_queue *q =
- bdev_get_queue(rdev->bdev);
- if (q->merge_bvec_fn) {
- bvm->bi_sector = r10_bio.devs[s].addr
- + rdev->data_offset;
- bvm->bi_bdev = rdev->bdev;
- max = min(max, q->merge_bvec_fn(
- q, bvm, biovec));
- }
+ if (!mddev->merge_check_needed)
+ return max;
+
+ if (conf->reshape_progress != MaxSector) {
+ /* Cannot give any guidance during reshape */
+ if (max <= biovec->bv_len && bio_sectors == 0)
+ return biovec->bv_len;
+ return 0;
+ }
+
+ r10_bio.sector = sector;
+ raid10_find_phys(conf, &r10_bio);
+ rcu_read_lock();
+ for (s = 0; s < conf->copies; s++) {
+ int disk = r10_bio.devs[s].devnum;
+ struct md_rdev *rdev = rcu_dereference(conf->mirrors[disk].rdev);
+ if (rdev && !test_bit(Faulty, &rdev->flags)) {
+ struct request_queue *q = bdev_get_queue(rdev->bdev);
+ if (q->merge_bvec_fn) {
+ bvm->bi_sector = r10_bio.devs[s].addr +
+ rdev->data_offset;
+ bvm->bi_bdev = rdev->bdev;
+ max = min(max, q->merge_bvec_fn(q, bvm, biovec));
}
- rdev = rcu_dereference(conf->mirrors[disk].replacement);
- if (rdev && !test_bit(Faulty, &rdev->flags)) {
- struct request_queue *q =
- bdev_get_queue(rdev->bdev);
- if (q->merge_bvec_fn) {
- bvm->bi_sector = r10_bio.devs[s].addr
- + rdev->data_offset;
- bvm->bi_bdev = rdev->bdev;
- max = min(max, q->merge_bvec_fn(
- q, bvm, biovec));
- }
+ }
+ rdev = rcu_dereference(conf->mirrors[disk].replacement);
+ if (rdev && !test_bit(Faulty, &rdev->flags)) {
+ struct request_queue *q = bdev_get_queue(rdev->bdev);
+ if (q->merge_bvec_fn) {
+ bvm->bi_sector = r10_bio.devs[s].addr +
+ rdev->data_offset;
+ bvm->bi_bdev = rdev->bdev;
+ max = min(max, q->merge_bvec_fn(q, bvm, biovec));
}
}
- rcu_read_unlock();
}
+ rcu_read_unlock();
+
return max;
}
--
1.7.7.6
next prev parent reply other threads:[~2012-05-31 10:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-31 10:18 [PATCH 1/4] raid1: change the code layout of raid1_mergeable_bvec() to make it look a bit nicer Yuanhan Liu
2012-05-31 10:18 ` Yuanhan Liu [this message]
2012-05-31 10:18 ` [PATCH 3/4] md: introduce md_rdev_merge_bvec to reduce code duplicate Yuanhan Liu
2012-05-31 10:18 ` [PATCH 4/4] md: put EXPORT_SYMBOL macro immediately after the corresponding function Yuanhan Liu
2012-06-04 3:42 ` [PATCH 1/4] raid1: change the code layout of raid1_mergeable_bvec() to make it look a bit nicer NeilBrown
2012-06-04 3:52 ` Yuanhan Liu
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=1338459528-24490-2-git-send-email-yuanhan.liu@linux.intel.com \
--to=yuanhan.liu@linux.intel.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).