fs/ocfs2/reservations.h

Source file repositories/reference/linux-study-clean/fs/ocfs2/reservations.h

File Facts

System
Linux kernel
Corpus path
fs/ocfs2/reservations.h
Extension
.h
Size
4778 bytes
Lines
145
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ocfs2_alloc_reservation {
	struct rb_node	r_node;

	unsigned int	r_start;	/* Beginning of current window */
	unsigned int	r_len;		/* Length of the window */

	unsigned int	r_last_len;	/* Length of most recent alloc */
	unsigned int	r_last_start;	/* Start of most recent alloc */
	struct list_head	r_lru;	/* LRU list head */

	unsigned int	r_flags;
};

#define	OCFS2_RESV_FLAG_INUSE	0x01	/* Set when r_node is part of a btree */
#define	OCFS2_RESV_FLAG_TMP	0x02	/* Temporary reservation, will be
					 * destroyed immediately after use */
#define	OCFS2_RESV_FLAG_DIR	0x04	/* Reservation is for an unindexed
					 * directory btree */

struct ocfs2_reservation_map {
	struct rb_root		m_reservations;
	char			*m_disk_bitmap;

	struct ocfs2_super	*m_osb;

	/* The following are not initialized to meaningful values until a disk
	 * bitmap is provided. */
	u32			m_bitmap_len;	/* Number of valid
						 * bits available */

	struct list_head	m_lru;		/* LRU of reservations
						 * structures. */

};

void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv);

#define OCFS2_RESV_TYPES	(OCFS2_RESV_FLAG_TMP|OCFS2_RESV_FLAG_DIR)
void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv,
			 unsigned int flags);

int ocfs2_dir_resv_allowed(struct ocfs2_super *osb);

/**
 * ocfs2_resv_discard() - truncate a reservation
 * @resmap:
 * @resv: the reservation to truncate.
 *
 * After this function is called, the reservation will be empty, and
 * unlinked from the rbtree.
 */
void ocfs2_resv_discard(struct ocfs2_reservation_map *resmap,
			struct ocfs2_alloc_reservation *resv);


/**
 * ocfs2_resmap_init() - Initialize fields of a reservations bitmap
 * @osb: struct ocfs2_super to be saved in resmap
 * @resmap: struct ocfs2_reservation_map to initialize
 */
void ocfs2_resmap_init(struct ocfs2_super *osb,
		      struct ocfs2_reservation_map *resmap);

/**
 * ocfs2_resmap_restart() - "restart" a reservation bitmap
 * @resmap: reservations bitmap
 * @clen: Number of valid bits in the bitmap
 * @disk_bitmap: the disk bitmap this resmap should refer to.
 *
 * Re-initialize the parameters of a reservation bitmap. This is
 * useful for local alloc window slides.
 *
 * This function will call ocfs2_trunc_resv against all existing
 * reservations. A future version will recalculate existing
 * reservations based on the new bitmap.
 */
void ocfs2_resmap_restart(struct ocfs2_reservation_map *resmap,
			  unsigned int clen, char *disk_bitmap);

/**
 * ocfs2_resmap_uninit() - uninitialize a reservation bitmap structure
 * @resmap: the struct ocfs2_reservation_map to uninitialize
 */
void ocfs2_resmap_uninit(struct ocfs2_reservation_map *resmap);

/**
 * ocfs2_resmap_resv_bits() - Return still-valid reservation bits
 * @resmap: reservations bitmap
 * @resv: reservation to base search from
 * @cstart: start of proposed allocation

Annotation

Implementation Notes