1 /* SPDX-License-Identifier: GPL-2.0-only */ 1 2 /* 3 * reservations.h 4 * 5 * Allocation reservations function prototypes 6 * 7 * Copyright (C) 2010 Novell. All rights rese 8 */ 9 10 #ifndef OCFS2_RESERVATIONS_H 11 #define OCFS2_RESERVATIONS_H 12 13 #include <linux/rbtree.h> 14 15 #define OCFS2_DEFAULT_RESV_LEVEL 2 16 #define OCFS2_MAX_RESV_LEVEL 9 17 #define OCFS2_MIN_RESV_LEVEL 0 18 19 struct ocfs2_alloc_reservation { 20 struct rb_node r_node; 21 22 unsigned int r_start; /* Beg 23 unsigned int r_len; /* Len 24 25 unsigned int r_last_len; /* Len 26 unsigned int r_last_start; /* Sta 27 struct list_head r_lru; /* LRU 28 29 unsigned int r_flags; 30 }; 31 32 #define OCFS2_RESV_FLAG_INUSE 0x01 /* Set 33 #define OCFS2_RESV_FLAG_TMP 0x02 /* Tem 34 * des 35 #define OCFS2_RESV_FLAG_DIR 0x04 /* Res 36 * dir 37 38 struct ocfs2_reservation_map { 39 struct rb_root m_reservations 40 char *m_disk_bitmap 41 42 struct ocfs2_super *m_osb; 43 44 /* The following are not initialized t 45 * bitmap is provided. */ 46 u32 m_bitmap_len; 47 48 49 struct list_head m_lru; 50 51 52 }; 53 54 void ocfs2_resv_init_once(struct ocfs2_alloc_r 55 56 #define OCFS2_RESV_TYPES (OCFS2_RESV_FL 57 void ocfs2_resv_set_type(struct ocfs2_alloc_re 58 unsigned int flags); 59 60 int ocfs2_dir_resv_allowed(struct ocfs2_super 61 62 /** 63 * ocfs2_resv_discard() - truncate a reservati 64 * @resmap: 65 * @resv: the reservation to truncate. 66 * 67 * After this function is called, the reservat 68 * unlinked from the rbtree. 69 */ 70 void ocfs2_resv_discard(struct ocfs2_reservati 71 struct ocfs2_alloc_res 72 73 74 /** 75 * ocfs2_resmap_init() - Initialize fields of 76 * @osb: struct ocfs2_super to be saved in res 77 * @resmap: struct ocfs2_reservation_map to in 78 */ 79 void ocfs2_resmap_init(struct ocfs2_super *osb 80 struct ocfs2_reservation 81 82 /** 83 * ocfs2_resmap_restart() - "restart" a reserv 84 * @resmap: reservations bitmap 85 * @clen: Number of valid bits in the bitmap 86 * @disk_bitmap: the disk bitmap this resmap s 87 * 88 * Re-initialize the parameters of a reservati 89 * useful for local alloc window slides. 90 * 91 * This function will call ocfs2_trunc_resv ag 92 * reservations. A future version will recalcu 93 * reservations based on the new bitmap. 94 */ 95 void ocfs2_resmap_restart(struct ocfs2_reserva 96 unsigned int clen, c 97 98 /** 99 * ocfs2_resmap_uninit() - uninitialize a rese 100 * @resmap: the struct ocfs2_reservation_map t 101 */ 102 void ocfs2_resmap_uninit(struct ocfs2_reservat 103 104 /** 105 * ocfs2_resmap_resv_bits() - Return still-val 106 * @resmap: reservations bitmap 107 * @resv: reservation to base search from 108 * @cstart: start of proposed allocation 109 * @clen: length (in clusters) of proposed all 110 * 111 * Using the reservation data from resv, this 112 * resmap and resmap->m_disk_bitmap to determi 113 * the reservation window is still clear to us 114 * this function will try to allocate a window 115 * 116 * On success, zero is returned and the valid 117 * and clen. 118 * 119 * Returns -ENOSPC if reservations are disable 120 */ 121 int ocfs2_resmap_resv_bits(struct ocfs2_reserv 122 struct ocfs2_alloc_ 123 int *cstart, int *c 124 125 /** 126 * ocfs2_resmap_claimed_bits() - Tell the rese 127 * @resmap: reservations bitmap 128 * @resv: optional reservation to recalulate b 129 * @cstart: start of allocation in clusters 130 * @clen: end of allocation in clusters. 131 * 132 * Tell the reservation code that bits were us 133 * resmap. The bits don't have to have been pa 134 * reservation. But we must always call this f 135 * Internally, the reservations code will use 136 * reservations bitmap. If resv is passed, it' 137 * calculated. It also expects that 'cstart' i 138 * from ocfs2_resmap_resv_bits(). 139 */ 140 void ocfs2_resmap_claimed_bits(struct ocfs2_re 141 struct ocfs2_al 142 u32 cstart, u32 143 144 #endif /* OCFS2_RESERVATIONS_H */ 145
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.