mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	btrfs: add READAHEAD extent buffer flag
Add a READAHEAD extent buffer flag. Add a function to trigger a read with this flag set. Changes v2: - use extent buffer flags instead of extent state flags Changes v5: - adapt to changed read_extent_buffer_pages interface - don't return eb from reada_tree_block_flagged if it has CORRUPT flag set Signed-off-by: Arne Jansen <sensille@gmx.net>
This commit is contained in:
		
							parent
							
								
									bb82ab88df
								
							
						
					
					
						commit
						ab0fff0305
					
				
					 3 changed files with 35 additions and 0 deletions
				
			
		| 
						 | 
					@ -980,6 +980,38 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize,
 | 
				
			||||||
 | 
								 int mirror_num, struct extent_buffer **eb)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct extent_buffer *buf = NULL;
 | 
				
			||||||
 | 
						struct inode *btree_inode = root->fs_info->btree_inode;
 | 
				
			||||||
 | 
						struct extent_io_tree *io_tree = &BTRFS_I(btree_inode)->io_tree;
 | 
				
			||||||
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						buf = btrfs_find_create_tree_block(root, bytenr, blocksize);
 | 
				
			||||||
 | 
						if (!buf)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						set_bit(EXTENT_BUFFER_READAHEAD, &buf->bflags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = read_extent_buffer_pages(io_tree, buf, 0, WAIT_PAGE_LOCK,
 | 
				
			||||||
 | 
									       btree_get_extent, mirror_num);
 | 
				
			||||||
 | 
						if (ret) {
 | 
				
			||||||
 | 
							free_extent_buffer(buf);
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (test_bit(EXTENT_BUFFER_CORRUPT, &buf->bflags)) {
 | 
				
			||||||
 | 
							free_extent_buffer(buf);
 | 
				
			||||||
 | 
							return -EIO;
 | 
				
			||||||
 | 
						} else if (extent_buffer_uptodate(io_tree, buf, NULL)) {
 | 
				
			||||||
 | 
							*eb = buf;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							free_extent_buffer(buf);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
 | 
					struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
 | 
				
			||||||
					    u64 bytenr, u32 blocksize)
 | 
										    u64 bytenr, u32 blocksize)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,6 +40,8 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
 | 
				
			||||||
				      u32 blocksize, u64 parent_transid);
 | 
									      u32 blocksize, u64 parent_transid);
 | 
				
			||||||
int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
 | 
					int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
 | 
				
			||||||
			 u64 parent_transid);
 | 
								 u64 parent_transid);
 | 
				
			||||||
 | 
					int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize,
 | 
				
			||||||
 | 
								 int mirror_num, struct extent_buffer **eb);
 | 
				
			||||||
struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
 | 
					struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
 | 
				
			||||||
						   u64 bytenr, u32 blocksize);
 | 
											   u64 bytenr, u32 blocksize);
 | 
				
			||||||
int clean_tree_block(struct btrfs_trans_handle *trans,
 | 
					int clean_tree_block(struct btrfs_trans_handle *trans,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,6 +32,7 @@
 | 
				
			||||||
#define EXTENT_BUFFER_BLOCKING 1
 | 
					#define EXTENT_BUFFER_BLOCKING 1
 | 
				
			||||||
#define EXTENT_BUFFER_DIRTY 2
 | 
					#define EXTENT_BUFFER_DIRTY 2
 | 
				
			||||||
#define EXTENT_BUFFER_CORRUPT 3
 | 
					#define EXTENT_BUFFER_CORRUPT 3
 | 
				
			||||||
 | 
					#define EXTENT_BUFFER_READAHEAD 4	/* this got triggered by readahead */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* these are flags for extent_clear_unlock_delalloc */
 | 
					/* these are flags for extent_clear_unlock_delalloc */
 | 
				
			||||||
#define EXTENT_CLEAR_UNLOCK_PAGE 0x1
 | 
					#define EXTENT_CLEAR_UNLOCK_PAGE 0x1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue