Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swapfile.c Create Date:2022-07-28 15:16:24
Last Modify:2020-03-17 22:19:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:swap allocation tell device that a cluster of swap can now be discarded,* to allow the swap device to optimize its wear-levelling.

Proto:static void discard_swap_cluster(struct swap_info_struct *si, unsigned long start_page, unsigned long nr_pages)

Type:void

Parameter:

TypeParameterName
struct swap_info_struct *si
unsigned longstart_page
unsigned longnr_pages
231  se = offset_to_swap_extent(si, start_page)
233  When nr_pages cycle
234  offset = start_page - start_page
235  start_block = start_block + offset
236  nr_blocks = nr_pages - offset
238  If nr_blocks > nr_pages Then nr_blocks = nr_pages
240  start_page += nr_blocks
241  nr_pages -= nr_blocks
243  start_block <<= PAGE_SHIFT determines the page size - 9
244  nr_blocks <<= PAGE_SHIFT determines the page size - 9
245  If blkdev_issue_discard(swap device or bdev of swap file , start_block, nr_blocks, GFP_NOIO, 0) Then Break
249  se = next_se(se)
Caller
NameDescribe
swap_do_scheduled_discardDoing discard actually. After a cluster discard is finished, the cluster* will be added to free cluster list. caller should hold si->lock.