Sergey SENOZHATSKY 1237275580 zram: keep the exact overcommited value in mem_used_max
`mem_used_max' is designed to store the max amount of memory zram consumed
to store the data.  However, it does not represent the actual
'overcommited' (max) value.  The existing code goes to -ENOMEM
overcommited case before it updates `->stats.max_used_pages', which hides
the reason we went to -ENOMEM in the first place -- we actually used more
memory than `->limit_pages':

        alloced_pages = zs_get_total_pages(meta->mem_pool);
        if (zram->limit_pages && alloced_pages > zram->limit_pages) {
                zs_free(meta->mem_pool, handle);
                ret = -ENOMEM;
                goto out;
        }

        update_used_max(zram, alloced_pages);

Which is misleading.  User will see -ENOMEM, check `->limit_pages', check
`->stats.max_used_pages', which will keep the value BEFORE zram passed
`->limit_pages', and see:
	`->stats.max_used_pages' < `->limit_pages'

Move update_used_max() before we do `->limit_pages' check, so that
user will see:
	`->stats.max_used_pages' > `->limit_pages'
should the overcommit and -ENOMEM happen.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 17:50:42 -08:00
..
2015-11-04 21:50:37 -08:00
2015-11-04 21:50:37 -08:00
2015-11-05 23:38:43 -08:00
2015-11-05 23:38:43 -08:00
2015-11-02 00:54:37 +01:00
2015-11-04 22:15:15 -08:00
2015-11-05 13:15:12 -08:00
2015-11-05 13:15:12 -08:00
2015-11-05 13:15:12 -08:00
2015-11-05 13:15:12 -08:00
2015-11-05 13:15:12 -08:00
2015-10-29 09:02:16 +09:00
2015-11-04 22:15:15 -08:00
2015-11-05 13:15:12 -08:00
2015-11-05 13:15:12 -08:00
2015-11-04 21:50:37 -08:00
2015-10-22 15:45:18 +02:00
2015-11-04 14:47:13 -08:00
2015-11-04 21:26:27 -08:00
2015-11-06 10:23:50 -08:00
2015-11-06 10:23:50 -08:00
2015-11-05 13:15:12 -08:00
2015-11-04 22:15:15 -08:00
2015-10-21 17:02:13 +02:00
2015-11-05 13:15:12 -08:00
2015-11-04 21:50:37 -08:00
2015-10-27 20:17:03 -07:00
2015-11-04 22:15:15 -08:00
2015-11-04 22:15:15 -08:00
2015-11-04 22:15:15 -08:00