Updated upstream Git repositories
[opendreambox.git] / meta-dreambox / recipes-kernel / linux / linux-dreambox-3.4 / 0003-mtd-block2mtd-throttle-writes-by-calling-balance_dir.patch
1 From bc8fe3e8c6424c1255a4b06ee90926ff2c9c8e7a Mon Sep 17 00:00:00 2001
2 From: NeilBrown <neilb@suse.de>
3 Date: Wed, 12 Dec 2012 19:32:15 +1100
4 Subject: [PATCH 3/4] mtd: block2mtd: throttle writes by calling
5  balance_dirty_pages_ratelimited.
6
7 If you create a block2mtd device that is larger than main memory,
8 and write to all of it, then lots of pages will be dirtied but
9 they will never be flushed out as nothing calls any variant of
10 balance_dirty_pages.
11
12 It would be nice to call set_page_dirty_balance(), but that isn't exported,
13 so just call balance_dirty_pages_ratelimited() directly.
14
15 Signed-off-by: NeilBrown <neilb@suse.de>
16 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
17 (cherry picked from commit 343efc0c553b4aa2c9370669ee4cdf27a5605185)
18 ---
19  drivers/mtd/devices/block2mtd.c | 2 ++
20  1 file changed, 2 insertions(+)
21
22 diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
23 index 401f7fd..db185e0 100644
24 --- a/drivers/mtd/devices/block2mtd.c
25 +++ b/drivers/mtd/devices/block2mtd.c
26 @@ -65,6 +65,7 @@ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len)
27                                 memset(page_address(page), 0xff, PAGE_SIZE);
28                                 set_page_dirty(page);
29                                 unlock_page(page);
30 +                               balance_dirty_pages_ratelimited(mapping);
31                                 break;
32                         }
33  
34 @@ -159,6 +160,7 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf,
35                         memcpy(page_address(page) + offset, buf, cpylen);
36                         set_page_dirty(page);
37                         unlock_page(page);
38 +                       balance_dirty_pages_ratelimited(mapping);
39                 }
40                 page_cache_release(page);
41  
42 -- 
43 2.1.4
44