aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@163.com>2016-01-14 18:20:45 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-14 19:00:49 -0500
commita8ae49917077facbe4ed7b3a89bf025b1cefa0ed (patch)
tree9084e900d1594e8176297fef6dfffdd5e0513db8 /mm/swapfile.c
parent8c9c1701c7c23a57ebfd1a0b27b87053ae43cfb5 (diff)
mm/swapfile.c: use list_{next,first}_entry
To make the intention clearer, use list_{next,first}_entry instead of list_entry(). Signed-off-by: Geliang Tang <geliangtang@163.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Jerome Marchand <jmarchan@redhat.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 58877312cf6b..77551a553f57 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -165,8 +165,6 @@ static void discard_swap_cluster(struct swap_info_struct *si,
165 int found_extent = 0; 165 int found_extent = 0;
166 166
167 while (nr_pages) { 167 while (nr_pages) {
168 struct list_head *lh;
169
170 if (se->start_page <= start_page && 168 if (se->start_page <= start_page &&
171 start_page < se->start_page + se->nr_pages) { 169 start_page < se->start_page + se->nr_pages) {
172 pgoff_t offset = start_page - se->start_page; 170 pgoff_t offset = start_page - se->start_page;
@@ -188,8 +186,7 @@ static void discard_swap_cluster(struct swap_info_struct *si,
188 break; 186 break;
189 } 187 }
190 188
191 lh = se->list.next; 189 se = list_next_entry(se, list);
192 se = list_entry(lh, struct swap_extent, list);
193 } 190 }
194} 191}
195 192
@@ -903,7 +900,7 @@ int swp_swapcount(swp_entry_t entry)
903 VM_BUG_ON(page_private(page) != SWP_CONTINUED); 900 VM_BUG_ON(page_private(page) != SWP_CONTINUED);
904 901
905 do { 902 do {
906 page = list_entry(page->lru.next, struct page, lru); 903 page = list_next_entry(page, lru);
907 map = kmap_atomic(page); 904 map = kmap_atomic(page);
908 tmp_count = map[offset]; 905 tmp_count = map[offset];
909 kunmap_atomic(map); 906 kunmap_atomic(map);
@@ -1633,14 +1630,11 @@ static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev)
1633 se = start_se; 1630 se = start_se;
1634 1631
1635 for ( ; ; ) { 1632 for ( ; ; ) {
1636 struct list_head *lh;
1637
1638 if (se->start_page <= offset && 1633 if (se->start_page <= offset &&
1639 offset < (se->start_page + se->nr_pages)) { 1634 offset < (se->start_page + se->nr_pages)) {
1640 return se->start_block + (offset - se->start_page); 1635 return se->start_block + (offset - se->start_page);
1641 } 1636 }
1642 lh = se->list.next; 1637 se = list_next_entry(se, list);
1643 se = list_entry(lh, struct swap_extent, list);
1644 sis->curr_swap_extent = se; 1638 sis->curr_swap_extent = se;
1645 BUG_ON(se == start_se); /* It *must* be present */ 1639 BUG_ON(se == start_se); /* It *must* be present */
1646 } 1640 }
@@ -1664,7 +1658,7 @@ static void destroy_swap_extents(struct swap_info_struct *sis)
1664 while (!list_empty(&sis->first_swap_extent.list)) { 1658 while (!list_empty(&sis->first_swap_extent.list)) {
1665 struct swap_extent *se; 1659 struct swap_extent *se;
1666 1660
1667 se = list_entry(sis->first_swap_extent.list.next, 1661 se = list_first_entry(&sis->first_swap_extent.list,
1668 struct swap_extent, list); 1662 struct swap_extent, list);
1669 list_del(&se->list); 1663 list_del(&se->list);
1670 kfree(se); 1664 kfree(se);