btrfs-debug-tree: add -d option to print only the device mapping
[btrfs-progs-unstable.git] / extent_io.h
bloba5d6bf0e73eec731a709cee4bde753089e79ae67
1 /*
2 * Copyright (C) 2007 Oracle. All rights reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
19 #ifndef __EXTENTMAP__
20 #define __EXTENTMAP__
21 #include "kerncompat.h"
22 #include "extent-cache.h"
23 #include "list.h"
25 #define EXTENT_DIRTY 1
26 #define EXTENT_WRITEBACK (1 << 1)
27 #define EXTENT_UPTODATE (1 << 2)
28 #define EXTENT_LOCKED (1 << 3)
29 #define EXTENT_NEW (1 << 4)
30 #define EXTENT_DELALLOC (1 << 5)
31 #define EXTENT_DEFRAG (1 << 6)
32 #define EXTENT_DEFRAG_DONE (1 << 7)
33 #define EXTENT_BUFFER_FILLED (1 << 8)
34 #define EXTENT_CSUM (1 << 9)
35 #define EXTENT_IOBITS (EXTENT_LOCKED | EXTENT_WRITEBACK)
37 struct extent_io_tree {
38 struct cache_tree state;
39 struct cache_tree cache;
40 struct list_head lru;
41 u64 cache_size;
44 struct extent_state {
45 struct cache_extent cache_node;
46 u64 start;
47 u64 end;
48 int refs;
49 unsigned long state;
50 u64 private;
53 struct extent_buffer {
54 struct cache_extent cache_node;
55 u64 start;
56 u64 dev_bytenr;
57 u32 len;
58 struct extent_io_tree *tree;
59 struct list_head lru;
60 int refs;
61 int flags;
62 int fd;
63 char data[];
66 static inline void extent_buffer_get(struct extent_buffer *eb)
68 eb->refs++;
71 void extent_io_tree_init(struct extent_io_tree *tree);
72 void extent_io_tree_cleanup(struct extent_io_tree *tree);
73 int set_extent_bits(struct extent_io_tree *tree, u64 start,
74 u64 end, int bits, gfp_t mask);
75 int clear_extent_bits(struct extent_io_tree *tree, u64 start,
76 u64 end, int bits, gfp_t mask);
77 int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
78 u64 *start_ret, u64 *end_ret, int bits);
79 int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end,
80 int bits, int filled);
81 int set_extent_dirty(struct extent_io_tree *tree, u64 start,
82 u64 end, gfp_t mask);
83 int clear_extent_dirty(struct extent_io_tree *tree, u64 start,
84 u64 end, gfp_t mask);
85 int extent_buffer_uptodate(struct extent_buffer *eb);
86 int set_extent_buffer_uptodate(struct extent_buffer *eb);
87 int clear_extent_buffer_uptodate(struct extent_io_tree *tree,
88 struct extent_buffer *eb);
89 int set_state_private(struct extent_io_tree *tree, u64 start, u64 private);
90 int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private);
91 struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
92 u64 bytenr, u32 blocksize);
93 struct extent_buffer *find_first_extent_buffer(struct extent_io_tree *tree,
94 u64 start);
95 struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
96 u64 bytenr, u32 blocksize);
97 void free_extent_buffer(struct extent_buffer *eb);
98 int read_extent_from_disk(struct extent_buffer *eb);
99 int write_extent_to_disk(struct extent_buffer *eb);
100 int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,
101 unsigned long start, unsigned long len);
102 void read_extent_buffer(struct extent_buffer *eb, void *dst,
103 unsigned long start, unsigned long len);
104 void write_extent_buffer(struct extent_buffer *eb, const void *src,
105 unsigned long start, unsigned long len);
106 void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
107 unsigned long dst_offset, unsigned long src_offset,
108 unsigned long len);
109 void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
110 unsigned long src_offset, unsigned long len);
111 void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
112 unsigned long src_offset, unsigned long len);
113 void memset_extent_buffer(struct extent_buffer *eb, char c,
114 unsigned long start, unsigned long len);
115 int set_extent_buffer_dirty(struct extent_buffer *eb);
116 int clear_extent_buffer_dirty(struct extent_buffer *eb);
117 #endif