mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 13:22:57 +00:00
mm: simplify swapdev_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> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
78e1663f19
commit
f885056a48
1 changed files with 3 additions and 27 deletions
|
@ -1790,9 +1790,6 @@ int free_swap_and_cache(swp_entry_t entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_HIBERNATION
|
#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).
|
* 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)
|
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_info_struct *si = swap_type_to_swap_info(type);
|
||||||
|
struct swap_extent *se;
|
||||||
|
|
||||||
if (!si || !(si->flags & SWP_WRITEOK))
|
if (!si || !(si->flags & SWP_WRITEOK))
|
||||||
return 0;
|
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);
|
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
|
* Free all of a swapdev's extent information
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue