1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/*
* Copyright (C) 2019 Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
*/
#ifndef _SPACEMAN_H
#define _SPACEMAN_H
#include <apfs/types.h>
#include "btree.h"
#include "object.h"
struct apfs_spaceman_free_queue_key;
/* Space manager data in memory */
struct spaceman {
void *sm_bitmap; /* Allocation bitmap for the whole container */
struct free_queue *sm_ip_fq; /* Free queue for internal pool */
struct free_queue *sm_main_fq; /* Free queue for main device */
int sm_struct_size; /* Size of the spaceman structure on disk */
/* Spaceman info read from the on-disk structures */
u64 sm_xid;
u32 sm_blocks_per_chunk;
u32 sm_chunks_per_cib;
u32 sm_cibs_per_cab;
u32 sm_cib_count;
u64 sm_chunk_count;
u64 sm_ip_base;
u64 sm_ip_block_count;
/* Spaceman info measured by the fsck */
u64 sm_chunks; /* Number of chunks */
u64 sm_blocks; /* Number of blocks */
u64 sm_free; /* Number of free blocks */
u64 sm_reserve_block_num; /* Blocks that are reserved for volumes */
u64 sm_reserve_alloc_num; /* Blocks already alloced by those volumes */
};
/*
* Free queue data in memory. This is a subclass of struct btree; a free queue
* btree can simply be cast to a free_queue structure.
*/
struct free_queue {
/* This must always remain the first field */
struct btree sfq_btree; /* B-tree structure for the free queue */
int sfq_index; /* Position in the free queue array */
/* Free queue stats as measured by the fsck */
u64 sfq_count; /* Total count of free blocks in the queue */
u64 sfq_oldest_xid; /* First transaction id in the queue */
};
extern void container_bmap_mark_as_used(u64 paddr, u64 length);
extern void ip_bmap_mark_as_used(u64 paddr, u64 length);
extern void check_spaceman(u64 oid);
extern void parse_free_queue_record(struct apfs_spaceman_free_queue_key *key,
void *val, int len, struct btree *btree);
#endif /* _SPACEMAN_H */
|