Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
reservations.h
Go to the documentation of this file.
1 /* -*- mode: c; c-basic-offset: 8; -*-
2  * vim: noexpandtab sw=8 ts=8 sts=0:
3  *
4  * reservations.h
5  *
6  * Allocation reservations function prototypes and structures.
7  *
8  * Copyright (C) 2010 Novell. All rights reserved.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public
12  * License version 2 as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  */
19 
20 #ifndef OCFS2_RESERVATIONS_H
21 #define OCFS2_RESERVATIONS_H
22 
23 #include <linux/rbtree.h>
24 
25 #define OCFS2_DEFAULT_RESV_LEVEL 2
26 #define OCFS2_MAX_RESV_LEVEL 9
27 #define OCFS2_MIN_RESV_LEVEL 0
28 
30  struct rb_node r_node;
31 
32  unsigned int r_start; /* Beginning of current window */
33  unsigned int r_len; /* Length of the window */
34 
35  unsigned int r_last_len; /* Length of most recent alloc */
36  unsigned int r_last_start; /* Start of most recent alloc */
37  struct list_head r_lru; /* LRU list head */
38 
39  unsigned int r_flags;
40 };
41 
42 #define OCFS2_RESV_FLAG_INUSE 0x01 /* Set when r_node is part of a btree */
43 #define OCFS2_RESV_FLAG_TMP 0x02 /* Temporary reservation, will be
44  * destroyed immedately after use */
45 #define OCFS2_RESV_FLAG_DIR 0x04 /* Reservation is for an unindexed
46  * directory btree */
47 
49  struct rb_root m_reservations;
51 
52  struct ocfs2_super *m_osb;
53 
54  /* The following are not initialized to meaningful values until a disk
55  * bitmap is provided. */
56  u32 m_bitmap_len; /* Number of valid
57  * bits available */
58 
59  struct list_head m_lru; /* LRU of reservations
60  * structures. */
61 
62 };
63 
65 
66 #define OCFS2_RESV_TYPES (OCFS2_RESV_FLAG_TMP|OCFS2_RESV_FLAG_DIR)
68  unsigned int flags);
69 
70 int ocfs2_dir_resv_allowed(struct ocfs2_super *osb);
71 
80 void ocfs2_resv_discard(struct ocfs2_reservation_map *resmap,
82 
83 
94 int ocfs2_resmap_init(struct ocfs2_super *osb,
95  struct ocfs2_reservation_map *resmap);
96 
110 void ocfs2_resmap_restart(struct ocfs2_reservation_map *resmap,
111  unsigned int clen, char *disk_bitmap);
112 
117 void ocfs2_resmap_uninit(struct ocfs2_reservation_map *resmap);
118 
138  int *cstart, int *clen);
139 
157  u32 cstart, u32 clen);
158 
159 #endif /* OCFS2_RESERVATIONS_H */