~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to fs/btrfs/ctree.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <linux/completion.h>
27
27
#include <linux/backing-dev.h>
28
28
#include <linux/wait.h>
 
29
#include <linux/slab.h>
 
30
#include <linux/kobject.h>
29
31
#include <asm/kmap_types.h>
30
32
#include "extent_io.h"
31
33
#include "extent_map.h"
33
35
 
34
36
struct btrfs_trans_handle;
35
37
struct btrfs_transaction;
 
38
struct btrfs_pending_snapshot;
36
39
extern struct kmem_cache *btrfs_trans_handle_cachep;
37
40
extern struct kmem_cache *btrfs_transaction_cachep;
38
41
extern struct kmem_cache *btrfs_bit_radix_cachep;
97
100
 */
98
101
#define BTRFS_EXTENT_CSUM_OBJECTID -10ULL
99
102
 
 
103
/* For storing free space cache */
 
104
#define BTRFS_FREE_SPACE_OBJECTID -11ULL
 
105
 
100
106
/* dummy objectid represents multiple objectids */
101
107
#define BTRFS_MULTIPLE_OBJECTIDS -255ULL
102
108
 
263
269
        /* additional stripes go here */
264
270
} __attribute__ ((__packed__));
265
271
 
 
272
#define BTRFS_FREE_SPACE_EXTENT 1
 
273
#define BTRFS_FREE_SPACE_BITMAP 2
 
274
 
 
275
struct btrfs_free_space_entry {
 
276
        __le64 offset;
 
277
        __le64 bytes;
 
278
        u8 type;
 
279
} __attribute__ ((__packed__));
 
280
 
 
281
struct btrfs_free_space_header {
 
282
        struct btrfs_disk_key location;
 
283
        __le64 generation;
 
284
        __le64 num_entries;
 
285
        __le64 num_bitmaps;
 
286
} __attribute__ ((__packed__));
 
287
 
266
288
static inline unsigned long btrfs_chunk_item_size(int num_stripes)
267
289
{
268
290
        BUG_ON(num_stripes == 0);
273
295
#define BTRFS_FSID_SIZE 16
274
296
#define BTRFS_HEADER_FLAG_WRITTEN       (1ULL << 0)
275
297
#define BTRFS_HEADER_FLAG_RELOC         (1ULL << 1)
 
298
 
 
299
/*
 
300
 * File system states
 
301
 */
 
302
 
 
303
/* Errors detected */
 
304
#define BTRFS_SUPER_FLAG_ERROR          (1ULL << 2)
 
305
 
276
306
#define BTRFS_SUPER_FLAG_SEEDING        (1ULL << 32)
277
307
#define BTRFS_SUPER_FLAG_METADUMP       (1ULL << 33)
278
308
 
310
340
#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
311
341
                                        sizeof(struct btrfs_item) - \
312
342
                                        sizeof(struct btrfs_file_extent_item))
 
343
#define BTRFS_MAX_XATTR_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
 
344
                                 sizeof(struct btrfs_item) -\
 
345
                                 sizeof(struct btrfs_dir_item))
313
346
 
314
347
 
315
348
/*
360
393
 
361
394
        char label[BTRFS_LABEL_SIZE];
362
395
 
 
396
        __le64 cache_generation;
 
397
 
363
398
        /* future expansion */
364
 
        __le64 reserved[32];
 
399
        __le64 reserved[31];
365
400
        u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
366
401
} __attribute__ ((__packed__));
367
402
 
370
405
 * ones specified below then we will fail to mount
371
406
 */
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)
373
411
 
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)
378
419
 
