~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/btrfs/block-rsv.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/btrfs/block-rsv.h (Version linux-6.12-rc7) and /fs/btrfs/block-rsv.h (Version linux-6.10.14)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2                                                     2 
  3 #ifndef BTRFS_BLOCK_RSV_H                           3 #ifndef BTRFS_BLOCK_RSV_H
  4 #define BTRFS_BLOCK_RSV_H                           4 #define BTRFS_BLOCK_RSV_H
  5                                                     5 
  6 #include <linux/types.h>                            6 #include <linux/types.h>
  7 #include <linux/compiler.h>                         7 #include <linux/compiler.h>
  8 #include <linux/spinlock.h>                         8 #include <linux/spinlock.h>
  9                                                     9 
 10 struct btrfs_trans_handle;                         10 struct btrfs_trans_handle;
 11 struct btrfs_root;                                 11 struct btrfs_root;
 12 struct btrfs_space_info;                           12 struct btrfs_space_info;
 13 struct btrfs_block_rsv;                            13 struct btrfs_block_rsv;
 14 struct btrfs_fs_info;                              14 struct btrfs_fs_info;
 15 enum btrfs_reserve_flush_enum;                     15 enum btrfs_reserve_flush_enum;
 16                                                    16 
 17 /*                                                 17 /*
 18  * Types of block reserves                         18  * Types of block reserves
 19  */                                                19  */
 20 enum btrfs_rsv_type {                              20 enum btrfs_rsv_type {
 21         BTRFS_BLOCK_RSV_GLOBAL,                    21         BTRFS_BLOCK_RSV_GLOBAL,
 22         BTRFS_BLOCK_RSV_DELALLOC,                  22         BTRFS_BLOCK_RSV_DELALLOC,
 23         BTRFS_BLOCK_RSV_TRANS,                     23         BTRFS_BLOCK_RSV_TRANS,
 24         BTRFS_BLOCK_RSV_CHUNK,                     24         BTRFS_BLOCK_RSV_CHUNK,
 25         BTRFS_BLOCK_RSV_DELOPS,                    25         BTRFS_BLOCK_RSV_DELOPS,
 26         BTRFS_BLOCK_RSV_DELREFS,                   26         BTRFS_BLOCK_RSV_DELREFS,
 27         BTRFS_BLOCK_RSV_EMPTY,                     27         BTRFS_BLOCK_RSV_EMPTY,
 28         BTRFS_BLOCK_RSV_TEMP,                      28         BTRFS_BLOCK_RSV_TEMP,
 29 };                                                 29 };
 30                                                    30 
 31 struct btrfs_block_rsv {                           31 struct btrfs_block_rsv {
 32         u64 size;                                  32         u64 size;
 33         u64 reserved;                              33         u64 reserved;
 34         struct btrfs_space_info *space_info;       34         struct btrfs_space_info *space_info;
 35         spinlock_t lock;                           35         spinlock_t lock;
 36         bool full;                                 36         bool full;
 37         bool failfast;                             37         bool failfast;
 38         /* Block reserve type, one of BTRFS_BL     38         /* Block reserve type, one of BTRFS_BLOCK_RSV_* */
 39         enum btrfs_rsv_type type:8;                39         enum btrfs_rsv_type type:8;
 40                                                    40 
 41         /*                                         41         /*
 42          * Qgroup equivalent for @size @reserv     42          * Qgroup equivalent for @size @reserved
 43          *                                         43          *
 44          * Unlike normal @size/@reserved for i     44          * Unlike normal @size/@reserved for inode rsv, qgroup doesn't care
 45          * about things like csum size nor how     45          * about things like csum size nor how many tree blocks it will need to
 46          * reserve.                                46          * reserve.
 47          *                                         47          *
 48          * Qgroup cares more about net change      48          * Qgroup cares more about net change of the extent usage.
 49          *                                         49          *
 50          * So for one newly inserted file exte     50          * So for one newly inserted file extent, in worst case it will cause
 51          * leaf split and level increase, node     51          * leaf split and level increase, nodesize for each file extent is
 52          * already too much.                       52          * already too much.
 53          *                                         53          *
 54          * In short, qgroup_size/reserved is t     54          * In short, qgroup_size/reserved is the upper limit of possible needed
 55          * qgroup metadata reservation.            55          * qgroup metadata reservation.
 56          */                                        56          */
 57         u64 qgroup_rsv_size;                       57         u64 qgroup_rsv_size;
 58         u64 qgroup_rsv_reserved;                   58         u64 qgroup_rsv_reserved;
 59 };                                                 59 };
 60                                                    60 
 61 void btrfs_init_block_rsv(struct btrfs_block_r     61 void btrfs_init_block_rsv(struct btrfs_block_rsv *rsv, enum btrfs_rsv_type type);
 62 void btrfs_init_root_block_rsv(struct btrfs_ro     62 void btrfs_init_root_block_rsv(struct btrfs_root *root);
 63 struct btrfs_block_rsv *btrfs_alloc_block_rsv(     63 struct btrfs_block_rsv *btrfs_alloc_block_rsv(struct btrfs_fs_info *fs_info,
 64                                                    64                                               enum btrfs_rsv_type type);
 65 void btrfs_init_metadata_block_rsv(struct btrf     65 void btrfs_init_metadata_block_rsv(struct btrfs_fs_info *fs_info,
 66                                    struct btrf     66                                    struct btrfs_block_rsv *rsv,
 67                                    enum btrfs_     67                                    enum btrfs_rsv_type type);
 68 void btrfs_free_block_rsv(struct btrfs_fs_info     68 void btrfs_free_block_rsv(struct btrfs_fs_info *fs_info,
 69                           struct btrfs_block_r     69                           struct btrfs_block_rsv *rsv);
 70 int btrfs_block_rsv_add(struct btrfs_fs_info *     70 int btrfs_block_rsv_add(struct btrfs_fs_info *fs_info,
 71                         struct btrfs_block_rsv     71                         struct btrfs_block_rsv *block_rsv, u64 num_bytes,
 72                         enum btrfs_reserve_flu     72                         enum btrfs_reserve_flush_enum flush);
 73 int btrfs_block_rsv_check(struct btrfs_block_r     73 int btrfs_block_rsv_check(struct btrfs_block_rsv *block_rsv, int min_percent);
 74 int btrfs_block_rsv_refill(struct btrfs_fs_inf     74 int btrfs_block_rsv_refill(struct btrfs_fs_info *fs_info,
 75                            struct btrfs_block_     75                            struct btrfs_block_rsv *block_rsv, u64 num_bytes,
 76                            enum btrfs_reserve_     76                            enum btrfs_reserve_flush_enum flush);
 77 int btrfs_block_rsv_migrate(struct btrfs_block     77 int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv,
 78                             struct btrfs_block     78                             struct btrfs_block_rsv *dst_rsv, u64 num_bytes,
 79                             bool update_size);     79                             bool update_size);
 80 int btrfs_block_rsv_use_bytes(struct btrfs_blo     80 int btrfs_block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv, u64 num_bytes);
 81 void btrfs_block_rsv_add_bytes(struct btrfs_bl     81 void btrfs_block_rsv_add_bytes(struct btrfs_block_rsv *block_rsv,
 82                                u64 num_bytes,      82                                u64 num_bytes, bool update_size);
 83 u64 btrfs_block_rsv_release(struct btrfs_fs_in     83 u64 btrfs_block_rsv_release(struct btrfs_fs_info *fs_info,
 84                               struct btrfs_blo     84                               struct btrfs_block_rsv *block_rsv,
 85                               u64 num_bytes, u     85                               u64 num_bytes, u64 *qgroup_to_release);
 86 void btrfs_update_global_block_rsv(struct btrf     86 void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info);
 87 void btrfs_init_global_block_rsv(struct btrfs_     87 void btrfs_init_global_block_rsv(struct btrfs_fs_info *fs_info);
 88 void btrfs_release_global_block_rsv(struct btr     88 void btrfs_release_global_block_rsv(struct btrfs_fs_info *fs_info);
 89 struct btrfs_block_rsv *btrfs_use_block_rsv(st     89 struct btrfs_block_rsv *btrfs_use_block_rsv(struct btrfs_trans_handle *trans,
 90                                             st     90                                             struct btrfs_root *root,
 91                                             u3     91                                             u32 blocksize);
 92 int btrfs_check_trunc_cache_free_space(const s !!  92 int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
 93                                        struct      93                                        struct btrfs_block_rsv *rsv);
 94 static inline void btrfs_unuse_block_rsv(struc     94 static inline void btrfs_unuse_block_rsv(struct btrfs_fs_info *fs_info,
 95                                          struc     95                                          struct btrfs_block_rsv *block_rsv,
 96                                          u32 b     96                                          u32 blocksize)
 97 {                                                  97 {
 98         btrfs_block_rsv_add_bytes(block_rsv, b     98         btrfs_block_rsv_add_bytes(block_rsv, blocksize, false);
 99         btrfs_block_rsv_release(fs_info, block     99         btrfs_block_rsv_release(fs_info, block_rsv, 0, NULL);
100 }                                                 100 }
101                                                   101 
102 /*                                                102 /*
103  * Fast path to check if the reserve is full,     103  * Fast path to check if the reserve is full, may be carefully used outside of
104  * locks.                                         104  * locks.
105  */                                               105  */
106 static inline bool btrfs_block_rsv_full(const     106 static inline bool btrfs_block_rsv_full(const struct btrfs_block_rsv *rsv)
107 {                                                 107 {
108         return data_race(rsv->full);              108         return data_race(rsv->full);
109 }                                                 109 }
110                                                   110 
111 /*                                                111 /*
112  * Get the reserved mount of a block reserve i    112  * Get the reserved mount of a block reserve in a context where getting a stale
113  * value is acceptable, instead of accessing i    113  * value is acceptable, instead of accessing it directly and trigger data race
114  * warning from KCSAN.                            114  * warning from KCSAN.
115  */                                               115  */
116 static inline u64 btrfs_block_rsv_reserved(str    116 static inline u64 btrfs_block_rsv_reserved(struct btrfs_block_rsv *rsv)
117 {                                                 117 {
118         u64 ret;                                  118         u64 ret;
119                                                   119 
120         spin_lock(&rsv->lock);                    120         spin_lock(&rsv->lock);
121         ret = rsv->reserved;                      121         ret = rsv->reserved;
122         spin_unlock(&rsv->lock);                  122         spin_unlock(&rsv->lock);
123                                                   123 
124         return ret;                               124         return ret;
125 }                                                 125 }
126                                                   126 
127 /*                                                127 /*
128  * Get the size of a block reserve in a contex    128  * Get the size of a block reserve in a context where getting a stale value is
129  * acceptable, instead of accessing it directl    129  * acceptable, instead of accessing it directly and trigger data race warning
130  * from KCSAN.                                    130  * from KCSAN.
131  */                                               131  */
132 static inline u64 btrfs_block_rsv_size(struct     132 static inline u64 btrfs_block_rsv_size(struct btrfs_block_rsv *rsv)
133 {                                                 133 {
134         u64 ret;                                  134         u64 ret;
135                                                   135 
136         spin_lock(&rsv->lock);                    136         spin_lock(&rsv->lock);
137         ret = rsv->size;                          137         ret = rsv->size;
138         spin_unlock(&rsv->lock);                  138         spin_unlock(&rsv->lock);
139                                                   139 
140         return ret;                               140         return ret;
141 }                                                 141 }
142                                                   142 
143 #endif /* BTRFS_BLOCK_RSV_H */                    143 #endif /* BTRFS_BLOCK_RSV_H */
144                                                   144 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php