From 079764d772f292031122960242c6073589020e59 Mon Sep 17 00:00:00 2001 From: Hugh Dickins Date: Sat, 3 Sep 2005 15:54:34 -0700 Subject: [PATCH] --- yaml --- r: 6847 b: refs/heads/master c: 11d31886dbcb61039ed3789e583d21c6e70960fd h: refs/heads/master i: 6845: e49c491b6a6785ba40f6f6aaadc4a74e269cfffb 6843: 0de52cb1898d3dbee6a3f58a41be783b3a516354 6839: d54792e0c9b84af5032e3917c73136074d6b2a53 6831: efca3e493d60d0a75bcde4493e75f570d8041bc1 6815: 8c8bb179dfbef7015f583f38006ae9d65c624e50 6783: 9ffc87e7b61804cd8fd13c521c9ba55ee75035ea v: v3 --- [refs] | 2 +- trunk/include/linux/swap.h | 2 -- trunk/mm/swapfile.c | 27 +++++++++------------------ 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/[refs] b/[refs] index cb88b48d78ca..588f31d38a0d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 4cd3bb10ff0b21b77b5a4cd13b4bd36694e054c4 +refs/heads/master: 11d31886dbcb61039ed3789e583d21c6e70960fd diff --git a/trunk/include/linux/swap.h b/trunk/include/linux/swap.h index bfe3e763ccf2..38f288475e67 100644 --- a/trunk/include/linux/swap.h +++ b/trunk/include/linux/swap.h @@ -116,8 +116,6 @@ enum { /* * The in-memory structure used to track swap areas. - * extent_list.prev points at the lowest-index extent. That list is - * sorted. */ struct swap_info_struct { unsigned int flags; diff --git a/trunk/mm/swapfile.c b/trunk/mm/swapfile.c index 4b39e9501d44..73521d39e985 100644 --- a/trunk/mm/swapfile.c +++ b/trunk/mm/swapfile.c @@ -832,9 +832,9 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset) offset < (se->start_page + se->nr_pages)) { return se->start_block + (offset - se->start_page); } - lh = se->list.prev; + lh = se->list.next; if (lh == &sis->extent_list) - lh = lh->prev; + lh = lh->next; se = list_entry(lh, struct swap_extent, list); sis->curr_swap_extent = se; BUG_ON(se == start_se); /* It *must* be present */ @@ -859,10 +859,9 @@ static void destroy_swap_extents(struct swap_info_struct *sis) /* * Add a block range (and the corresponding page range) into this swapdev's - * extent list. The extent list is kept sorted in block order. + * extent list. The extent list is kept sorted in page order. * - * This function rather assumes that it is called in ascending sector_t order. - * It doesn't look for extent coalescing opportunities. + * This function rather assumes that it is called in ascending page order. */ static int add_swap_extent(struct swap_info_struct *sis, unsigned long start_page, @@ -872,16 +871,15 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page, struct swap_extent *new_se; struct list_head *lh; - lh = sis->extent_list.next; /* The highest-addressed block */ - while (lh != &sis->extent_list) { + lh = sis->extent_list.prev; /* The highest page extent */ + if (lh != &sis->extent_list) { se = list_entry(lh, struct swap_extent, list); - if (se->start_block + se->nr_pages == start_block && - se->start_page + se->nr_pages == start_page) { + BUG_ON(se->start_page + se->nr_pages != start_page); + if (se->start_block + se->nr_pages == start_block) { /* Merge it */ se->nr_pages += nr_pages; return 0; } - lh = lh->next; } /* @@ -894,14 +892,7 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page, new_se->nr_pages = nr_pages; new_se->start_block = start_block; - lh = sis->extent_list.prev; /* The lowest block */ - while (lh != &sis->extent_list) { - se = list_entry(lh, struct swap_extent, list); - if (se->start_block > start_block) - break; - lh = lh->prev; - } - list_add_tail(&new_se->list, lh); + list_add_tail(&new_se->list, &sis->extent_list); sis->nr_extents++; return 0; }