]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.14.44/md-raid0-fix-restore-to-sector-variable-in-raid0_make_request.patch
drop queue-4.14/mips-make-sure-dt-memory-regions-are-valid.patch
[thirdparty/kernel/stable-queue.git] / releases / 3.14.44 / md-raid0-fix-restore-to-sector-variable-in-raid0_make_request.patch
1 From a81157768a00e8cf8a7b43b5ea5cac931262374f Mon Sep 17 00:00:00 2001
2 From: Eric Work <work.eric@gmail.com>
3 Date: Mon, 18 May 2015 23:26:23 -0700
4 Subject: md/raid0: fix restore to sector variable in raid0_make_request
5
6 From: Eric Work <work.eric@gmail.com>
7
8 commit a81157768a00e8cf8a7b43b5ea5cac931262374f upstream.
9
10 The variable "sector" in "raid0_make_request()" was improperly updated
11 by a call to "sector_div()" which modifies its first argument in place.
12 Commit 47d68979cc968535cb87f3e5f2e6a3533ea48fbd restored this variable
13 after the call for later re-use. Unfortunetly the restore was done after
14 the referenced variable "bio" was advanced. This lead to the original
15 value and the restored value being different. Here we move this line to
16 the proper place.
17
18 One observed side effect of this bug was discarding a file though
19 unlinking would cause an unrelated file's contents to be discarded.
20
21 Signed-off-by: NeilBrown <neilb@suse.de>
22 Fixes: 47d68979cc96 ("md/raid0: fix bug with chunksize not a power of 2.")
23 URL: https://bugzilla.kernel.org/show_bug.cgi?id=98501
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 drivers/md/raid0.c | 4 +++-
28 1 file changed, 3 insertions(+), 1 deletion(-)
29
30 --- a/drivers/md/raid0.c
31 +++ b/drivers/md/raid0.c
32 @@ -531,6 +531,9 @@ static void raid0_make_request(struct md
33 ? (sector & (chunk_sects-1))
34 : sector_div(sector, chunk_sects));
35
36 + /* Restore due to sector_div */
37 + sector = bio->bi_iter.bi_sector;
38 +
39 if (sectors < bio_sectors(bio)) {
40 split = bio_split(bio, sectors, GFP_NOIO, fs_bio_set);
41 bio_chain(split, bio);
42 @@ -538,7 +541,6 @@ static void raid0_make_request(struct md
43 split = bio;
44 }
45
46 - sector = bio->bi_iter.bi_sector;
47 zone = find_zone(mddev->private, &sector);
48 tmp_dev = map_sector(mddev, zone, sector, &sector);
49 split->bi_bdev = tmp_dev->bdev;