vm_compressor_backing_store.h [plain text]
#include <kern/kern_types.h>
#include <kern/locks.h>
#include <vm/vm_kern.h>
#include <mach/kern_return.h>
#include <kern/queue.h>
#include <vm/vm_pageout.h>
#include <vm/vm_protos.h>
#include <vm/vm_compressor.h>
#include <libkern/crypto/aes.h>
#include <kern/host_statistics.h>
#if CONFIG_EMBEDDED
#define MIN_SWAP_FILE_SIZE (64 * 1024 * 1024ULL)
#define MAX_SWAP_FILE_SIZE (128 * 1024 * 1024ULL)
#else
#define MIN_SWAP_FILE_SIZE (256 * 1024 * 1024ULL)
#define MAX_SWAP_FILE_SIZE (1 * 1024 * 1024 * 1024ULL)
#endif
#define COMPRESSED_SWAP_CHUNK_SIZE (C_SEG_BUFSIZE)
#define VM_SWAPFILE_HIWATER_SEGS (MIN_SWAP_FILE_SIZE / COMPRESSED_SWAP_CHUNK_SIZE)
#define SWAPFILE_RECLAIM_THRESHOLD_SEGS ((17 * (MAX_SWAP_FILE_SIZE / COMPRESSED_SWAP_CHUNK_SIZE)) / 10)
#define SWAPFILE_RECLAIM_MINIMUM_SEGS ((13 * (MAX_SWAP_FILE_SIZE / COMPRESSED_SWAP_CHUNK_SIZE)) / 10)
#if defined(XNU_TARGET_OS_OSX)
#define SWAP_FILE_NAME "/System/Volumes/VM/swapfile"
#else
#define SWAP_FILE_NAME "/private/var/vm/swapfile"
#endif
#define SWAPFILENAME_LEN (int)(strlen(SWAP_FILE_NAME))
#define SWAP_SLOT_MASK 0x1FFFFFFFF
#define SWAP_DEVICE_SHIFT 33
extern int vm_num_swap_files;
struct swapfile;
void vm_swap_init(void);
boolean_t vm_swap_create_file(void);
struct swapout_io_completion {
int swp_io_busy;
int swp_io_done;
int swp_io_error;
uint32_t swp_c_size;
c_segment_t swp_c_seg;
struct swapfile *swp_swf;
uint64_t swp_f_offset;
struct upl_io_completion swp_upl_ctx;
};
void vm_swapout_iodone(void *, int);
static void vm_swapout_finish(c_segment_t, uint64_t, uint32_t, kern_return_t);
kern_return_t vm_swap_put_finish(struct swapfile *, uint64_t *, int, boolean_t);
kern_return_t vm_swap_put(vm_offset_t, uint64_t*, uint32_t, c_segment_t, struct swapout_io_completion *);
void vm_swap_flush(void);
void vm_swap_reclaim(void);
void vm_swap_encrypt(c_segment_t);
uint64_t vm_swap_get_total_space(void);
uint64_t vm_swap_get_used_space(void);
uint64_t vm_swap_get_free_space(void);
uint64_t vm_swap_get_max_configured_space(void);
struct vnode;
extern void vm_swapfile_open(const char *path, struct vnode **vp);
extern void vm_swapfile_close(uint64_t path, struct vnode *vp);
extern int vm_swapfile_preallocate(struct vnode *vp, uint64_t *size, boolean_t *pin);
extern uint64_t vm_swapfile_get_blksize(struct vnode *vp);
extern uint64_t vm_swapfile_get_transfer_size(struct vnode *vp);
extern int vm_swapfile_io(struct vnode *vp, uint64_t offset, uint64_t start, int npages, int flags, void *upl_ctx);
#if CONFIG_FREEZE
boolean_t vm_swap_max_budget(uint64_t *);
int vm_swap_vol_get_budget(struct vnode* vp, uint64_t *freeze_daily_budget);
#endif
#if RECORD_THE_COMPRESSED_DATA
extern int vm_record_file_write(struct vnode *vp, uint64_t offset, char *buf, int size);
#endif