379
420
/*
380
421
 * A leaf is full of items. offset and size tell us where to find
521
562
} __attribute__ ((__packed__));
522
563
 
523
564
enum btrfs_compression_type {
524
 
        BTRFS_COMPRESS_NONE = 0,
525
 
        BTRFS_COMPRESS_ZLIB = 1,
526
 
        BTRFS_COMPRESS_LAST = 2,
 
565
        BTRFS_COMPRESS_NONE  = 0,
 
566
        BTRFS_COMPRESS_ZLIB  = 1,
 
567
        BTRFS_COMPRESS_LZO   = 2,
 
568
        BTRFS_COMPRESS_TYPES = 2,
 
569
        BTRFS_COMPRESS_LAST  = 3,
527
570
};
528
571
 
529
572
struct btrfs_inode_item {
567
610
        u8 type;
568
611
} __attribute__ ((__packed__));
569
612
 
 
613
#define BTRFS_ROOT_SUBVOL_RDONLY        (1ULL << 0)
 
614
 
570
615
struct btrfs_root_item {
571
616
        struct btrfs_inode_item inode;
572
617
        __le64 generation;
657
702
#define BTRFS_BLOCK_GROUP_RAID1    (1 << 4)
658
703
#define BTRFS_BLOCK_GROUP_DUP      (1 << 5)
659
704
#define BTRFS_BLOCK_GROUP_RAID10   (1 << 6)
 
705
#define BTRFS_NR_RAID_TYPES        5
660
706
 
661
707
struct btrfs_block_group_item {
662
708
        __le64 used;
667
713
struct btrfs_space_info {
668
714
        u64 flags;
669
715
 
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
679
 
                                   transaction */
 
725
 
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
 
730
                                   account */
 
731
 
 
732
        /*
 
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
 
738
         */
 
739
        unsigned long reservation_progress;
684
740
 
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
688
744
                                   this space */
689
 
        int force_delalloc;     /* make people start doing filemap_flush until
690
 
                                   we're under a threshold */
691
745
 
692
746
        struct list_head list;
693
747
 
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;
698
 
        int flushing;
699
 
 
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];
702
750
        spinlock_t lock;
703
751
        struct rw_semaphore groups_sem;
704
752
        atomic_t caching_threads;
705
753
};
706
754
 
 
755
struct btrfs_block_rsv {
 
756
        u64 size;
 
757
        u64 reserved;
 
758
        u64 freed[2];
 
759
        struct btrfs_space_info *space_info;
 
760
        struct list_head list;
 
761
        spinlock_t lock;
 
762
        atomic_t usage;
 
763
        unsigned int priority:8;
 
764
        unsigned int durable:1;
 
765
        unsigned int refill_used:1;
 
766
        unsigned int full:1;
 
767
};
 
768
 
707
769
/*
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
738
800
        BTRFS_CACHE_FINISHED    = 2,
739
801
};
740
802
 
 
803
enum btrfs_disk_cache_state {
 
804
        BTRFS_DC_WRITTEN        = 0,
 
805
        BTRFS_DC_ERROR          = 1,
 
806
        BTRFS_DC_CLEAR          = 2,
 
807
        BTRFS_DC_SETUP          = 3,
 
808
        BTRFS_DC_NEED_WRITE     = 4,
 
809
};
 
810
 
741
811
struct btrfs_caching_control {
742
812
        struct list_head list;
743
813
        struct mutex mutex;
751
821
        struct btrfs_key key;
752
822
        struct btrfs_block_group_item item;
753
823
        struct btrfs_fs_info *fs_info;
 
824
        struct inode *inode;
754
825
        spinlock_t lock;
755
826
        u64 pinned;
756
827
        u64 reserved;
 
828
        u64 reserved_pinned;
757
829
        u64 bytes_super;
758
830
        u64 flags;
759
831
        u64 sectorsize;
760
832
        int extents_thresh;
761
833
        int free_extents;
762
834
        int total_bitmaps;
763
 
        int ro;
764
 
        int dirty;
 
835
        unsigned int ro:1;
 
836
        unsigned int dirty:1;
 
837
        unsigned int iref:1;
 
838
 
 
839
        int disk_cache_state;
765
840
 
766
841
        /* cache tracking stuff */
767
842
        int cached;
819
894
        /* logical->physical extent mapping */
820
895
        struct btrfs_mapping_tree mapping_tree;
821
896
 
 
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;
 
905
 
 
906
        struct btrfs_block_rsv empty_block_rsv;
 
907
 
 
908
        /* list of block reservations that cross multiple transactions */
 
909
        struct list_head durable_block_rsv_list;
 
