Switch to byte granular allocations
[platform/upstream/btrfs-progs.git] / disk-io.h
1 /*
2  * Copyright (C) 2007 Oracle.  All rights reserved.
3  *
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.
7  *
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.
12  *
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.
17  */
18
19 #ifndef __DISKIO__
20 #define __DISKIO__
21 #include "list.h"
22
23 struct btrfs_buffer {
24         u64 bytenr;
25         u64 dev_bytenr;
26         u32 size;
27         int count;
28         int fd;
29         struct list_head dirty;
30         struct list_head cache;
31         union {
32                 struct btrfs_node node;
33                 struct btrfs_leaf leaf;
34         };
35 };
36
37 struct btrfs_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
38                                      u32 blocksize);
39 struct btrfs_buffer *find_tree_block(struct btrfs_root *root, u64 bytenr,
40                                      u32 blocksize);
41 int write_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
42                      struct btrfs_buffer *buf);
43 int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
44                      struct btrfs_buffer *buf);
45 int clean_tree_block(struct btrfs_trans_handle *trans,
46                      struct btrfs_root *root, struct btrfs_buffer *buf);
47 int btrfs_commit_transaction(struct btrfs_trans_handle *trans, struct btrfs_root
48                              *root, struct btrfs_super_block *s);
49 struct btrfs_root *open_ctree(char *filename, struct btrfs_super_block *s);
50 struct btrfs_root *open_ctree_fd(int fp, struct btrfs_super_block *super);
51 int close_ctree(struct btrfs_root *root, struct btrfs_super_block *s);
52 void btrfs_block_release(struct btrfs_root *root, struct btrfs_buffer *buf);
53 int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root *root,
54                       struct btrfs_super_block *s);
55 int btrfs_map_bh_to_logical(struct btrfs_root *root, struct btrfs_buffer *bh,
56                              u64 logical);
57 int btrfs_csum_super(struct btrfs_root *root, struct btrfs_super_block *super);
58 int btrfs_csum_node(struct btrfs_root *root, struct btrfs_node *node);
59 #define BTRFS_SUPER_INFO_OFFSET (16 * 1024)
60
61 #endif