@@ -99,6 +99,9 @@ struct btrfs_ordered_sum;
99
99
*/
100
100
#define BTRFS_EXTENT_CSUM_OBJECTID -10ULL
101
101
102
+ /* For storing free space cache */
103
+ #define BTRFS_FREE_SPACE_OBJECTID -11ULL
104
+
102
105
/* dummy objectid represents multiple objectids */
103
106
#define BTRFS_MULTIPLE_OBJECTIDS -255ULL
104
107
@@ -265,6 +268,22 @@ struct btrfs_chunk {
265
268
/* additional stripes go here */
266
269
} __attribute__ ((__packed__ ));
267
270
271
+ #define BTRFS_FREE_SPACE_EXTENT 1
272
+ #define BTRFS_FREE_SPACE_BITMAP 2
273
+
274
+ struct btrfs_free_space_entry {
275
+ __le64 offset ;
276
+ __le64 bytes ;
277
+ u8 type ;
278
+ } __attribute__ ((__packed__ ));
279
+
280
+ struct btrfs_free_space_header {
281
+ struct btrfs_disk_key location ;
282
+ __le64 generation ;
283
+ __le64 num_entries ;
284
+ __le64 num_bitmaps ;
285
+ } __attribute__ ((__packed__ ));
286
+
268
287
static inline unsigned long btrfs_chunk_item_size (int num_stripes )
269
288
{
270
289
BUG_ON (num_stripes == 0 );
@@ -365,8 +384,10 @@ struct btrfs_super_block {
365
384
366
385
char label [BTRFS_LABEL_SIZE ];
367
386
387
+ __le64 cache_generation ;
388
+
368
389
/* future expansion */
369
- __le64 reserved [32 ];
390
+ __le64 reserved [31 ];
370
391
u8 sys_chunk_array [BTRFS_SYSTEM_CHUNK_ARRAY_SIZE ];
371
392
} __attribute__ ((__packed__ ));
372
393
@@ -375,12 +396,12 @@ struct btrfs_super_block {
375
396
* ones specified below then we will fail to mount
376
397
*/
377
398
#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
378
- #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (2ULL << 0 )
399
+ #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1 )
379
400
380
401
#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
381
402
#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
382
- #define BTRFS_FEATURE_INCOMPAT_SUPP \
383
- (BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
403
+ #define BTRFS_FEATURE_INCOMPAT_SUPP \
404
+ (BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
384
405
BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL)
385
406
386
407
/*
@@ -750,6 +771,14 @@ enum btrfs_caching_type {
750
771
BTRFS_CACHE_FINISHED = 2 ,
751
772
};
752
773
774
+ enum btrfs_disk_cache_state {
775
+ BTRFS_DC_WRITTEN = 0 ,
776
+ BTRFS_DC_ERROR = 1 ,
777
+ BTRFS_DC_CLEAR = 2 ,
778
+ BTRFS_DC_SETUP = 3 ,
779
+ BTRFS_DC_NEED_WRITE = 4 ,
780
+ };
781
+
753
782
struct btrfs_caching_control {
754
783
struct list_head list ;
755
784
struct mutex mutex ;
@@ -763,6 +792,7 @@ struct btrfs_block_group_cache {
763
792
struct btrfs_key key ;
764
793
struct btrfs_block_group_item item ;
765
794
struct btrfs_fs_info * fs_info ;
795
+ struct inode * inode ;
766
796
spinlock_t lock ;
767
797
u64 pinned ;
768
798
u64 reserved ;
@@ -773,8 +803,11 @@ struct btrfs_block_group_cache {
773
803
int extents_thresh ;
774
804
int free_extents ;
775
805
int total_bitmaps ;
776
- int ro ;
777
- int dirty ;
806
+ int ro :1 ;
807
+ int dirty :1 ;
808
+ int iref :1 ;
809
+
810
+ int disk_cache_state ;
778
811
779
812
/* cache tracking stuff */
780
813
int cached ;
@@ -1192,6 +1225,7 @@ struct btrfs_root {
1192
1225
#define BTRFS_MOUNT_NOSSD (1 << 9)
1193
1226
#define BTRFS_MOUNT_DISCARD (1 << 10)
1194
1227
#define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
1228
+ #define BTRFS_MOUNT_SPACE_CACHE (1 << 12)
1195
1229
1196
1230
#define btrfs_clear_opt (o , opt ) ((o) &= ~BTRFS_MOUNT_##opt)
1197
1231
#define btrfs_set_opt (o , opt ) ((o) |= BTRFS_MOUNT_##opt)
@@ -1665,6 +1699,27 @@ static inline void btrfs_set_dir_item_key(struct extent_buffer *eb,
1665
1699
write_eb_member (eb , item , struct btrfs_dir_item , location , key );
1666
1700
}
1667
1701
1702
+ BTRFS_SETGET_FUNCS (free_space_entries , struct btrfs_free_space_header ,
1703
+ num_entries , 64 );
1704
+ BTRFS_SETGET_FUNCS (free_space_bitmaps , struct btrfs_free_space_header ,
1705
+ num_bitmaps , 64 );
1706
+ BTRFS_SETGET_FUNCS (free_space_generation , struct btrfs_free_space_header ,
1707
+ generation , 64 );
1708
+
1709
+ static inline void btrfs_free_space_key (struct extent_buffer * eb ,
1710
+ struct btrfs_free_space_header * h ,
1711
+ struct btrfs_disk_key * key )
1712
+ {
1713
+ read_eb_member (eb , h , struct btrfs_free_space_header , location , key );
1714
+ }
1715
+
1716
+ static inline void btrfs_set_free_space_key (struct extent_buffer * eb ,
1717
+ struct btrfs_free_space_header * h ,
1718
+ struct btrfs_disk_key * key )
1719
+ {
1720
+ write_eb_member (eb , h , struct btrfs_free_space_header , location , key );
1721
+ }
1722
+
1668
1723
/* struct btrfs_disk_key */
1669
1724
BTRFS_SETGET_STACK_FUNCS (disk_key_objectid , struct btrfs_disk_key ,
1670
1725
objectid , 64 );
@@ -1876,6 +1931,8 @@ BTRFS_SETGET_STACK_FUNCS(super_incompat_flags, struct btrfs_super_block,
1876
1931
incompat_flags , 64 );
1877
1932
BTRFS_SETGET_STACK_FUNCS (super_csum_type , struct btrfs_super_block ,
1878
1933
csum_type , 16 );
1934
+ BTRFS_SETGET_STACK_FUNCS (super_cache_generation , struct btrfs_super_block ,
1935
+ cache_generation , 64 );
1879
1936
1880
1937
static inline int btrfs_super_csum_size (struct btrfs_super_block * s )
1881
1938
{
@@ -2115,6 +2172,7 @@ int btrfs_set_block_group_ro(struct btrfs_root *root,
2115
2172
struct btrfs_block_group_cache * cache );
2116
2173
int btrfs_set_block_group_rw (struct btrfs_root * root ,
2117
2174
struct btrfs_block_group_cache * cache );
2175
+ void btrfs_put_block_group_cache (struct btrfs_fs_info * info );
2118
2176
/* ctree.c */
2119
2177
int btrfs_bin_search (struct extent_buffer * eb , struct btrfs_key * key ,
2120
2178
int level , int * slot );
@@ -2426,6 +2484,10 @@ void btrfs_run_delayed_iputs(struct btrfs_root *root);
2426
2484
int btrfs_prealloc_file_range (struct inode * inode , int mode ,
2427
2485
u64 start , u64 num_bytes , u64 min_size ,
2428
2486
loff_t actual_len , u64 * alloc_hint );
2487
+ int btrfs_prealloc_file_range_trans (struct inode * inode ,
2488
+ struct btrfs_trans_handle * trans , int mode ,
2489
+ u64 start , u64 num_bytes , u64 min_size ,
2490
+ loff_t actual_len , u64 * alloc_hint );
2429
2491
extern const struct dentry_operations btrfs_dentry_operations ;
2430
2492
2431
2493
/* ioctl.c */
0 commit comments