* another swap/hibernate code cleanup for for-5.12/block
@ 2021-02-09 17:14 Christoph Hellwig
2021-02-09 17:14 ` [PATCH] mm: simplify swapdev_block Christoph Hellwig
2021-02-10 15:23 ` another swap/hibernate code cleanup for for-5.12/block Jens Axboe
0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2021-02-09 17:14 UTC (permalink / raw)
To: Jens Axboe; +Cc: Andrew Morton, Rafael J. Wysocki, linux-mm, linux-block
Hi Jens,
this cleans up another lose end in the swapfile.c after the previous
bio related cleanups.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] mm: simplify swapdev_block
2021-02-09 17:14 another swap/hibernate code cleanup for for-5.12/block Christoph Hellwig
@ 2021-02-09 17:14 ` Christoph Hellwig
2021-02-10 13:34 ` Rafael J. Wysocki
2021-02-10 15:23 ` another swap/hibernate code cleanup for for-5.12/block Jens Axboe
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2021-02-09 17:14 UTC (permalink / raw)
To: Jens Axboe; +Cc: Andrew Morton, Rafael J. Wysocki, linux-mm, linux-block
Open code the parts of map_swap_entry that was actually used by
swapdev_block, and remove the now unused map_swap_entry function.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
mm/swapfile.c | 30 +++---------------------------
1 file changed, 3 insertions(+), 27 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 351999a84e6e4e..21a98cb8d646e3 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1790,9 +1790,6 @@ int free_swap_and_cache(swp_entry_t entry)
}
#ifdef CONFIG_HIBERNATION
-
-static sector_t map_swap_entry(swp_entry_t, struct block_device**);
-
/*
* Find the swap type that corresponds to given device (if any).
*
@@ -1852,12 +1849,13 @@ int find_first_swap(dev_t *device)
*/
sector_t swapdev_block(int type, pgoff_t offset)
{
- struct block_device *bdev;
struct swap_info_struct *si = swap_type_to_swap_info(type);
+ struct swap_extent *se;
if (!si || !(si->flags & SWP_WRITEOK))
return 0;
- return map_swap_entry(swp_entry(type, offset), &bdev);
+ se = offset_to_swap_extent(si, offset);
+ return se->start_block + (offset - se->start_page);
}
/*
@@ -2283,28 +2281,6 @@ static void drain_mmlist(void)
spin_unlock(&mmlist_lock);
}
-#ifdef CONFIG_HIBERNATION
-/*
- * Use this swapdev's extent info to locate the (PAGE_SIZE) block which
- * corresponds to page offset for the specified swap entry.
- * Note that the type of this function is sector_t, but it returns page offset
- * into the bdev, not sector offset.
- */
-static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev)
-{
- struct swap_info_struct *sis;
- struct swap_extent *se;
- pgoff_t offset;
-
- sis = swp_swap_info(entry);
- *bdev = sis->bdev;
-
- offset = swp_offset(entry);
- se = offset_to_swap_extent(sis, offset);
- return se->start_block + (offset - se->start_page);
-}
-#endif
-
/*
* Free all of a swapdev's extent information
*/
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: simplify swapdev_block
2021-02-09 17:14 ` [PATCH] mm: simplify swapdev_block Christoph Hellwig
@ 2021-02-10 13:34 ` Rafael J. Wysocki
0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-02-10 13:34 UTC (permalink / raw)
To: Christoph Hellwig, Jens Axboe; +Cc: Andrew Morton, linux-mm, linux-block
On Tuesday, February 9, 2021 6:14:19 PM CET Christoph Hellwig wrote:
> Open code the parts of map_swap_entry that was actually used by
> swapdev_block, and remove the now unused map_swap_entry function.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> mm/swapfile.c | 30 +++---------------------------
> 1 file changed, 3 insertions(+), 27 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 351999a84e6e4e..21a98cb8d646e3 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -1790,9 +1790,6 @@ int free_swap_and_cache(swp_entry_t entry)
> }
>
> #ifdef CONFIG_HIBERNATION
> -
> -static sector_t map_swap_entry(swp_entry_t, struct block_device**);
> -
> /*
> * Find the swap type that corresponds to given device (if any).
> *
> @@ -1852,12 +1849,13 @@ int find_first_swap(dev_t *device)
> */
> sector_t swapdev_block(int type, pgoff_t offset)
> {
> - struct block_device *bdev;
> struct swap_info_struct *si = swap_type_to_swap_info(type);
> + struct swap_extent *se;
>
> if (!si || !(si->flags & SWP_WRITEOK))
> return 0;
> - return map_swap_entry(swp_entry(type, offset), &bdev);
> + se = offset_to_swap_extent(si, offset);
> + return se->start_block + (offset - se->start_page);
> }
>
> /*
> @@ -2283,28 +2281,6 @@ static void drain_mmlist(void)
> spin_unlock(&mmlist_lock);
> }
>
> -#ifdef CONFIG_HIBERNATION
> -/*
> - * Use this swapdev's extent info to locate the (PAGE_SIZE) block which
> - * corresponds to page offset for the specified swap entry.
> - * Note that the type of this function is sector_t, but it returns page offset
> - * into the bdev, not sector offset.
> - */
> -static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev)
> -{
> - struct swap_info_struct *sis;
> - struct swap_extent *se;
> - pgoff_t offset;
> -
> - sis = swp_swap_info(entry);
> - *bdev = sis->bdev;
> -
> - offset = swp_offset(entry);
> - se = offset_to_swap_extent(sis, offset);
> - return se->start_block + (offset - se->start_page);
> -}
> -#endif
> -
> /*
> * Free all of a swapdev's extent information
> */
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: another swap/hibernate code cleanup for for-5.12/block
2021-02-09 17:14 another swap/hibernate code cleanup for for-5.12/block Christoph Hellwig
2021-02-09 17:14 ` [PATCH] mm: simplify swapdev_block Christoph Hellwig
@ 2021-02-10 15:23 ` Jens Axboe
1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-02-10 15:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Andrew Morton, Rafael J. Wysocki, linux-mm, linux-block
On 2/9/21 10:14 AM, Christoph Hellwig wrote:
> Hi Jens,
>
> this cleans up another lose end in the swapfile.c after the previous
> bio related cleanups.
>
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-10 15:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 17:14 another swap/hibernate code cleanup for for-5.12/block Christoph Hellwig
2021-02-09 17:14 ` [PATCH] mm: simplify swapdev_block Christoph Hellwig
2021-02-10 13:34 ` Rafael J. Wysocki
2021-02-10 15:23 ` another swap/hibernate code cleanup for for-5.12/block Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).