[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.1 / 0020-ore-fix-BUG_ON-too-few-sgs-when-reading.patch
1 From 3c8f1a35fab7418f9afeda2618992c1fd5504475 Mon Sep 17 00:00:00 2001
2 From: Boaz Harrosh <bharrosh@panasas.com>
3 Date: Wed, 28 Dec 2011 19:14:23 +0200
4 Subject: [PATCH 20/49] ore: fix BUG_ON, too few sgs when reading
6 commit 361aba569f55dd159b850489a3538253afbb3973 upstream.
8 When reading RAID5 files, in rare cases, we calculated too
9 few sg segments. There should be two extra for the beginning
10 and end partial units.
12 Also "too few sg segments" should not be a BUG_ON there is
13 all the mechanics in place to handle it, as a short read.
14 So just return -ENOMEM and the rest of the code will gracefully
15 split the IO.
17 Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
19 ---
20 fs/exofs/ore.c | 2 +-
21 fs/exofs/ore_raid.c | 6 +++++-
22 2 files changed, 6 insertions(+), 2 deletions(-)
24 diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c
25 index 894f3e1..49cf230 100644
26 --- a/fs/exofs/ore.c
27 +++ b/fs/exofs/ore.c
28 @@ -266,7 +266,7 @@ int ore_get_rw_state(struct ore_layout *layout, struct ore_components *oc,
30 /* first/last seg is split */
31 num_raid_units += layout->group_width;
32 - sgs_per_dev = div_u64(num_raid_units, data_devs);
33 + sgs_per_dev = div_u64(num_raid_units, data_devs) + 2;
34 } else {
35 /* For Writes add parity pages array. */
36 max_par_pages = num_raid_units * pages_in_unit *
37 diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
38 index 29c47e5..414a2df 100644
39 --- a/fs/exofs/ore_raid.c
40 +++ b/fs/exofs/ore_raid.c
41 @@ -551,7 +551,11 @@ int _ore_add_parity_unit(struct ore_io_state *ios,
42 unsigned cur_len)
43 {
44 if (ios->reading) {
45 - BUG_ON(per_dev->cur_sg >= ios->sgs_per_dev);
46 + if (per_dev->cur_sg >= ios->sgs_per_dev) {
47 + ORE_DBGMSG("cur_sg(%d) >= sgs_per_dev(%d)\n" ,
48 + per_dev->cur_sg, ios->sgs_per_dev);
49 + return -ENOMEM;
50 + }
51 _ore_add_sg_seg(per_dev, cur_len, true);
52 } else {
53 struct __stripe_pages_2d *sp2d = ios->sp2d;
54 --
55 1.7.7.4