From: "majianpeng" <majianpeng@gmail.com>
To: Neil Brown <neilb@suse.de>
Cc: linux-raid <linux-raid@vger.kernel.org>
Subject: md/raid1:If r1bio->sectors % 8 != 0,then the memcmp and later memcpy will omit the last bio_vec.
Date: Sat, 31 Mar 2012 15:44:14 +0800 [thread overview]
Message-ID: <201203311544085318429@gmail.com> (raw)
From 72e5ad9da511689f7efe330ce5093a3df2c92738 Mon Sep 17 00:00:00 2001
From: majianpeng <majianpeng@gmail.com>
Date: Sat, 31 Mar 2012 15:36:01 +0800
Subject: [PATCH] md/raid1:If r1bio->sectors % 8 != 0,then the memcmp and
later memcpy will omit the last bio_vec.
Signed-off-by: majianpeng <majianpeng@gmail.com>
---
drivers/md/raid1.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4a40a20..11a28ca 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1711,7 +1711,7 @@ static int process_checks(struct r1bio *r1_bio)
struct mddev *mddev = r1_bio->mddev;
struct r1conf *conf = mddev->private;
int primary;
- int i;
+ int i, vcnt;
for (primary = 0; primary < conf->raid_disks * 2; primary++)
if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
@@ -1721,9 +1721,9 @@ static int process_checks(struct r1bio *r1_bio)
break;
}
r1_bio->read_disk = primary;
+ vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
for (i = 0; i < conf->raid_disks * 2; i++) {
int j;
- int vcnt = r1_bio->sectors >> (PAGE_SHIFT- 9);
struct bio *pbio = r1_bio->bios[primary];
struct bio *sbio = r1_bio->bios[i];
int size;
@@ -1736,9 +1736,16 @@ static int process_checks(struct r1bio *r1_bio)
struct page *p, *s;
p = pbio->bi_io_vec[j].bv_page;
s = sbio->bi_io_vec[j].bv_page;
+ if ((j == vcnt - 1) &&
+ (r1_bio->sectors &
+ (PAGE_SIZE / 512 - 1)))
+ size = (r1_bio->sectors << 9)
+ - (PAGE_SIZE * j);
+ else
+ size = PAGE_SIZE;
if (memcmp(page_address(p),
page_address(s),
- PAGE_SIZE))
+ size))
break;
}
} else
@@ -2480,7 +2487,6 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp
} while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES);
bio_full:
r1_bio->sectors = nr_sectors;
-
/* For a user-requested sync, we read all readable devices and do a
* compare
*/
--
1.7.5.4
--------------
majianpeng
2012-03-31
next reply other threads:[~2012-03-31 7:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-31 7:44 majianpeng [this message]
2012-04-02 1:41 ` md/raid1:If r1bio->sectors % 8 != 0,then the memcmp and later memcpy will omit the last bio_vec NeilBrown
2012-04-05 6:12 ` Re: md/raid1:If r1bio->sectors % 8 != 0,then the memcmp and latermemcpy " kedacomkernel
2012-04-05 6:53 ` NeilBrown
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=201203311544085318429@gmail.com \
--to=majianpeng@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).