shmem.c (fcbc329fa39ef261ba9072c56c63563423bff798) shmem.c (3d2c908768877714a354ee6d7bf93e801400d5e2)
1/*
2 * Resizable virtual memory filesystem for Linux.
3 *
4 * Copyright (C) 2000 Linus Torvalds.
5 * 2000 Transmeta Corp.
6 * 2000-2001 Christoph Rohland
7 * 2000-2001 SAP AG
8 * 2002 Red Hat Inc.

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

1637{
1638 struct folio *old, *new;
1639 struct address_space *swap_mapping;
1640 swp_entry_t entry;
1641 pgoff_t swap_index;
1642 int error;
1643
1644 old = *foliop;
1/*
2 * Resizable virtual memory filesystem for Linux.
3 *
4 * Copyright (C) 2000 Linus Torvalds.
5 * 2000 Transmeta Corp.
6 * 2000-2001 Christoph Rohland
7 * 2000-2001 SAP AG
8 * 2002 Red Hat Inc.

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

1637{
1638 struct folio *old, *new;
1639 struct address_space *swap_mapping;
1640 swp_entry_t entry;
1641 pgoff_t swap_index;
1642 int error;
1643
1644 old = *foliop;
1645 entry = folio_swap_entry(old);
1645 entry = old->swap;
1646 swap_index = swp_offset(entry);
1647 swap_mapping = swap_address_space(entry);
1648
1649 /*
1650 * We have arrived here because our zones are constrained, so don't
1651 * limit chance of success by further cpuset and node constraints.
1652 */
1653 gfp &= ~GFP_CONSTRAINT_MASK;

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

1658
1659 folio_get(new);
1660 folio_copy(new, old);
1661 flush_dcache_folio(new);
1662
1663 __folio_set_locked(new);
1664 __folio_set_swapbacked(new);
1665 folio_mark_uptodate(new);
1646 swap_index = swp_offset(entry);
1647 swap_mapping = swap_address_space(entry);
1648
1649 /*
1650 * We have arrived here because our zones are constrained, so don't
1651 * limit chance of success by further cpuset and node constraints.
1652 */
1653 gfp &= ~GFP_CONSTRAINT_MASK;

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

1658
1659 folio_get(new);
1660 folio_copy(new, old);
1661 flush_dcache_folio(new);
1662
1663 __folio_set_locked(new);
1664 __folio_set_swapbacked(new);
1665 folio_mark_uptodate(new);
1666 folio_set_swap_entry(new, entry);
1666 new->swap = entry;
1667 folio_set_swapcache(new);
1668
1669 /*
1670 * Our caller will very soon move newpage out of swapcache, but it's
1671 * a nice clean interface for us to replace oldpage by newpage there.
1672 */
1673 xa_lock_irq(&swap_mapping->i_pages);
1674 error = shmem_replace_entry(swap_mapping, swap_index, old, new);

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

1780 error = -ENOMEM;
1781 goto failed;
1782 }
1783 }
1784
1785 /* We have to do this with folio locked to prevent races */
1786 folio_lock(folio);
1787 if (!folio_test_swapcache(folio) ||
1667 folio_set_swapcache(new);
1668
1669 /*
1670 * Our caller will very soon move newpage out of swapcache, but it's
1671 * a nice clean interface for us to replace oldpage by newpage there.
1672 */
1673 xa_lock_irq(&swap_mapping->i_pages);
1674 error = shmem_replace_entry(swap_mapping, swap_index, old, new);

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

1780 error = -ENOMEM;
1781 goto failed;
1782 }
1783 }
1784
1785 /* We have to do this with folio locked to prevent races */
1786 folio_lock(folio);
1787 if (!folio_test_swapcache(folio) ||
1788 folio_swap_entry(folio).val != swap.val ||
1788 folio->swap.val != swap.val ||
1789 !shmem_confirm_swap(mapping, index, swap)) {
1790 error = -EEXIST;
1791 goto unlock;
1792 }
1793 if (!folio_test_uptodate(folio)) {
1794 error = -EIO;
1795 goto failed;
1796 }

--- 2755 unchanged lines hidden ---
1789 !shmem_confirm_swap(mapping, index, swap)) {
1790 error = -EEXIST;
1791 goto unlock;
1792 }
1793 if (!folio_test_uptodate(folio)) {
1794 error = -EIO;
1795 goto failed;
1796 }

--- 2755 unchanged lines hidden ---