xref: /openbmc/linux/fs/btrfs/volumes.h (revision 6324fbf3)
10b86a832SChris Mason /*
20b86a832SChris Mason  * Copyright (C) 2007 Oracle.  All rights reserved.
30b86a832SChris Mason  *
40b86a832SChris Mason  * This program is free software; you can redistribute it and/or
50b86a832SChris Mason  * modify it under the terms of the GNU General Public
60b86a832SChris Mason  * License v2 as published by the Free Software Foundation.
70b86a832SChris Mason  *
80b86a832SChris Mason  * This program is distributed in the hope that it will be useful,
90b86a832SChris Mason  * but WITHOUT ANY WARRANTY; without even the implied warranty of
100b86a832SChris Mason  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
110b86a832SChris Mason  * General Public License for more details.
120b86a832SChris Mason  *
130b86a832SChris Mason  * You should have received a copy of the GNU General Public
140b86a832SChris Mason  * License along with this program; if not, write to the
150b86a832SChris Mason  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
160b86a832SChris Mason  * Boston, MA 021110-1307, USA.
170b86a832SChris Mason  */
180b86a832SChris Mason 
190b86a832SChris Mason #ifndef __BTRFS_VOLUMES_
200b86a832SChris Mason #define __BTRFS_VOLUMES_
210b86a832SChris Mason struct btrfs_device {
220b86a832SChris Mason 	struct list_head dev_list;
230b86a832SChris Mason 	struct btrfs_root *dev_root;
240b86a832SChris Mason 	struct btrfs_key dev_key;
250b86a832SChris Mason 
260b86a832SChris Mason 	struct block_device *bdev;
270b86a832SChris Mason 
280b86a832SChris Mason 	/* the internal btrfs device id */
290b86a832SChris Mason 	u64 devid;
300b86a832SChris Mason 
310b86a832SChris Mason 	/* size of the device */
320b86a832SChris Mason 	u64 total_bytes;
330b86a832SChris Mason 
340b86a832SChris Mason 	/* bytes used */
350b86a832SChris Mason 	u64 bytes_used;
360b86a832SChris Mason 
370b86a832SChris Mason 	/* optimal io alignment for this device */
380b86a832SChris Mason 	u32 io_align;
390b86a832SChris Mason 
400b86a832SChris Mason 	/* optimal io width for this device */
410b86a832SChris Mason 	u32 io_width;
420b86a832SChris Mason 
430b86a832SChris Mason 	/* minimal io size for this device */
440b86a832SChris Mason 	u32 sector_size;
450b86a832SChris Mason 
460b86a832SChris Mason 	/* the kernel device number */
470b86a832SChris Mason 	u64 rdev;
480b86a832SChris Mason 
490b86a832SChris Mason 	/* type and info about this device */
500b86a832SChris Mason 	u64 type;
510b86a832SChris Mason 
520b86a832SChris Mason 	/* partition number, 0 for whole dev */
530b86a832SChris Mason 	int partition;
540b86a832SChris Mason 
550b86a832SChris Mason 	/* length of the name data at the end of the item */
560b86a832SChris Mason 	int name_len;
570b86a832SChris Mason 
580b86a832SChris Mason 	/* physical drive uuid (or lvm uuid) */
590b86a832SChris Mason 	u8 uuid[BTRFS_DEV_UUID_SIZE];
600b86a832SChris Mason 
610b86a832SChris Mason 	char *name;
620b86a832SChris Mason };
630b86a832SChris Mason 
640b86a832SChris Mason int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
650b86a832SChris Mason 			   struct btrfs_device *device,
660b86a832SChris Mason 			   u64 owner, u64 num_bytes, u64 *start);
670b86a832SChris Mason int btrfs_map_block(struct btrfs_mapping_tree *map_tree,
680b86a832SChris Mason 		    u64 logical, u64 *phys, u64 *length,
690b86a832SChris Mason 		    struct btrfs_device **dev);
700b86a832SChris Mason int btrfs_read_sys_array(struct btrfs_root *root);
710b86a832SChris Mason int btrfs_read_chunk_tree(struct btrfs_root *root);
720b86a832SChris Mason int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
730b86a832SChris Mason 		      struct btrfs_root *extent_root, u64 *start,
746324fbf3SChris Mason 		      u64 *num_bytes, u64 type);
750b86a832SChris Mason void btrfs_mapping_init(struct btrfs_mapping_tree *tree);
760b86a832SChris Mason void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree);
770b86a832SChris Mason int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio);
780b86a832SChris Mason #endif
79