swap_state.c (a4c366f01f10073e0220656561b875627ff7cd90) swap_state.c (4081f7446d95a9d3ced12dc04ff02c187a761e90)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/mm/swap_state.c
4 *
5 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
6 * Swap reorganised 29.12.95, Stephen Tweedie
7 *
8 * Rewritten to use page cache, (C) 1998 Stephen Tweedie

--- 204 unchanged lines hidden (view full) ---

213 * the folio is swapped in later. Always setting the dirty flag
214 * for the folio solves the problem.
215 */
216 folio_mark_dirty(folio);
217
218 return true;
219
220fail:
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/mm/swap_state.c
4 *
5 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
6 * Swap reorganised 29.12.95, Stephen Tweedie
7 *
8 * Rewritten to use page cache, (C) 1998 Stephen Tweedie

--- 204 unchanged lines hidden (view full) ---

213 * the folio is swapped in later. Always setting the dirty flag
214 * for the folio solves the problem.
215 */
216 folio_mark_dirty(folio);
217
218 return true;
219
220fail:
221 put_swap_page(&folio->page, entry);
221 put_swap_folio(folio, entry);
222 return false;
223}
224
225/*
226 * This must be called only on folios that have
227 * been verified to be in the swap cache and locked.
228 * It will never put the folio into the free list,
229 * the caller has a reference on the folio.
230 */
231void delete_from_swap_cache(struct folio *folio)
232{
233 swp_entry_t entry = folio_swap_entry(folio);
234 struct address_space *address_space = swap_address_space(entry);
235
236 xa_lock_irq(&address_space->i_pages);
237 __delete_from_swap_cache(folio, entry, NULL);
238 xa_unlock_irq(&address_space->i_pages);
239
222 return false;
223}
224
225/*
226 * This must be called only on folios that have
227 * been verified to be in the swap cache and locked.
228 * It will never put the folio into the free list,
229 * the caller has a reference on the folio.
230 */
231void delete_from_swap_cache(struct folio *folio)
232{
233 swp_entry_t entry = folio_swap_entry(folio);
234 struct address_space *address_space = swap_address_space(entry);
235
236 xa_lock_irq(&address_space->i_pages);
237 __delete_from_swap_cache(folio, entry, NULL);
238 xa_unlock_irq(&address_space->i_pages);
239
240 put_swap_page(&folio->page, entry);
240 put_swap_folio(folio, entry);
241 folio_ref_sub(folio, folio_nr_pages(folio));
242}
243
244void clear_shadow_from_swap_cache(int type, unsigned long begin,
245 unsigned long end)
246{
247 unsigned long curr = begin;
248 void *old;

--- 244 unchanged lines hidden (view full) ---

493 workingset_refault(folio, shadow);
494
495 /* Caller will initiate read into locked folio */
496 folio_add_lru(folio);
497 *new_page_allocated = true;
498 return &folio->page;
499
500fail_unlock:
241 folio_ref_sub(folio, folio_nr_pages(folio));
242}
243
244void clear_shadow_from_swap_cache(int type, unsigned long begin,
245 unsigned long end)
246{
247 unsigned long curr = begin;
248 void *old;

--- 244 unchanged lines hidden (view full) ---

493 workingset_refault(folio, shadow);
494
495 /* Caller will initiate read into locked folio */
496 folio_add_lru(folio);
497 *new_page_allocated = true;
498 return &folio->page;
499
500fail_unlock:
501 put_swap_page(&folio->page, entry);
501 put_swap_folio(folio, entry);
502 folio_unlock(folio);
503 folio_put(folio);
504 return NULL;
505}
506
507/*
508 * Locate a page of swap in physical memory, reserving swap cache space
509 * and reading the disk if it is not already cached.

--- 398 unchanged lines hidden ---
502 folio_unlock(folio);
503 folio_put(folio);
504 return NULL;
505}
506
507/*
508 * Locate a page of swap in physical memory, reserving swap cache space
509 * and reading the disk if it is not already cached.

--- 398 unchanged lines hidden ---