Skip to content

Commit

Permalink
pstore/ram: Include ecc_size when calculating ecc_block
Browse files Browse the repository at this point in the history
Wastes less memory and allows using more memory for ecc than data.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
[jstultz: Tweaked commit subject]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
  • Loading branch information
Arve Hjønnevåg authored and Anton Vorontsov committed Apr 4, 2013
1 parent c530267 commit 422ca86
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/pstore/ram_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 422ca86

Please sign in to comment.