370
405
* ones specified below then we will fail to mount
372
407
#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
408
#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
409
#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
410
#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
374
412
#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
375
413
#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
376
#define BTRFS_FEATURE_INCOMPAT_SUPP \
377
BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF
414
#define BTRFS_FEATURE_INCOMPAT_SUPP \
415
(BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
416
BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \
417
BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \
418
BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO)
380
421
* A leaf is full of items. offset and size tell us where to find
667
713
struct btrfs_space_info {
670
u64 total_bytes; /* total bytes in the space */
671
u64 bytes_used; /* total bytes used on disk */
716
u64 total_bytes; /* total bytes in the space,
717
this doesn't take mirrors into account */
718
u64 bytes_used; /* total bytes used,
719
this does't take mirrors into account */
672
720
u64 bytes_pinned; /* total bytes pinned, will be freed when the
673
721
transaction finishes */
674
722
u64 bytes_reserved; /* total bytes the allocator has reserved for
675
723
current allocations */
676
724
u64 bytes_readonly; /* total bytes that are read only */
677
u64 bytes_super; /* total bytes reserved for the super blocks */
678
u64 bytes_root; /* the number of bytes needed to commit a
680
726
u64 bytes_may_use; /* number of bytes that may be used for
681
727
delalloc/allocations */
682
u64 bytes_delalloc; /* number of bytes currently reserved for
683
delayed allocation */
728
u64 disk_used; /* total bytes used on disk */
729
u64 disk_total; /* total bytes on disk, takes mirrors into
733
* we bump reservation progress every time we decrement
734
* bytes_reserved. This way people waiting for reservations
735
* know something good has happened and they can check
736
* for progress. The number here isn't to be trusted, it
737
* just shows reclaim activity
739
unsigned long reservation_progress;
685
741
int full; /* indicates that we cannot allocate any more
686
742
chunks for this space */
687
743
int force_alloc; /* set if we need to force a chunk alloc for
689
int force_delalloc; /* make people start doing filemap_flush until
690
we're under a threshold */
692
746
struct list_head list;
694
/* for controlling how we free up space for allocations */
695
wait_queue_head_t allocate_wait;
696
wait_queue_head_t flush_wait;
697
int allocating_chunk;
700
748
/* for block groups in our same type */
701
struct list_head block_groups;
749
struct list_head block_groups[BTRFS_NR_RAID_TYPES];
703
751
struct rw_semaphore groups_sem;
704
752
atomic_t caching_threads;
755
struct btrfs_block_rsv {
759
struct btrfs_space_info *space_info;
760
struct list_head list;
763
unsigned int priority:8;
764
unsigned int durable:1;
765
unsigned int refill_used:1;
708
770
* free clusters are used to claim free space in relatively large chunks,
709
771
* allowing us to do less seeky writes. They are used for all metadata
819
894
/* logical->physical extent mapping */
820
895
struct btrfs_mapping_tree mapping_tree;
897
/* block reservation for extent, checksum and root tree */
898
struct btrfs_block_rsv global_block_rsv;
899
/* block reservation for delay allocation */
900
struct btrfs_block_rsv delalloc_block_rsv;
901
/* block reservation for metadata operations */
902
struct btrfs_block_rsv trans_block_rsv;
903
/* block reservation for chunk tree */
904
struct btrfs_block_rsv chunk_block_rsv;
906
struct btrfs_block_rsv empty_block_rsv;
908
/* list of block reservations that cross multiple transactions */
909
struct list_head durable_block_rsv_list;
911
struct mutex durable_block_rsv_mutex;
823
914
u64 last_trans_committed;
1628
1737
write_eb_member(eb, item, struct btrfs_dir_item, location, key);
1740
BTRFS_SETGET_FUNCS(free_space_entries, struct btrfs_free_space_header,
1742
BTRFS_SETGET_FUNCS(free_space_bitmaps, struct btrfs_free_space_header,
1744
BTRFS_SETGET_FUNCS(free_space_generation, struct btrfs_free_space_header,
1747
static inline void btrfs_free_space_key(struct extent_buffer *eb,
1748
struct btrfs_free_space_header *h,
1749
struct btrfs_disk_key *key)
1751
read_eb_member(eb, h, struct btrfs_free_space_header, location, key);
1754
static inline void btrfs_set_free_space_key(struct extent_buffer *eb,
1755
struct btrfs_free_space_header *h,
1756
struct btrfs_disk_key *key)
1758
write_eb_member(eb, h, struct btrfs_free_space_header, location, key);
1631
1761
/* struct btrfs_disk_key */
1632
1762
BTRFS_SETGET_STACK_FUNCS(disk_key_objectid, struct btrfs_disk_key,
1951
2088
return file->f_path.dentry;
2091
static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info)
2093
return ((space_info->flags & BTRFS_BLOCK_GROUP_METADATA) &&
2094
(space_info->flags & BTRFS_BLOCK_GROUP_DATA));
1954
2097
/* extent-tree.c */
1955
2098
void btrfs_put_block_group(struct btrfs_block_group_cache *cache);
1956
2099
int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
1957
2100
struct btrfs_root *root, unsigned long count);
1958
2101
int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len);
2102
int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
2103
struct btrfs_root *root, u64 bytenr,
2104
u64 num_bytes, u64 *refs, u64 *flags);
1959
2105
int btrfs_pin_extent(struct btrfs_root *root,
1960
2106
u64 bytenr, u64 num, int reserved);
1961
2107
int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
2029
2179
int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
2030
2180
struct btrfs_root *root, u64 group_start);
2031
int btrfs_prepare_block_group_relocation(struct btrfs_root *root,
2032
struct btrfs_block_group_cache *group);
2034
2181
u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags);
2182
u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data);
2035
2183
void btrfs_set_inode_space_info(struct btrfs_root *root, struct inode *ionde);
2036
2184
void btrfs_clear_space_info_full(struct btrfs_fs_info *info);
2185
int btrfs_check_data_free_space(struct inode *inode, u64 bytes);
2186
void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes);
2187
int btrfs_trans_reserve_metadata(struct btrfs_trans_handle *trans,
2188
struct btrfs_root *root,
2190
void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
2191
struct btrfs_root *root);
2192
int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,
2193
struct inode *inode);
2194
void btrfs_orphan_release_metadata(struct inode *inode);
2195
int btrfs_snap_reserve_metadata(struct btrfs_trans_handle *trans,
2196
struct btrfs_pending_snapshot *pending);
2197
int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes);
2198
void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes);
2199
int btrfs_delalloc_reserve_space(struct inode *inode, u64 num_bytes);
2200
void btrfs_delalloc_release_space(struct inode *inode, u64 num_bytes);
2201
void btrfs_init_block_rsv(struct btrfs_block_rsv *rsv);
2202
struct btrfs_block_rsv *btrfs_alloc_block_rsv(struct btrfs_root *root);
2203
void btrfs_free_block_rsv(struct btrfs_root *root,
2204
struct btrfs_block_rsv *rsv);
2205
void btrfs_add_durable_block_rsv(struct btrfs_fs_info *fs_info,
2206
struct btrfs_block_rsv *rsv);
2207
int btrfs_block_rsv_add(struct btrfs_trans_handle *trans,
2208
struct btrfs_root *root,
2209
struct btrfs_block_rsv *block_rsv,
2211
int btrfs_block_rsv_check(struct btrfs_trans_handle *trans,
2212
struct btrfs_root *root,
2213
struct btrfs_block_rsv *block_rsv,
2214
u64 min_reserved, int min_factor);
2215
int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv,
2216
struct btrfs_block_rsv *dst_rsv,
2218
void btrfs_block_rsv_release(struct btrfs_root *root,
2219
struct btrfs_block_rsv *block_rsv,
2221
int btrfs_set_block_group_ro(struct btrfs_root *root,
2222
struct btrfs_block_group_cache *cache);
2223
int btrfs_set_block_group_rw(struct btrfs_root *root,
2224
struct btrfs_block_group_cache *cache);
2225
void btrfs_put_block_group_cache(struct btrfs_fs_info *info);
2226
u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo);
2227
int btrfs_error_unpin_extent_range(struct btrfs_root *root,
2228
u64 start, u64 end);
2229
int btrfs_error_discard_extent(struct btrfs_root *root, u64 bytenr,
2231
int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans,
2232
struct btrfs_root *root, u64 type);
2038
int btrfs_reserve_metadata_space(struct btrfs_root *root, int num_items);
2039
int btrfs_unreserve_metadata_space(struct btrfs_root *root, int num_items);
2040
int btrfs_unreserve_metadata_for_delalloc(struct btrfs_root *root,
2041
struct inode *inode, int num_items);
2042
int btrfs_reserve_metadata_for_delalloc(struct btrfs_root *root,
2043
struct inode *inode, int num_items);
2044
int btrfs_check_data_free_space(struct btrfs_root *root, struct inode *inode,
2046
void btrfs_free_reserved_data_space(struct btrfs_root *root,
2047
struct inode *inode, u64 bytes);
2048
void btrfs_delalloc_reserve_space(struct btrfs_root *root, struct inode *inode,
2050
void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode,
2053
2235
int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key,
2054
2236
int level, int *slot);
2196
2383
struct btrfs_path *path,
2197
2384
struct btrfs_dir_item *di);
2198
2385
int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
2199
struct btrfs_root *root, const char *name,
2200
u16 name_len, const void *data, u16 data_len,
2386
struct btrfs_root *root,
2387
struct btrfs_path *path, u64 objectid,
2388
const char *name, u16 name_len,
2389
const void *data, u16 data_len);
2202
2390
struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
2203
2391
struct btrfs_root *root,
2204
2392
struct btrfs_path *path, u64 dir,
2292
2488
struct inode *inode, u64 new_size,
2295
int btrfs_start_delalloc_inodes(struct btrfs_root *root);
2296
int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end);
2491
int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput);
2492
int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput,
2494
int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
2495
struct extent_state **cached_state);
2297
2496
int btrfs_writepages(struct address_space *mapping,
2298
2497
struct writeback_control *wbc);
2299
2498
int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
2307
2506
pgoff_t offset, pgoff_t last_index);
2308
2507
int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
2309
2508
int btrfs_readpage(struct file *file, struct page *page);
2310
void btrfs_delete_inode(struct inode *inode);
2509
void btrfs_evict_inode(struct inode *inode);
2311
2510
void btrfs_put_inode(struct inode *inode);
2312
int btrfs_write_inode(struct inode *inode, int wait);
2511
int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc);
2313
2512
void btrfs_dirty_inode(struct inode *inode);
2314
2513
struct inode *btrfs_alloc_inode(struct super_block *sb);
2315
2514
void btrfs_destroy_inode(struct inode *inode);
2316
void btrfs_drop_inode(struct inode *inode);
2515
int btrfs_drop_inode(struct inode *inode);
2317
2516
int btrfs_init_cachep(void);
2318
2517
void btrfs_destroy_cachep(void);
2319
2518
long btrfs_ioctl_trans_end(struct file *file);
2320
2519
struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
2321
struct btrfs_root *root);
2520
struct btrfs_root *root, int *was_new);
2322
2521
int btrfs_commit_write(struct file *file, struct page *page,
2323
2522
unsigned from, unsigned to);
2324
2523
struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
2330
2529
int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode);
2331
2530
int btrfs_orphan_del(struct btrfs_trans_handle *trans, struct inode *inode);
2332
2531
void btrfs_orphan_cleanup(struct btrfs_root *root);
2532
void btrfs_orphan_pre_snapshot(struct btrfs_trans_handle *trans,
2533
struct btrfs_pending_snapshot *pending,
2534
u64 *bytes_to_reserve);
2535
void btrfs_orphan_post_snapshot(struct btrfs_trans_handle *trans,
2536
struct btrfs_pending_snapshot *pending);
2537
void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans,
2538
struct btrfs_root *root);
2333
2539
int btrfs_cont_expand(struct inode *inode, loff_t size);
2334
2540
int btrfs_invalidate_inodes(struct btrfs_root *root);
2541
void btrfs_add_delayed_iput(struct inode *inode);
2542
void btrfs_run_delayed_iputs(struct btrfs_root *root);
2543
int btrfs_prealloc_file_range(struct inode *inode, int mode,
2544
u64 start, u64 num_bytes, u64 min_size,
2545
loff_t actual_len, u64 *alloc_hint);
2546
int btrfs_prealloc_file_range_trans(struct inode *inode,
2547
struct btrfs_trans_handle *trans, int mode,
2548
u64 start, u64 num_bytes, u64 min_size,
2549
loff_t actual_len, u64 *alloc_hint);
2335
2550
extern const struct dentry_operations btrfs_dentry_operations;
2340
2555
void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2343
int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
2558
int btrfs_sync_file(struct file *file, int datasync);
2344
2559
int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
2345
2560
int skip_pinned);
2346
2561
int btrfs_check_file(struct btrfs_root *root, struct inode *inode);
2347
2562
extern const struct file_operations btrfs_file_operations;
2348
int btrfs_drop_extents(struct btrfs_trans_handle *trans,
2349
struct btrfs_root *root, struct inode *inode,
2350
u64 start, u64 end, u64 locked_end,
2351
u64 inline_limit, u64 *hint_block, int drop_cache);
2563
int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode,
2564
u64 start, u64 end, u64 *hint_byte, int drop_cache);
2352
2565
int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
2353
struct btrfs_root *root,
2354
2566
struct inode *inode, u64 start, u64 end);
2355
2567
int btrfs_release_file(struct inode *inode, struct file *file);
2370
2582
ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
2373
u64 btrfs_parse_size(char *str);
2374
2585
int btrfs_parse_options(struct btrfs_root *root, char *options);
2375
2586
int btrfs_sync_fs(struct super_block *sb, int wait);
2587
void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
2588
unsigned int line, int errno);
2590
#define btrfs_std_error(fs_info, errno) \
2593
__btrfs_std_error((fs_info), __func__, __LINE__, (errno));\
2378
2597
#ifdef CONFIG_BTRFS_FS_POSIX_ACL
2379
int btrfs_check_acl(struct inode *inode, int mask);
2598
int btrfs_check_acl(struct inode *inode, int mask, unsigned int flags);
2381
2600
#define btrfs_check_acl NULL
2383
int btrfs_init_acl(struct inode *inode, struct inode *dir);
2602
int btrfs_init_acl(struct btrfs_trans_handle *trans,
2603
struct inode *inode, struct inode *dir);
2384
2604
int btrfs_acl_chmod(struct inode *inode);
2386
2606
/* relocation.c */
2391
2611
struct btrfs_root *root);
2392
2612
int btrfs_recover_relocation(struct btrfs_root *root);
2393
2613
int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len);
2614
void btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
2615
struct btrfs_root *root, struct extent_buffer *buf,
2616
struct extent_buffer *cow);
2617
void btrfs_reloc_pre_snapshot(struct btrfs_trans_handle *trans,
2618
struct btrfs_pending_snapshot *pending,
2619
u64 *bytes_to_reserve);
2620
void btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
2621
struct btrfs_pending_snapshot *pending);