aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-09-29 15:18:18 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-29 15:18:18 -0400
commitd352ac68148b69937d39ca5d48bcc4478e118dbf (patch)
tree7951dd7311999d9e77766acdc7f8e93de97874d8 /fs/btrfs/disk-io.c
parent9a5e1ea1e1e539e244a54afffc330fc368376ab9 (diff)
Btrfs: add and improve comments
This improves the comments at the top of many functions. It didn't dive into the guts of functions because I was trying to avoid merging problems with the new allocator and back reference work. extent-tree.c and volumes.c were both skipped, and there is definitely more work todo in cleaning and commenting the code. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 45b4f7285275..5ee10d3136f5 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -55,6 +55,11 @@ static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf)
55static struct extent_io_ops btree_extent_io_ops; 55static struct extent_io_ops btree_extent_io_ops;
56static void end_workqueue_fn(struct btrfs_work *work); 56static void end_workqueue_fn(struct btrfs_work *work);
57 57
58/*
59 * end_io_wq structs are used to do processing in task context when an IO is
60 * complete. This is used during reads to verify checksums, and it is used
61 * by writes to insert metadata for new file extents after IO is complete.
62 */
58struct end_io_wq { 63struct end_io_wq {
59 struct bio *bio; 64 struct bio *bio;
60 bio_end_io_t *end_io; 65 bio_end_io_t *end_io;
@@ -66,6 +71,11 @@ struct end_io_wq {
66 struct btrfs_work work; 71 struct btrfs_work work;
67}; 72};
68 73
74/*
75 * async submit bios are used to offload expensive checksumming
76 * onto the worker threads. They checksum file and metadata bios
77 * just before they are sent down the IO stack.
78 */
69struct async_submit_bio { 79struct async_submit_bio {
70 struct inode *inode; 80 struct inode *inode;
71 struct bio *bio; 81 struct bio *bio;
@@ -76,6 +86,10 @@ struct async_submit_bio {
76 struct btrfs_work work; 86 struct btrfs_work work;
77}; 87};
78 88
89/*
90 * extents on the btree inode are pretty simple, there's one extent
91 * that covers the entire device
92 */
79struct extent_map *btree_get_extent(struct inode *inode, struct page *page, 93struct extent_map *btree_get_extent(struct inode *inode, struct page *page,
80 size_t page_offset, u64 start, u64 len, 94 size_t page_offset, u64 start, u64 len,
81 int create) 95 int create)
@@ -151,6 +165,10 @@ void btrfs_csum_final(u32 crc, char *result)
151 *(__le32 *)result = ~cpu_to_le32(crc); 165 *(__le32 *)result = ~cpu_to_le32(crc);
152} 166}
153 167
168/*
169 * compute the csum for a btree block, and either verify it or write it
170 * into the csum field of the block.
171 */
154static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, 172static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
155 int verify) 173 int verify)
156{ 174{
@@ -204,6 +222,12 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
204 return 0; 222 return 0;
205} 223}
206 224
225/*
226 * we can't consider a given block up to date unless the transid of the
227 * block matches the transid in the parent node's pointer. This is how we
228 * detect blocks that either didn't get written at all or got written
229 * in the wrong place.
230 */
207static int verify_parent_transid(struct extent_io_tree *io_tree, 231static int verify_parent_transid(struct extent_io_tree *io_tree,
208 struct extent_buffer *eb, u64 parent_transid) 232 struct extent_buffer *eb, u64 parent_transid)
209{ 233{
@@ -228,9 +252,12 @@ out:
228 unlock_extent(io_tree, eb->start, eb->start + eb->len - 1, 252 unlock_extent(io_tree, eb->start, eb->start + eb->len - 1,
229 GFP_NOFS); 253 GFP_NOFS);
230 return ret; 254 return ret;
231
232} 255}
233 256
257/*
258 * helper to read a given tree block, doing retries as required when
259 * the checksums don't match and we have alternate mirrors to try.
260 */
234static int btree_read_extent_buffer_pages(struct btrfs_root *root, 261static int btree_read_extent_buffer_pages(struct btrfs_root *root,
235 struct extent_buffer *eb, 262 struct extent_buffer *eb,
236 u64 start, u64 parent_transid) 263 u64 start, u64 parent_transid)
@@ -260,6 +287,10 @@ printk("read extent buffer pages failed with ret %d mirror no %d\n", ret, mirror
260 return -EIO; 287 return -EIO;
261} 288}
262 289
290/*
291 * checksum a dirty tree block before IO. This has extra checks to make
292 * sure we only fill in the checksum field in the first page of a multi-page block
293 */
263int csum_dirty_buffer(struct btrfs_root *root, struct page *page) 294int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
264{ 295{
265 struct extent_io_tree *tree; 296 struct extent_io_tree *tree;