910
 
 
911
        struct mutex durable_block_rsv_mutex;
 
912
 
822
913
        u64 generation;
823
914
        u64 last_trans_committed;
824
915
 
828
919
         */
829
920
        u64 last_trans_log_full_commit;
830
921
        u64 open_ioctl_trans;
831
 
        unsigned long mount_opt;
832
 
        u64 max_extent;
 
922
        unsigned long mount_opt:20;
 
923
        unsigned long compress_type:4;
833
924
        u64 max_inline;
834
925
        u64 alloc_start;
835
926
        struct btrfs_transaction *running_transaction;
836
927
        wait_queue_head_t transaction_throttle;
837
928
        wait_queue_head_t transaction_wait;
 
929
        wait_queue_head_t transaction_blocked_wait;
838
930
        wait_queue_head_t async_submit_wait;
839
931
 
840
932
        struct btrfs_super_block super_copy;
859
951
        struct mutex ordered_operations_mutex;
860
952
        struct rw_semaphore extent_commit_sem;
861
953
 
 
954
        struct rw_semaphore cleanup_work_sem;
 
955
 
862
956
        struct rw_semaphore subvol_sem;
863
 
 
864
957
        struct srcu_struct subvol_srcu;
865
958
 
866
959
        struct list_head trans_list;
868
961
        struct list_head dead_roots;
869
962
        struct list_head caching_block_groups;
870
963
 
 
964
        spinlock_t delayed_iput_lock;
 
965
        struct list_head delayed_iputs;
 
966
 
871
967
        atomic_t nr_async_submits;
872
968
        atomic_t async_submit_draining;
873
969
        atomic_t nr_async_bios;
917
1013
        struct btrfs_workers endio_meta_workers;
918
1014
        struct btrfs_workers endio_meta_write_workers;
919
1015
        struct btrfs_workers endio_write_workers;
 
1016
        struct btrfs_workers endio_freespace_worker;
920
1017
        struct btrfs_workers submit_workers;
921
 
        struct btrfs_workers enospc_workers;
922
1018
        /*
923
1019
         * fixup workers take dirty pages that didn't properly go through
924
1020
         * the cow mechanism and make them safe to write.  It happens
934
1030
        int do_barriers;
935
1031
        int closing;
936
1032
        int log_root_recovering;
 
1033
        int enospc_unlink;
937
1034
 
938
1035
        u64 total_pinned;
939
1036
 
978
1075
        unsigned metadata_ratio;
979
1076
 
980
1077
        void *bdev_holder;
 
1078
 
 
1079
        /* filesystem state */
 
1080
        u64 fs_state;
981
1081
};
982
1082
 
983
1083
/*
1003
1103
        struct completion kobj_unregister;
1004
1104
        struct mutex objectid_mutex;
1005
1105
 
 
1106
        spinlock_t accounting_lock;
 
1107
        struct btrfs_block_rsv *block_rsv;
 
1108
 
1006
1109
        struct mutex log_mutex;
1007
1110
        wait_queue_head_t log_writer_wait;
1008
1111
        wait_queue_head_t log_commit_wait[2];
1039
1142
        struct btrfs_key defrag_progress;
1040
1143
        struct btrfs_key defrag_max;
1041
1144
        int defrag_running;
1042
 
        int defrag_level;
1043
1145
        char *name;
1044
1146
        int in_sysfs;
1045
1147
 
1048
1150
 
1049
1151
        struct list_head root_list;
1050
1152
 
1051
 
        spinlock_t list_lock;
 
1153
        spinlock_t orphan_lock;
1052
1154
        struct list_head orphan_list;
 
1155
        struct btrfs_block_rsv *orphan_block_rsv;
 
1156
        int orphan_item_inserted;
 
1157
        int orphan_cleanup_state;
1053
1158
 
1054
1159
        spinlock_t inode_lock;
1055
1160
        /* red-black tree that keeps track of in-memory inodes */
1154
1259
#define BTRFS_MOUNT_SSD_SPREAD          (1 << 8)
1155
1260
#define BTRFS_MOUNT_NOSSD               (1 << 9)
1156
1261
#define BTRFS_MOUNT_DISCARD             (1 << 10)
 
