From 422ca8608c49d1e9bfed1c58a1ca448a8a38c0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Date: Tue, 20 Mar 2012 16:01:31 -0700 Subject: pstore/ram: Include ecc_size when calculating ecc_block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wastes less memory and allows using more memory for ecc than data. Signed-off-by: Arve Hjønnevåg [jstultz: Tweaked commit subject] Signed-off-by: John Stultz Acked-by: Kees Cook Signed-off-by: Anton Vorontsov diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index 0306303..e5afa22 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -187,7 +187,8 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz, prz->ecc_block_size = 128; prz->ecc_size = ecc_size; - ecc_blocks = DIV_ROUND_UP(prz->buffer_size, prz->ecc_block_size); + ecc_blocks = DIV_ROUND_UP(prz->buffer_size - prz->ecc_size, + prz->ecc_block_size + prz->ecc_size); ecc_total = (ecc_blocks + 1) * prz->ecc_size; if (ecc_total >= prz->buffer_size) { pr_err("%s: invalid ecc_size %u (total %zu, buffer size %zu)\n", -- cgit v0.10.2