aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorArne Jansen <sensille@gmx.net>2011-06-10 08:06:53 -0400
committerArne Jansen <sensille@gmx.net>2011-10-02 02:47:55 -0400
commitbb82ab88dfdb12948af58989c75bfe904bc1b09d (patch)
tree1311f5b5ec398cad99aa0da120aed0ee8a224a36 /fs
parent286d6e70aa6cf0f0235653eb1049bfc04610b4fb (diff)
btrfs: add an extra wait mode to read_extent_buffer_pages
read_extent_buffer_pages currently has two modes, either trigger a read without waiting for anything, or wait for the I/O to finish. The former also bails when it's unable to lock the page. This patch now adds an additional parameter to allow it to block on page lock, but don't wait for completion. Changes v5: - merge the 2 wait parameters into one and define WAIT_NONE, WAIT_COMPLETE and WAIT_PAGE_LOCK Change v6: - fix bug introduced in v5 Signed-off-by: Arne Jansen <sensille@gmx.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/disk-io.c5
-rw-r--r--fs/btrfs/extent_io.c7
-rw-r--r--fs/btrfs/extent_io.h3
3 files changed, 9 insertions, 6 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 07b3ac662e19..e6170e142cad 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -367,7 +367,8 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
367 clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags); 367 clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags);
368 io_tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree; 368 io_tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree;
369 while (1) { 369 while (1) {
370 ret = read_extent_buffer_pages(io_tree, eb, start, 1, 370 ret = read_extent_buffer_pages(io_tree, eb, start,
371 WAIT_COMPLETE,
371 btree_get_extent, mirror_num); 372 btree_get_extent, mirror_num);
372 if (!ret && 373 if (!ret &&
373 !verify_parent_transid(io_tree, eb, parent_transid)) 374 !verify_parent_transid(io_tree, eb, parent_transid))
@@ -974,7 +975,7 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
974 if (!buf) 975 if (!buf)
975 return 0; 976 return 0;
976 read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, 977 read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree,
977 buf, 0, 0, btree_get_extent, 0); 978 buf, 0, WAIT_NONE, btree_get_extent, 0);
978 free_extent_buffer(buf); 979 free_extent_buffer(buf);
979 return ret; 980 return ret;
980} 981}
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d418164a35f1..823028e73cf8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3349,8 +3349,7 @@ int extent_buffer_uptodate(struct extent_io_tree *tree,
3349} 3349}
3350 3350
3351int read_extent_buffer_pages(struct extent_io_tree *tree, 3351int read_extent_buffer_pages(struct extent_io_tree *tree,
3352 struct extent_buffer *eb, 3352 struct extent_buffer *eb, u64 start, int wait,
3353 u64 start, int wait,
3354 get_extent_t *get_extent, int mirror_num) 3353 get_extent_t *get_extent, int mirror_num)
3355{ 3354{
3356 unsigned long i; 3355 unsigned long i;
@@ -3386,7 +3385,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
3386 num_pages = num_extent_pages(eb->start, eb->len); 3385 num_pages = num_extent_pages(eb->start, eb->len);
3387 for (i = start_i; i < num_pages; i++) { 3386 for (i = start_i; i < num_pages; i++) {
3388 page = extent_buffer_page(eb, i); 3387 page = extent_buffer_page(eb, i);
3389 if (!wait) { 3388 if (wait == WAIT_NONE) {
3390 if (!trylock_page(page)) 3389 if (!trylock_page(page))
3391 goto unlock_exit; 3390 goto unlock_exit;
3392 } else { 3391 } else {
@@ -3430,7 +3429,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
3430 if (bio) 3429 if (bio)
3431 submit_one_bio(READ, bio, mirror_num, bio_flags); 3430 submit_one_bio(READ, bio, mirror_num, bio_flags);
3432 3431
3433 if (ret || !wait) 3432 if (ret || wait != WAIT_COMPLETE)
3434 return ret; 3433 return ret;
3435 3434
3436 for (i = start_i; i < num_pages; i++) { 3435 for (i = start_i; i < num_pages; i++) {
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 7b2f0c3e7929..6d74c6b34691 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -248,6 +248,9 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
248struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree, 248struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
249 u64 start, unsigned long len); 249 u64 start, unsigned long len);
250void free_extent_buffer(struct extent_buffer *eb); 250void free_extent_buffer(struct extent_buffer *eb);
251#define WAIT_NONE 0
252#define WAIT_COMPLETE 1
253#define WAIT_PAGE_LOCK 2
251int read_extent_buffer_pages(struct extent_io_tree *tree, 254int read_extent_buffer_pages(struct extent_io_tree *tree,
252 struct extent_buffer *eb, u64 start, int wait, 255 struct extent_buffer *eb, u64 start, int wait,
253 get_extent_t *get_extent, int mirror_num); 256 get_extent_t *get_extent, int mirror_num);