aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h87
1 files changed, 61 insertions, 26 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index bfe4a337fb4d..84a6a5b3384a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -100,6 +100,9 @@ struct btrfs_ordered_sum;
100/* tracks free space in block groups. */ 100/* tracks free space in block groups. */
101#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL 101#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
102 102
103/* device stats in the device tree */
104#define BTRFS_DEV_STATS_OBJECTID 0ULL
105
103/* for storing balance parameters in the root tree */ 106/* for storing balance parameters in the root tree */
104#define BTRFS_BALANCE_OBJECTID -4ULL 107#define BTRFS_BALANCE_OBJECTID -4ULL
105 108
@@ -715,14 +718,6 @@ struct btrfs_timespec {
715 __le32 nsec; 718 __le32 nsec;
716} __attribute__ ((__packed__)); 719} __attribute__ ((__packed__));
717 720
718enum btrfs_compression_type {
719 BTRFS_COMPRESS_NONE = 0,
720 BTRFS_COMPRESS_ZLIB = 1,
721 BTRFS_COMPRESS_LZO = 2,
722 BTRFS_COMPRESS_TYPES = 2,
723 BTRFS_COMPRESS_LAST = 3,
724};
725
726struct btrfs_inode_item { 721struct btrfs_inode_item {
727 /* nfs style generation number */ 722 /* nfs style generation number */
728 __le64 generation; 723 __le64 generation;
@@ -793,7 +788,7 @@ struct btrfs_root_item {
793 788
794 /* 789 /*
795 * This generation number is used to test if the new fields are valid 790 * This generation number is used to test if the new fields are valid
796 * and up to date while reading the root item. Everytime the root item 791 * and up to date while reading the root item. Every time the root item
797 * is written out, the "generation" field is copied into this field. If 792 * is written out, the "generation" field is copied into this field. If
798 * anyone ever mounted the fs with an older kernel, we will have 793 * anyone ever mounted the fs with an older kernel, we will have
799 * mismatching generation values here and thus must invalidate the 794 * mismatching generation values here and thus must invalidate the
@@ -1002,8 +997,10 @@ struct btrfs_dev_replace {
1002 pid_t lock_owner; 997 pid_t lock_owner;
1003 atomic_t nesting_level; 998 atomic_t nesting_level;
1004 struct mutex lock_finishing_cancel_unmount; 999 struct mutex lock_finishing_cancel_unmount;
1005 struct mutex lock_management_lock; 1000 rwlock_t lock;
1006 struct mutex lock; 1001 atomic_t read_locks;
1002 atomic_t blocking_readers;
1003 wait_queue_head_t read_lock_wq;
1007 1004
1008 struct btrfs_scrub_progress scrub_progress; 1005 struct btrfs_scrub_progress scrub_progress;
1009}; 1006};
@@ -1222,10 +1219,10 @@ struct btrfs_space_info {
1222 * we've called update_block_group and dropped the bytes_used counter 1219 * we've called update_block_group and dropped the bytes_used counter
1223 * and increased the bytes_pinned counter. However this means that 1220 * and increased the bytes_pinned counter. However this means that
1224 * bytes_pinned does not reflect the bytes that will be pinned once the 1221 * bytes_pinned does not reflect the bytes that will be pinned once the
1225 * delayed refs are flushed, so this counter is inc'ed everytime we call 1222 * delayed refs are flushed, so this counter is inc'ed every time we
1226 * btrfs_free_extent so it is a realtime count of what will be freed 1223 * call btrfs_free_extent so it is a realtime count of what will be
1227 * once the transaction is committed. It will be zero'ed everytime the 1224 * freed once the transaction is committed. It will be zero'ed every
1228 * transaction commits. 1225 * time the transaction commits.
1229 */ 1226 */
1230 struct percpu_counter total_bytes_pinned; 1227 struct percpu_counter total_bytes_pinned;
1231 1228
@@ -1822,6 +1819,9 @@ struct btrfs_fs_info {
1822 spinlock_t reada_lock; 1819 spinlock_t reada_lock;
1823 struct radix_tree_root reada_tree; 1820 struct radix_tree_root reada_tree;
1824 1821
1822 /* readahead works cnt */
1823 atomic_t reada_works_cnt;
1824
1825 /* Extent buffer radix tree */ 1825 /* Extent buffer radix tree */
1826 spinlock_t buffer_lock; 1826 spinlock_t buffer_lock;
1827 struct radix_tree_root buffer_radix; 1827 struct radix_tree_root buffer_radix;
@@ -2185,13 +2185,43 @@ struct btrfs_ioctl_defrag_range_args {
2185 */ 2185 */
2186#define BTRFS_QGROUP_RELATION_KEY 246 2186#define BTRFS_QGROUP_RELATION_KEY 246
2187 2187
2188/*
2189 * Obsolete name, see BTRFS_TEMPORARY_ITEM_KEY.
2190 */
2188#define BTRFS_BALANCE_ITEM_KEY 248 2191#define BTRFS_BALANCE_ITEM_KEY 248
2189 2192
2190/* 2193/*
2191 * Persistantly stores the io stats in the device tree. 2194 * The key type for tree items that are stored persistently, but do not need to
2192 * One key for all stats, (0, BTRFS_DEV_STATS_KEY, devid). 2195 * exist for extended period of time. The items can exist in any tree.
2196 *
2197 * [subtype, BTRFS_TEMPORARY_ITEM_KEY, data]
2198 *
2199 * Existing items:
2200 *
2201 * - balance status item
2202 * (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0)
2193 */ 2203 */
2194#define BTRFS_DEV_STATS_KEY 249 2204#define BTRFS_TEMPORARY_ITEM_KEY 248
2205
2206/*
2207 * Obsolete name, see BTRFS_PERSISTENT_ITEM_KEY
2208 */
2209#define BTRFS_DEV_STATS_KEY 249
2210
2211/*
2212 * The key type for tree items that are stored persistently and usually exist
2213 * for a long period, eg. filesystem lifetime. The item kinds can be status
2214 * information, stats or preference values. The item can exist in any tree.
2215 *
2216 * [subtype, BTRFS_PERSISTENT_ITEM_KEY, data]
2217 *
2218 * Existing items:
2219 *
2220 * - device statistics, store IO stats in the device tree, one key for all
2221 * stats
2222 * (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0)
2223 */
2224#define BTRFS_PERSISTENT_ITEM_KEY 249
2195 2225
2196/* 2226/*
2197 * Persistantly stores the device replace state in the device tree. 2227 * Persistantly stores the device replace state in the device tree.
@@ -2241,7 +2271,7 @@ struct btrfs_ioctl_defrag_range_args {
2241#define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) 2271#define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15)
2242#define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) 2272#define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)
2243#define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) 2273#define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
2244#define BTRFS_MOUNT_RECOVERY (1 << 18) 2274#define BTRFS_MOUNT_USEBACKUPROOT (1 << 18)
2245#define BTRFS_MOUNT_SKIP_BALANCE (1 << 19) 2275#define BTRFS_MOUNT_SKIP_BALANCE (1 << 19)
2246#define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20) 2276#define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20)
2247#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) 2277#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
@@ -2250,9 +2280,10 @@ struct btrfs_ioctl_defrag_range_args {
2250#define BTRFS_MOUNT_FRAGMENT_DATA (1 << 24) 2280#define BTRFS_MOUNT_FRAGMENT_DATA (1 << 24)
2251#define BTRFS_MOUNT_FRAGMENT_METADATA (1 << 25) 2281#define BTRFS_MOUNT_FRAGMENT_METADATA (1 << 25)
2252#define BTRFS_MOUNT_FREE_SPACE_TREE (1 << 26) 2282#define BTRFS_MOUNT_FREE_SPACE_TREE (1 << 26)
2283#define BTRFS_MOUNT_NOLOGREPLAY (1 << 27)
2253 2284
2254#define BTRFS_DEFAULT_COMMIT_INTERVAL (30) 2285#define BTRFS_DEFAULT_COMMIT_INTERVAL (30)
2255#define BTRFS_DEFAULT_MAX_INLINE (8192) 2286#define BTRFS_DEFAULT_MAX_INLINE (2048)
2256 2287
2257#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) 2288#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2258#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) 2289#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
@@ -2353,6 +2384,9 @@ struct btrfs_map_token {
2353 unsigned long offset; 2384 unsigned long offset;
2354}; 2385};
2355 2386
2387#define BTRFS_BYTES_TO_BLKS(fs_info, bytes) \
2388 ((bytes) >> (fs_info)->sb->s_blocksize_bits)
2389
2356static inline void btrfs_init_map_token (struct btrfs_map_token *token) 2390static inline void btrfs_init_map_token (struct btrfs_map_token *token)
2357{ 2391{
2358 token->kaddr = NULL; 2392 token->kaddr = NULL;
@@ -3448,8 +3482,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes);
3448static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root, 3482static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
3449 unsigned num_items) 3483 unsigned num_items)
3450{ 3484{
3451 return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) * 3485 return root->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
3452 2 * num_items;
3453} 3486}
3454 3487
3455/* 3488/*
@@ -4027,7 +4060,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
4027 struct btrfs_root *root, 4060 struct btrfs_root *root,
4028 struct inode *dir, u64 objectid, 4061 struct inode *dir, u64 objectid,
4029 const char *name, int name_len); 4062 const char *name, int name_len);
4030int btrfs_truncate_page(struct inode *inode, loff_t from, loff_t len, 4063int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
4031 int front); 4064 int front);
4032int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, 4065int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
4033 struct btrfs_root *root, 4066 struct btrfs_root *root,
@@ -4089,6 +4122,7 @@ void btrfs_test_inode_set_ops(struct inode *inode);
4089 4122
4090/* ioctl.c */ 4123/* ioctl.c */
4091long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 4124long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
4125int btrfs_ioctl_get_supported_features(void __user *arg);
4092void btrfs_update_iflags(struct inode *inode); 4126void btrfs_update_iflags(struct inode *inode);
4093void btrfs_inherit_iflags(struct inode *inode, struct inode *dir); 4127void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
4094int btrfs_is_empty_uuid(u8 *uuid); 4128int btrfs_is_empty_uuid(u8 *uuid);
@@ -4151,7 +4185,8 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info);
4151ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); 4185ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
4152 4186
4153/* super.c */ 4187/* super.c */
4154int btrfs_parse_options(struct btrfs_root *root, char *options); 4188int btrfs_parse_options(struct btrfs_root *root, char *options,
4189 unsigned long new_flags);
4155int btrfs_sync_fs(struct super_block *sb, int wait); 4190int btrfs_sync_fs(struct super_block *sb, int wait);
4156 4191
4157#ifdef CONFIG_PRINTK 4192#ifdef CONFIG_PRINTK
@@ -4525,8 +4560,8 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
4525 struct btrfs_key *start, struct btrfs_key *end); 4560 struct btrfs_key *start, struct btrfs_key *end);
4526int btrfs_reada_wait(void *handle); 4561int btrfs_reada_wait(void *handle);
4527void btrfs_reada_detach(void *handle); 4562void btrfs_reada_detach(void *handle);
4528int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb, 4563int btree_readahead_hook(struct btrfs_fs_info *fs_info,
4529 u64 start, int err); 4564 struct extent_buffer *eb, u64 start, int err);
4530 4565
4531static inline int is_fstree(u64 rootid) 4566static inline int is_fstree(u64 rootid)
4532{ 4567{