dm bufio: make the parameter "retain_bytes" unsigned long
authorMikulas Patocka <mpatocka@redhat.com>
Sun, 30 Apr 2017 21:32:28 +0000 (17:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 May 2017 12:30:08 +0000 (14:30 +0200)
commitea4889d6f39ddeb4f0ac87fc935a794db94b7895
treeab54d81629c6b46775a45627418cfa5bdee66355
parent4a9631ffe5205583800d8bdf9735381f0a09324d
dm bufio: make the parameter "retain_bytes" unsigned long

commit 13840d38016203f0095cd547b90352812d24b787 upstream.

Change the type of the parameter "retain_bytes" from unsigned to
unsigned long, so that on 64-bit machines the user can set more than
4GiB of data to be retained.

Also, change the type of the variable "count" in the function
"__evict_old_buffers" to unsigned long.  The assignment
"count = c->n_buffers[LIST_CLEAN] + c->n_buffers[LIST_DIRTY];"
could result in unsigned long to unsigned overflow and that could result
in buffers not being freed when they should.

While at it, avoid division in get_retain_buffers().  Division is slow,
we can change it to shift because we have precalculated the log2 of
block size.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-bufio.c