aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-07-17 13:53:27 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:05 -0400
commiteb84ae039e10f1f80443d846ba1350122bbdc753 (patch)
treed87bcbead436eaf96f5160ac46f78699d65c5251 /fs/btrfs/ordered-data.h
parent54641bd17db9fbfc13c7b1d4ee0dd2713bf3e076 (diff)
Btrfs: Cleanup and comment ordered-data.c
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ordered-data.h')
-rw-r--r--fs/btrfs/ordered-data.h49
1 files changed, 41 insertions, 8 deletions
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index 33f0d9e91b11..98f491d1022b 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -19,12 +19,19 @@
19#ifndef __BTRFS_ORDERED_DATA__ 19#ifndef __BTRFS_ORDERED_DATA__
20#define __BTRFS_ORDERED_DATA__ 20#define __BTRFS_ORDERED_DATA__
21 21
22/* one of these per inode */
22struct btrfs_ordered_inode_tree { 23struct btrfs_ordered_inode_tree {
23 struct mutex mutex; 24 struct mutex mutex;
24 struct rb_root tree; 25 struct rb_root tree;
25 struct rb_node *last; 26 struct rb_node *last;
26}; 27};
27 28
29/*
30 * these are used to collect checksums done just before bios submission.
31 * They are attached via a list into the ordered extent, and
32 * checksum items are inserted into the tree after all the blocks in
33 * the ordered extent are on disk
34 */
28struct btrfs_sector_sum { 35struct btrfs_sector_sum {
29 u64 offset; 36 u64 offset;
30 u32 sum; 37 u32 sum;
@@ -34,27 +41,56 @@ struct btrfs_ordered_sum {
34 u64 file_offset; 41 u64 file_offset;
35 u64 len; 42 u64 len;
36 struct list_head list; 43 struct list_head list;
44 /* last field is a variable length array of btrfs_sector_sums */
37 struct btrfs_sector_sum sums; 45 struct btrfs_sector_sum sums;
38}; 46};
39 47
40/* bits for the flags field */ 48/*
49 * bits for the flags field:
50 *
51 * BTRFS_ORDERED_IO_DONE is set when all of the blocks are written.
52 * It is used to make sure metadata is inserted into the tree only once
53 * per extent.
54 *
55 * BTRFS_ORDERED_COMPLETE is set when the extent is removed from the
56 * rbtree, just before waking any waiters. It is used to indicate the
57 * IO is done and any metadata is inserted into the tree.
58 */
41#define BTRFS_ORDERED_IO_DONE 0 /* set when all the pages are written */ 59#define BTRFS_ORDERED_IO_DONE 0 /* set when all the pages are written */
60
42#define BTRFS_ORDERED_COMPLETE 1 /* set when removed from the tree */ 61#define BTRFS_ORDERED_COMPLETE 1 /* set when removed from the tree */
43#define BTRFS_ORDERED_START 2 /* set when tree setup */
44 62
45struct btrfs_ordered_extent { 63struct btrfs_ordered_extent {
64 /* logical offset in the file */
46 u64 file_offset; 65 u64 file_offset;
66
67 /* disk byte number */
47 u64 start; 68 u64 start;
69
70 /* length of the extent in bytes */
48 u64 len; 71 u64 len;
72
73 /* flags (described above) */
49 unsigned long flags; 74 unsigned long flags;
75
76 /* reference count */
50 atomic_t refs; 77 atomic_t refs;
78
79 /* list of checksums for insertion when the extent io is done */
51 struct list_head list; 80 struct list_head list;
52 struct inode *inode; 81
82 /* used to wait for the BTRFS_ORDERED_COMPLETE bit */
53 wait_queue_head_t wait; 83 wait_queue_head_t wait;
84
85 /* our friendly rbtree entry */
54 struct rb_node rb_node; 86 struct rb_node rb_node;
55}; 87};
56 88
57 89
90/*
91 * calculates the total size you need to allocate for an ordered sum
92 * structure spanning 'bytes' in the file
93 */
58static inline int btrfs_ordered_sum_size(struct btrfs_root *root, u64 bytes) 94static inline int btrfs_ordered_sum_size(struct btrfs_root *root, u64 bytes)
59{ 95{
60 unsigned long num_sectors = (bytes + root->sectorsize - 1) / 96 unsigned long num_sectors = (bytes + root->sectorsize - 1) /
@@ -81,14 +117,11 @@ int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
81int btrfs_add_ordered_sum(struct inode *inode, struct btrfs_ordered_sum *sum); 117int btrfs_add_ordered_sum(struct inode *inode, struct btrfs_ordered_sum *sum);
82struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode, 118struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode,
83 u64 file_offset); 119 u64 file_offset);
84void btrfs_wait_ordered_extent(struct inode *inode, 120void btrfs_start_ordered_extent(struct inode *inode,
85 struct btrfs_ordered_extent *entry); 121 struct btrfs_ordered_extent *entry, int wait);
86void btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len); 122void btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len);
87struct btrfs_ordered_extent * 123struct btrfs_ordered_extent *
88btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset); 124btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset);
89int btrfs_add_ordered_pending(struct inode *inode,
90 struct btrfs_ordered_extent *ordered,
91 u64 start, u64 len);
92int btrfs_ordered_update_i_size(struct inode *inode, 125int btrfs_ordered_update_i_size(struct inode *inode,
93 struct btrfs_ordered_extent *ordered); 126 struct btrfs_ordered_extent *ordered);
94int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u32 *sum); 127int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u32 *sum);