calculate checksums during IO
[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 blocknr;
25         u64 dev_blocknr;
26         int count;
27         int fd;
28         struct list_head dirty;
29         struct list_head cache;
30         union {
31                 struct btrfs_node node;
32                 struct btrfs_leaf leaf;
33         };
34 };
35
36 struct btrfs_buffer *read_tree_block(struct btrfs_root *root, u64 blocknr);
37 struct btrfs_buffer *find_tree_block(struct btrfs_root *root, u64 blocknr);
38 int write_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
39                      struct btrfs_buffer *buf);
40 int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
41                      struct btrfs_buffer *buf);
42 int clean_tree_block(struct btrfs_trans_handle *trans,
43                      struct btrfs_root *root, struct btrfs_buffer *buf);
44 int btrfs_commit_transaction(struct btrfs_trans_handle *trans, struct btrfs_root
45                              *root, struct btrfs_super_block *s);
46 struct btrfs_root *open_ctree(char *filename, struct btrfs_super_block *s);
47 struct btrfs_root *open_ctree_fd(int fp, struct btrfs_super_block *super);
48 int close_ctree(struct btrfs_root *root, struct btrfs_super_block *s);
49 void btrfs_block_release(struct btrfs_root *root, struct btrfs_buffer *buf);
50 int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root *root,
51                       struct btrfs_super_block *s);
52 int btrfs_map_bh_to_logical(struct btrfs_root *root, struct btrfs_buffer *bh,
53                              u64 logical);
54 int btrfs_csum_super(struct btrfs_root *root, struct btrfs_super_block *super);
55 int btrfs_csum_node(struct btrfs_root *root, struct btrfs_node *node);
56 #define BTRFS_SUPER_INFO_OFFSET (16 * 1024)
57
58 #endif