1262
#define BTRFS_MOUNT_FORCE_COMPRESS      (1 << 11)
 
1263
#define BTRFS_MOUNT_SPACE_CACHE         (1 << 12)
 
1264
#define BTRFS_MOUNT_CLEAR_CACHE         (1 << 13)
 
1265
#define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14)
 
1266
#define BTRFS_MOUNT_ENOSPC_DEBUG         (1 << 15)
1157
1267
 
1158
1268
#define btrfs_clear_opt(o, opt)         ((o) &= ~BTRFS_MOUNT_##opt)
1159
1269
#define btrfs_set_opt(o, opt)           ((o) |= BTRFS_MOUNT_##opt)
1174
1284
#define BTRFS_INODE_NOATIME             (1 << 9)
1175
1285
#define BTRFS_INODE_DIRSYNC             (1 << 10)
1176
1286
 
1177
 
 
1178
1287
/* some macros to generate set/get funcs for the struct fields.  This
1179
1288
 * assumes there is a lefoo_to_cpu for every type, so lets make a simple
1180
1289
 * one for u8:
1628
1737
        write_eb_member(eb, item, struct btrfs_dir_item, location, key);
1629
1738
}
1630
1739
 
 
1740
BTRFS_SETGET_FUNCS(free_space_entries, struct btrfs_free_space_header,
 
1741
                   num_entries, 64);
 
1742
BTRFS_SETGET_FUNCS(free_space_bitmaps, struct btrfs_free_space_header,
 
1743
                   num_bitmaps, 64);
 
1744
BTRFS_SETGET_FUNCS(free_space_generation, struct btrfs_free_space_header,
 
1745
                   generation, 64);
 
1746
 
 
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)
 
1750
{
 
1751
        read_eb_member(eb, h, struct btrfs_free_space_header, location, key);
 
1752
}
 
1753
 
 
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)
 
1757
{
 
1758
        write_eb_member(eb, h, struct btrfs_free_space_header, location, key);
 
1759
}
 
1760
 
1631
1761
/* struct btrfs_disk_key */
1632
1762
BTRFS_SETGET_STACK_FUNCS(disk_key_objectid, struct btrfs_disk_key,
1633
1763
                         objectid, 64);
1792
1922
BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item,
1793
1923
                         last_snapshot, 64);
1794
1924
 
 
1925
static inline bool btrfs_root_readonly(struct btrfs_root *root)
 
1926
{
 
1927
        return root->root_item.flags & BTRFS_ROOT_SUBVOL_RDONLY;
 
1928
}
 
1929
 
1795
1930
/* struct btrfs_super_block */
1796
1931
 
1797
1932
BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64);
1834
1969
BTRFS_SETGET_STACK_FUNCS(super_compat_flags, struct btrfs_super_block,
1835
1970
                         compat_flags, 64);
1836
1971
BTRFS_SETGET_STACK_FUNCS(super_compat_ro_flags, struct btrfs_super_block,
1837
 
                         compat_flags, 64);
 
1972
                         compat_ro_flags, 64);
1838
1973
BTRFS_SETGET_STACK_FUNCS(super_incompat_flags, struct btrfs_super_block,
1839
1974
                         incompat_flags, 64);
1840
1975
BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block,
1841
1976
                         csum_type, 16);
 
1977
BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block,
 
1978
                         cache_generation, 64);
1842
1979
 
1843
1980
static inline int btrfs_super_csum_size(struct btrfs_super_block *s)
1844
1981
{
1951
2088
        return file->f_path.dentry;
1952
2089
}
1953
2090
 
 
2091
static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info)
 
2092
{
 
2093
        return ((space_info->flags & BTRFS_BLOCK_GROUP_METADATA) &&
 
2094
                (space_info->flags & BTRFS_BLOCK_GROUP_DATA));
 
2095
}
 
2096
 
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,
1975
2121
                                        u64 parent, u64 root_objectid,
1976
2122
                                        struct btrfs_disk_key *key, int level,
1977
2123
                                        u64 hint, u64 empty_size);
 
