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

TOMOYO Linux Cross Reference
Linux/fs/bcachefs/disk_accounting.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/bcachefs/disk_accounting.h (Version linux-6.12-rc7) and /fs/bcachefs/disk_accounting.h (Version linux-5.14.21)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 #ifndef _BCACHEFS_DISK_ACCOUNTING_H               
  3 #define _BCACHEFS_DISK_ACCOUNTING_H               
  4                                                   
  5 #include "eytzinger.h"                            
  6 #include "sb-members.h"                           
  7                                                   
  8 static inline void bch2_u64s_neg(u64 *v, unsig    
  9 {                                                 
 10         for (unsigned i = 0; i < nr; i++)         
 11                 v[i] = -v[i];                     
 12 }                                                 
 13                                                   
 14 static inline unsigned bch2_accounting_counter    
 15 {                                                 
 16         return bkey_val_u64s(k) - offsetof(str    
 17 }                                                 
 18                                                   
 19 static inline void bch2_accounting_neg(struct     
 20 {                                                 
 21         bch2_u64s_neg(a.v->d, bch2_accounting_    
 22 }                                                 
 23                                                   
 24 static inline bool bch2_accounting_key_is_zero    
 25 {                                                 
 26         for (unsigned i = 0;  i < bch2_account    
 27                 if (a.v->d[i])                    
 28                         return false;             
 29         return true;                              
 30 }                                                 
 31                                                   
 32 static inline void bch2_accounting_accumulate(    
 33                                                   
 34 {                                                 
 35         EBUG_ON(dst->k.u64s != src.k->u64s);      
 36                                                   
 37         for (unsigned i = 0; i < bch2_accounti    
 38                 dst->v.d[i] += src.v->d[i];       
 39         if (bversion_cmp(dst->k.bversion, src.    
 40                 dst->k.bversion = src.k->bvers    
 41 }                                                 
 42                                                   
 43 static inline void fs_usage_data_type_to_base(    
 44                                                   
 45                                                   
 46 {                                                 
 47         switch (data_type) {                      
 48         case BCH_DATA_btree:                      
 49                 fs_usage->btree         += sec    
 50                 break;                            
 51         case BCH_DATA_user:                       
 52         case BCH_DATA_parity:                     
 53                 fs_usage->data          += sec    
 54                 break;                            
 55         case BCH_DATA_cached:                     
 56                 fs_usage->cached        += sec    
 57                 break;                            
 58         default:                                  
 59                 break;                            
 60         }                                         
 61 }                                                 
 62                                                   
 63 static inline void bpos_to_disk_accounting_pos    
 64 {                                                 
 65         acc->_pad = p;                            
 66 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__        
 67         bch2_bpos_swab(&acc->_pad);               
 68 #endif                                            
 69 }                                                 
 70                                                   
 71 static inline struct bpos disk_accounting_pos_    
 72 {                                                 
 73         struct bpos ret = k->_pad;                
 74                                                   
 75 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__        
 76         bch2_bpos_swab(&ret);                     
 77 #endif                                            
 78         return ret;                               
 79 }                                                 
 80                                                   
 81 int bch2_disk_accounting_mod(struct btree_tran    
 82                              s64 *, unsigned,     
 83 int bch2_mod_dev_cached_sectors(struct btree_t    
 84                                                   
 85 int bch2_accounting_validate(struct bch_fs *,     
 86 void bch2_accounting_key_to_text(struct printb    
 87 void bch2_accounting_to_text(struct printbuf *    
 88 void bch2_accounting_swab(struct bkey_s);         
 89                                                   
 90 #define bch2_bkey_ops_accounting ((struct bkey    
 91         .key_validate   = bch2_accounting_vali    
 92         .val_to_text    = bch2_accounting_to_t    
 93         .swab           = bch2_accounting_swab    
 94         .min_val_size   = 8,                      
 95 })                                                
 96                                                   
 97 int bch2_accounting_update_sb(struct btree_tra    
 98                                                   
 99 static inline int accounting_pos_cmp(const voi    
100 {                                                 
101         const struct bpos *l = _l, *r = _r;       
102                                                   
103         return bpos_cmp(*l, *r);                  
104 }                                                 
105                                                   
106 enum bch_accounting_mode {                        
107         BCH_ACCOUNTING_normal,                    
108         BCH_ACCOUNTING_gc,                        
109         BCH_ACCOUNTING_read,                      
110 };                                                
111                                                   
112 int bch2_accounting_mem_insert(struct bch_fs *    
113 void bch2_accounting_mem_gc(struct bch_fs *);     
114                                                   
115 /*                                                
116  * Update in memory counters so they match the    
117  * from transaction commit path                   
118  */                                               
119 static inline int bch2_accounting_mem_mod_lock    
120                                                   
121                                                   
122 {                                                 
123         struct bch_fs *c = trans->c;              
124         struct bch_accounting_mem *acc = &c->a    
125         struct disk_accounting_pos acc_k;         
126         bpos_to_disk_accounting_pos(&acc_k, a.    
127         bool gc = mode == BCH_ACCOUNTING_gc;      
128                                                   
129         EBUG_ON(gc && !acc->gc_running);          
130                                                   
131         if (acc_k.type == BCH_DISK_ACCOUNTING_    
132                 return 0;                         
133                                                   
134         if (mode == BCH_ACCOUNTING_normal) {      
135                 switch (acc_k.type) {             
136                 case BCH_DISK_ACCOUNTING_persi    
137                         trans->fs_usage_delta.    
138                         break;                    
139                 case BCH_DISK_ACCOUNTING_repli    
140                         fs_usage_data_type_to_    
141                         break;                    
142                 case BCH_DISK_ACCOUNTING_dev_d    
143                         rcu_read_lock();          
144                         struct bch_dev *ca = b    
145                         if (ca) {                 
146                                 this_cpu_add(c    
147                                 this_cpu_add(c    
148                                 this_cpu_add(c    
149                         }                         
150                         rcu_read_unlock();        
151                         break;                    
152                 }                                 
153         }                                         
154                                                   
155         unsigned idx;                             
156                                                   
157         while ((idx = eytzinger0_find(acc->k.d    
158                                       accounti    
159                 int ret = bch2_accounting_mem_    
160                 if (ret)                          
161                         return ret;               
162         }                                         
163                                                   
164         struct accounting_mem_entry *e = &acc-    
165                                                   
166         EBUG_ON(bch2_accounting_counters(a.k)     
167                                                   
168         for (unsigned i = 0; i < bch2_accounti    
169                 this_cpu_add(e->v[gc][i], a.v-    
170         return 0;                                 
171 }                                                 
172                                                   
173 static inline int bch2_accounting_mem_add(stru    
174 {                                                 
175         percpu_down_read(&trans->c->mark_lock)    
176         int ret = bch2_accounting_mem_mod_lock    
177         percpu_up_read(&trans->c->mark_lock);     
178         return ret;                               
179 }                                                 
180                                                   
181 static inline void bch2_accounting_mem_read_co    
182                                                   
183 {                                                 
184         memset(v, 0, sizeof(*v) * nr);            
185                                                   
186         if (unlikely(idx >= acc->k.nr))           
187                 return;                           
188                                                   
189         struct accounting_mem_entry *e = &acc-    
190                                                   
191         nr = min_t(unsigned, nr, e->nr_counter    
192                                                   
193         for (unsigned i = 0; i < nr; i++)         
194                 v[i] = percpu_u64_get(e->v[gc]    
195 }                                                 
196                                                   
197 static inline void bch2_accounting_mem_read(st    
198                                             u6    
199 {                                                 
200         struct bch_accounting_mem *acc = &c->a    
201         unsigned idx = eytzinger0_find(acc->k.    
202                                        account    
203                                                   
204         bch2_accounting_mem_read_counters(acc,    
205 }                                                 
206                                                   
207 int bch2_fs_replicas_usage_read(struct bch_fs     
208 int bch2_fs_accounting_read(struct bch_fs *, d    
209 void bch2_fs_accounting_to_text(struct printbu    
210                                                   
211 int bch2_gc_accounting_start(struct bch_fs *);    
212 int bch2_gc_accounting_done(struct bch_fs *);     
213                                                   
214 int bch2_accounting_read(struct bch_fs *);        
215                                                   
216 int bch2_dev_usage_remove(struct bch_fs *, uns    
217 int bch2_dev_usage_init(struct bch_dev *, bool    
218                                                   
219 void bch2_verify_accounting_clean(struct bch_f    
220                                                   
221 void bch2_accounting_gc_free(struct bch_fs *);    
222 void bch2_fs_accounting_exit(struct bch_fs *);    
223                                                   
224 #endif /* _BCACHEFS_DISK_ACCOUNTING_H */          
225                                                   

~ [ 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