summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mm/swapfile.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index f8fe507be4f3..668684dc9efa 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -192,7 +192,7 @@ static bool swap_is_last_map(struct swap_info_struct *si,
unsigned char *map_end = map + nr_pages;
unsigned char count = *map;
- if (swap_count(count) != 1)
+ if (swap_count(count) != 1 && swap_count(count) != SWAP_MAP_SHMEM)
return false;
while (++map < map_end) {
@@ -1487,7 +1487,10 @@ static bool swap_entries_put_nr(struct swap_info_struct *si,
unsigned char count;
int i;
- if (nr <= 1 || swap_count(data_race(si->swap_map[offset])) != 1)
+ if (nr <= 1)
+ goto fallback;
+ count = swap_count(data_race(si->swap_map[offset]));
+ if (count != 1 && count != SWAP_MAP_SHMEM)
goto fallback;
/* cross into another cluster */
if (nr > SWAPFILE_CLUSTER - offset % SWAPFILE_CLUSTER)