2124
void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
 
2125
                           struct btrfs_root *root,
 
2126
                           struct extent_buffer *buf,
 
2127
                           u64 parent, int last_ref);
1978
2128
struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans,
1979
2129
                                            struct btrfs_root *root,
1980
2130
                                            u64 bytenr, u32 blocksize,
2028
2178
                           u64 size);
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);
2033
 
 
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,
 
2189
                                int num_items);
 
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,
 
2210
                        u64 num_bytes);
 
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,
 
2217
                            u64 num_bytes);
 
2218
void btrfs_block_rsv_release(struct btrfs_root *root,
 
2219
                             struct btrfs_block_rsv *block_rsv,
 
2220
                             u64 num_bytes);
 
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,
 
2230
                               u64 num_bytes);
 
2231
int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans,
 
2232
                            struct btrfs_root *root, u64 type);
2037
2233
 
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,
2045
 
                                u64 bytes);
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,
2049
 
                                 u64 bytes);
2050
 
void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode,
2051
 
                              u64 bytes);
2052
2234
/* ctree.c */
2053
2235
int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key,
2054
2236
                     int level, int *slot);
2089
2271
                     struct btrfs_path *path,
2090
2272
                     struct btrfs_key *new_key,
2091
2273
                     unsigned long split_offset);
 
2274
int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
 
2275
                         struct btrfs_root *root,
 
2276
                         struct btrfs_path *path,
 
2277
                         struct btrfs_key *new_key);
2092
2278
int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
2093
2279
                      *root, struct btrfs_key *key, struct btrfs_path *p, int
2094
2280
                      ins_len, int cow);
2135
2321
int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
2136
2322
int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
2137
2323
int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf);
2138
 
int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref);
 
2324
int btrfs_drop_snapshot(struct btrfs_root *root,
 
2325
                        struct btrfs_block_rsv *block_rsv, int update_ref);
2139
2326
int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
2140
2327
                        struct btrfs_root *root,
2141
2328
                        struct extent_buffer *node,
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,
2201
 
                            u64 dir);
 
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,
2227
2415
                           struct btrfs_root *root,
2228
2416
                           const char *name, int name_len,
2229
2417
                           u64 inode_objectid, u64 ref_objectid, u64 *index);
 
2418
struct btrfs_inode_ref *
 
2419
btrfs_lookup_inode_ref(struct btrfs_trans_handle *trans,
 
2420
                        struct btrfs_root *root,
 
2421
                        struct btrfs_path *path,
 
2422
                        const char *name, int name_len,
 
2423
                        u64 inode_objectid, u64 ref_objectid, int mod);
2230
2424
int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
2231
2425
                             struct btrfs_root *root,
2232
2426
                             struct btrfs_path *path, u64 objectid);
2239
2433
                    struct btrfs_root *root, u64 bytenr, u64 len);
2240
2434
int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
2241
2435
                          struct bio *bio, u32 *dst);
 
2436
int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode,
 
2437
                              struct bio *bio, u64 logical_offset, u32 *dst);
2242
2438
int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
2243
2439
                             struct btrfs_root *root,
2244
2440
                             u64 objectid, u64 pos,
2292
2488
                               struct inode *inode, u64 new_size,
2293
2489
                               u32 min_type);
2294
2490
 
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,
 
2493
                                   int sync);
 
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;
2336
2551
 
2337
2552
/* ioctl.c */
2340
2555
void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2341
2556
 
2342
2557
/* file.c */
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);
2356
2568
 
2370
2582
ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
2371
2583
 
2372
2584
/* super.c */
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);
 
2589
 
 
2590
#define btrfs_std_error(fs_info, errno)                         \
 
2591
do {                                                            \
 
2592
        if ((errno))                                            \
 
2593
                __btrfs_std_error((fs_info), __func__, __LINE__, (errno));\
 
2594
} while (0)
2376
2595
 
2377
2596
/* acl.c */
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);
2380
2599
#else
2381
2600
#define btrfs_check_acl NULL
2382
2601
#endif
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);
2385
2605
 
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);
2394
2622
#endif