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.h109
1 files changed, 90 insertions, 19 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 9821b672f5a2..926c9ffc66d9 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -154,6 +154,13 @@ struct btrfs_ordered_sum;
154 */ 154 */
155#define BTRFS_NAME_LEN 255 155#define BTRFS_NAME_LEN 255
156 156
157/*
158 * Theoretical limit is larger, but we keep this down to a sane
159 * value. That should limit greatly the possibility of collisions on
160 * inode ref items.
161 */
162#define BTRFS_LINK_MAX 65535U
163
157/* 32 bytes in various csum fields */ 164/* 32 bytes in various csum fields */
158#define BTRFS_CSUM_SIZE 32 165#define BTRFS_CSUM_SIZE 32
159 166
@@ -489,6 +496,8 @@ struct btrfs_super_block {
489 */ 496 */
490#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5) 497#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
491 498
499#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
500
492#define BTRFS_FEATURE_COMPAT_SUPP 0ULL 501#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
493#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL 502#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
494#define BTRFS_FEATURE_INCOMPAT_SUPP \ 503#define BTRFS_FEATURE_INCOMPAT_SUPP \
@@ -496,7 +505,8 @@ struct btrfs_super_block {
496 BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \ 505 BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \
497 BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \ 506 BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \
498 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \ 507 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \
499 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO) 508 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \
509 BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF)
500 510
501/* 511/*
502 * A leaf is full of items. offset and size tell us where to find 512 * A leaf is full of items. offset and size tell us where to find
@@ -643,6 +653,14 @@ struct btrfs_inode_ref {
643 /* name goes here */ 653 /* name goes here */
644} __attribute__ ((__packed__)); 654} __attribute__ ((__packed__));
645 655
656struct btrfs_inode_extref {
657 __le64 parent_objectid;
658 __le64 index;
659 __le16 name_len;
660 __u8 name[0];
661 /* name goes here */
662} __attribute__ ((__packed__));
663
646struct btrfs_timespec { 664struct btrfs_timespec {
647 __le64 sec; 665 __le64 sec;
648 __le32 nsec; 666 __le32 nsec;
@@ -1028,12 +1046,22 @@ struct btrfs_space_info {
1028 wait_queue_head_t wait; 1046 wait_queue_head_t wait;
1029}; 1047};
1030 1048
1049#define BTRFS_BLOCK_RSV_GLOBAL 1
1050#define BTRFS_BLOCK_RSV_DELALLOC 2
1051#define BTRFS_BLOCK_RSV_TRANS 3
1052#define BTRFS_BLOCK_RSV_CHUNK 4
1053#define BTRFS_BLOCK_RSV_DELOPS 5
1054#define BTRFS_BLOCK_RSV_EMPTY 6
1055#define BTRFS_BLOCK_RSV_TEMP 7
1056
1031struct btrfs_block_rsv { 1057struct btrfs_block_rsv {
1032 u64 size; 1058 u64 size;
1033 u64 reserved; 1059 u64 reserved;
1034 struct btrfs_space_info *space_info; 1060 struct btrfs_space_info *space_info;
1035 spinlock_t lock; 1061 spinlock_t lock;
1036 unsigned int full; 1062 unsigned short full;
1063 unsigned short type;
1064 unsigned short failfast;
1037}; 1065};
1038 1066
1039/* 1067/*
@@ -1127,6 +1155,9 @@ struct btrfs_block_group_cache {
1127 * Today it will only have one thing on it, but that may change 1155 * Today it will only have one thing on it, but that may change
1128 */ 1156 */
1129 struct list_head cluster_list; 1157 struct list_head cluster_list;
1158
1159 /* For delayed block group creation */
1160 struct list_head new_bg_list;
1130}; 1161};
1131 1162
1132/* delayed seq elem */ 1163/* delayed seq elem */
@@ -1240,7 +1271,6 @@ struct btrfs_fs_info {
1240 struct mutex reloc_mutex; 1271 struct mutex reloc_mutex;
1241 1272
1242 struct list_head trans_list; 1273 struct list_head trans_list;
1243 struct list_head hashers;
1244 struct list_head dead_roots; 1274 struct list_head dead_roots;
1245 struct list_head caching_block_groups; 1275 struct list_head caching_block_groups;
1246 1276
@@ -1366,9 +1396,6 @@ struct btrfs_fs_info {
1366 struct rb_root defrag_inodes; 1396 struct rb_root defrag_inodes;
1367 atomic_t defrag_running; 1397 atomic_t defrag_running;
1368 1398
1369 spinlock_t ref_cache_lock;
1370 u64 total_ref_cache_size;
1371
1372 /* 1399 /*
1373 * these three are in extended format (availability of single 1400 * these three are in extended format (availability of single
1374 * chunks is denoted by BTRFS_AVAIL_ALLOC_BIT_SINGLE bit, other 1401 * chunks is denoted by BTRFS_AVAIL_ALLOC_BIT_SINGLE bit, other
@@ -1441,6 +1468,8 @@ struct btrfs_fs_info {
1441 1468
1442 /* next backup root to be overwritten */ 1469 /* next backup root to be overwritten */
1443 int backup_root_index; 1470 int backup_root_index;
1471
1472 int num_tolerated_disk_barrier_failures;
1444}; 1473};
1445 1474
1446/* 1475/*
@@ -1481,9 +1510,9 @@ struct btrfs_root {
1481 wait_queue_head_t log_commit_wait[2]; 1510 wait_queue_head_t log_commit_wait[2];
1482 atomic_t log_writers; 1511 atomic_t log_writers;
1483 atomic_t log_commit[2]; 1512 atomic_t log_commit[2];
1513 atomic_t log_batch;
1484 unsigned long log_transid; 1514 unsigned long log_transid;
1485 unsigned long last_log_commit; 1515 unsigned long last_log_commit;
1486 unsigned long log_batch;
1487 pid_t log_start_pid; 1516 pid_t log_start_pid;
1488 bool log_multiple_pids; 1517 bool log_multiple_pids;
1489 1518
@@ -1592,6 +1621,7 @@ struct btrfs_ioctl_defrag_range_args {
1592 */ 1621 */
1593#define BTRFS_INODE_ITEM_KEY 1 1622#define BTRFS_INODE_ITEM_KEY 1
1594#define BTRFS_INODE_REF_KEY 12 1623#define BTRFS_INODE_REF_KEY 12
1624#define BTRFS_INODE_EXTREF_KEY 13
1595#define BTRFS_XATTR_ITEM_KEY 24 1625#define BTRFS_XATTR_ITEM_KEY 24
1596#define BTRFS_ORPHAN_ITEM_KEY 48 1626#define BTRFS_ORPHAN_ITEM_KEY 48
1597/* reserve 2-15 close to the inode for later flexibility */ 1627/* reserve 2-15 close to the inode for later flexibility */
@@ -1978,6 +2008,13 @@ BTRFS_SETGET_STACK_FUNCS(block_group_flags,
1978BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16); 2008BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16);
1979BTRFS_SETGET_FUNCS(inode_ref_index, struct btrfs_inode_ref, index, 64); 2009BTRFS_SETGET_FUNCS(inode_ref_index, struct btrfs_inode_ref, index, 64);
1980 2010
2011/* struct btrfs_inode_extref */
2012BTRFS_SETGET_FUNCS(inode_extref_parent, struct btrfs_inode_extref,
2013 parent_objectid, 64);
2014BTRFS_SETGET_FUNCS(inode_extref_name_len, struct btrfs_inode_extref,
2015 name_len, 16);
2016BTRFS_SETGET_FUNCS(inode_extref_index, struct btrfs_inode_extref, index, 64);
2017
1981/* struct btrfs_inode_item */ 2018/* struct btrfs_inode_item */
1982BTRFS_SETGET_FUNCS(inode_generation, struct btrfs_inode_item, generation, 64); 2019BTRFS_SETGET_FUNCS(inode_generation, struct btrfs_inode_item, generation, 64);
1983BTRFS_SETGET_FUNCS(inode_sequence, struct btrfs_inode_item, sequence, 64); 2020BTRFS_SETGET_FUNCS(inode_sequence, struct btrfs_inode_item, sequence, 64);
@@ -2858,6 +2895,8 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
2858 u64 size); 2895 u64 size);
2859int btrfs_remove_block_group(struct btrfs_trans_handle *trans, 2896int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
2860 struct btrfs_root *root, u64 group_start); 2897 struct btrfs_root *root, u64 group_start);
2898void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
2899 struct btrfs_root *root);
2861u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags); 2900u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags);
2862u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data); 2901u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data);
2863void btrfs_clear_space_info_full(struct btrfs_fs_info *info); 2902void btrfs_clear_space_info_full(struct btrfs_fs_info *info);
@@ -2874,8 +2913,9 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes);
2874void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes); 2913void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes);
2875int btrfs_delalloc_reserve_space(struct inode *inode, u64 num_bytes); 2914int btrfs_delalloc_reserve_space(struct inode *inode, u64 num_bytes);
2876void btrfs_delalloc_release_space(struct inode *inode, u64 num_bytes); 2915void btrfs_delalloc_release_space(struct inode *inode, u64 num_bytes);
2877void btrfs_init_block_rsv(struct btrfs_block_rsv *rsv); 2916void btrfs_init_block_rsv(struct btrfs_block_rsv *rsv, unsigned short type);
2878struct btrfs_block_rsv *btrfs_alloc_block_rsv(struct btrfs_root *root); 2917struct btrfs_block_rsv *btrfs_alloc_block_rsv(struct btrfs_root *root,
2918 unsigned short type);
2879void btrfs_free_block_rsv(struct btrfs_root *root, 2919void btrfs_free_block_rsv(struct btrfs_root *root,
2880 struct btrfs_block_rsv *rsv); 2920 struct btrfs_block_rsv *rsv);
2881int btrfs_block_rsv_add(struct btrfs_root *root, 2921int btrfs_block_rsv_add(struct btrfs_root *root,
@@ -3172,12 +3212,12 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
3172 struct btrfs_root *root, 3212 struct btrfs_root *root,
3173 const char *name, int name_len, 3213 const char *name, int name_len,
3174 u64 inode_objectid, u64 ref_objectid, u64 *index); 3214 u64 inode_objectid, u64 ref_objectid, u64 *index);
3175struct btrfs_inode_ref * 3215int btrfs_get_inode_ref_index(struct btrfs_trans_handle *trans,
3176btrfs_lookup_inode_ref(struct btrfs_trans_handle *trans, 3216 struct btrfs_root *root,
3177 struct btrfs_root *root, 3217 struct btrfs_path *path,
3178 struct btrfs_path *path, 3218 const char *name, int name_len,
3179 const char *name, int name_len, 3219 u64 inode_objectid, u64 ref_objectid, int mod,
3180 u64 inode_objectid, u64 ref_objectid, int mod); 3220 u64 *ret_index);
3181int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans, 3221int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
3182 struct btrfs_root *root, 3222 struct btrfs_root *root,
3183 struct btrfs_path *path, u64 objectid); 3223 struct btrfs_path *path, u64 objectid);
@@ -3185,6 +3225,19 @@ int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
3185 *root, struct btrfs_path *path, 3225 *root, struct btrfs_path *path,
3186 struct btrfs_key *location, int mod); 3226 struct btrfs_key *location, int mod);
3187 3227
3228struct btrfs_inode_extref *
3229btrfs_lookup_inode_extref(struct btrfs_trans_handle *trans,
3230 struct btrfs_root *root,
3231 struct btrfs_path *path,
3232 const char *name, int name_len,
3233 u64 inode_objectid, u64 ref_objectid, int ins_len,
3234 int cow);
3235
3236int btrfs_find_name_in_ext_backref(struct btrfs_path *path,
3237 u64 ref_objectid, const char *name,
3238 int name_len,
3239 struct btrfs_inode_extref **extref_ret);
3240
3188/* file-item.c */ 3241/* file-item.c */
3189int btrfs_del_csums(struct btrfs_trans_handle *trans, 3242int btrfs_del_csums(struct btrfs_trans_handle *trans,
3190 struct btrfs_root *root, u64 bytenr, u64 len); 3243 struct btrfs_root *root, u64 bytenr, u64 len);
@@ -3249,6 +3302,8 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
3249 struct btrfs_root *root, 3302 struct btrfs_root *root,
3250 struct inode *dir, u64 objectid, 3303 struct inode *dir, u64 objectid,
3251 const char *name, int name_len); 3304 const char *name, int name_len);
3305int btrfs_truncate_page(struct inode *inode, loff_t from, loff_t len,
3306 int front);
3252int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, 3307int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
3253 struct btrfs_root *root, 3308 struct btrfs_root *root,
3254 struct inode *inode, u64 new_size, 3309 struct inode *inode, u64 new_size,
@@ -3308,16 +3363,27 @@ void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3308int btrfs_defrag_file(struct inode *inode, struct file *file, 3363int btrfs_defrag_file(struct inode *inode, struct file *file,
3309 struct btrfs_ioctl_defrag_range_args *range, 3364 struct btrfs_ioctl_defrag_range_args *range,
3310 u64 newer_than, unsigned long max_pages); 3365 u64 newer_than, unsigned long max_pages);
3366void btrfs_get_block_group_info(struct list_head *groups_list,
3367 struct btrfs_ioctl_space_info *space);
3368
3311/* file.c */ 3369/* file.c */
3312int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, 3370int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
3313 struct inode *inode); 3371 struct inode *inode);
3314int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info); 3372int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info);
3315int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync); 3373int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
3316int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, 3374void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
3317 int skip_pinned); 3375 int skip_pinned);
3376int btrfs_replace_extent_cache(struct inode *inode, struct extent_map *replace,
3377 u64 start, u64 end, int skip_pinned,
3378 int modified);
3318extern const struct file_operations btrfs_file_operations; 3379extern const struct file_operations btrfs_file_operations;
3319int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode, 3380int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
3320 u64 start, u64 end, u64 *hint_byte, int drop_cache); 3381 struct btrfs_root *root, struct inode *inode,
3382 struct btrfs_path *path, u64 start, u64 end,
3383 u64 *drop_end, int drop_cache);
3384int btrfs_drop_extents(struct btrfs_trans_handle *trans,
3385 struct btrfs_root *root, struct inode *inode, u64 start,
3386 u64 end, int drop_cache);
3321int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, 3387int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
3322 struct inode *inode, u64 start, u64 end); 3388 struct inode *inode, u64 start, u64 end);
3323int btrfs_release_file(struct inode *inode, struct file *file); 3389int btrfs_release_file(struct inode *inode, struct file *file);
@@ -3378,6 +3444,11 @@ static inline void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info,
3378 } 3444 }
3379} 3445}
3380 3446
3447/*
3448 * Call btrfs_abort_transaction as early as possible when an error condition is
3449 * detected, that way the exact line number is reported.
3450 */
3451
3381#define btrfs_abort_transaction(trans, root, errno) \ 3452#define btrfs_abort_transaction(trans, root, errno) \
3382do { \ 3453do { \
3383 __btrfs_abort_transaction(trans, root, __func__, \ 3454 __btrfs_abort_transaction(trans, root, __func__, \