* SWP_PAGER_FREESWAPSPACE() - free raw swap space * * This routine returns the specified swap blocks back to the bitmap. * * This routine may not sleep. */
| 873 | * This routine may not sleep. |
| 874 | */ |
| 875 | static void |
| 876 | swp_pager_freeswapspace(daddr_t blk, daddr_t npages) |
| 877 | { |
| 878 | struct swdevt *sp; |
| 879 | |
| 880 | if (npages == 0) |
| 881 | return; |
| 882 | mtx_lock(&sw_dev_mtx); |
| 883 | TAILQ_FOREACH(sp, &swtailq, sw_list) { |
| 884 | if (swp_pager_isondev(blk, sp)) { |
| 885 | sp->sw_used -= npages; |
| 886 | /* |
| 887 | * If we are attempting to stop swapping on |
| 888 | * this device, we don't want to mark any |
| 889 | * blocks free lest they be reused. |
| 890 | */ |
| 891 | if ((sp->sw_flags & SW_CLOSING) == 0) { |
| 892 | blist_free(sp->sw_blist, blk - sp->sw_first, |
| 893 | npages); |
| 894 | swap_pager_avail += npages; |
| 895 | swp_sizecheck(); |
| 896 | } |
| 897 | mtx_unlock(&sw_dev_mtx); |
| 898 | return; |
| 899 | } |
| 900 | } |
| 901 | panic("Swapdev not found"); |
| 902 | } |
| 903 | |
| 904 | /* |
| 905 | * SYSCTL_SWAP_FRAGMENTATION() - produce raw swap space stats |
no test coverage detected