Commit 3f9e7949 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] valid_swaphandles() fix

akpm draws my attention to the fact that sysctl(VM_PAGE_CLUSTER) might
conceivably change page_cluster to 0 while valid_swaphandles() is in the
middle of using it, leading to an embarrassingly long loop: take a local
snapshot of page_cluster and work with that.
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2d1d43f6
...@@ -1723,13 +1723,14 @@ get_swap_info_struct(unsigned type) ...@@ -1723,13 +1723,14 @@ get_swap_info_struct(unsigned type)
*/ */
int valid_swaphandles(swp_entry_t entry, unsigned long *offset) int valid_swaphandles(swp_entry_t entry, unsigned long *offset)
{ {
int ret = 0, i = 1 << page_cluster; int our_page_cluster = page_cluster;
int ret = 0, i = 1 << our_page_cluster;
unsigned long toff; unsigned long toff;
struct swap_info_struct *swapdev = swp_type(entry) + swap_info; struct swap_info_struct *swapdev = swp_type(entry) + swap_info;
if (!page_cluster) /* no readahead */ if (!our_page_cluster) /* no readahead */
return 0; return 0;
toff = (swp_offset(entry) >> page_cluster) << page_cluster; toff = (swp_offset(entry) >> our_page_cluster) << our_page_cluster;
if (!toff) /* first page is swap header */ if (!toff) /* first page is swap header */
toff++, i--; toff++, i--;
*offset = toff; *offset = toff;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment