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

TOMOYO Linux Cross Reference
Linux/fs/bcachefs/alloc_types.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _BCACHEFS_ALLOC_TYPES_H
  3 #define _BCACHEFS_ALLOC_TYPES_H
  4 
  5 #include <linux/mutex.h>
  6 #include <linux/spinlock.h>
  7 
  8 #include "clock_types.h"
  9 #include "fifo.h"
 10 
 11 struct bucket_alloc_state {
 12         enum {
 13                 BTREE_BITMAP_NO,
 14                 BTREE_BITMAP_YES,
 15                 BTREE_BITMAP_ANY,
 16         }       btree_bitmap;
 17 
 18         u64     buckets_seen;
 19         u64     skipped_open;
 20         u64     skipped_need_journal_commit;
 21         u64     skipped_nocow;
 22         u64     skipped_nouse;
 23         u64     skipped_mi_btree_bitmap;
 24 };
 25 
 26 #define BCH_WATERMARKS()                \
 27         x(stripe)                       \
 28         x(normal)                       \
 29         x(copygc)                       \
 30         x(btree)                        \
 31         x(btree_copygc)                 \
 32         x(reclaim)                      \
 33         x(interior_updates)
 34 
 35 enum bch_watermark {
 36 #define x(name) BCH_WATERMARK_##name,
 37         BCH_WATERMARKS()
 38 #undef x
 39         BCH_WATERMARK_NR,
 40 };
 41 
 42 #define BCH_WATERMARK_BITS      3
 43 #define BCH_WATERMARK_MASK      ~(~0U << BCH_WATERMARK_BITS)
 44 
 45 #define OPEN_BUCKETS_COUNT      1024
 46 
 47 #define WRITE_POINT_HASH_NR     32
 48 #define WRITE_POINT_MAX         32
 49 
 50 /*
 51  * 0 is never a valid open_bucket_idx_t:
 52  */
 53 typedef u16                     open_bucket_idx_t;
 54 
 55 struct open_bucket {
 56         spinlock_t              lock;
 57         atomic_t                pin;
 58         open_bucket_idx_t       freelist;
 59         open_bucket_idx_t       hash;
 60 
 61         /*
 62          * When an open bucket has an ec_stripe attached, this is the index of
 63          * the block in the stripe this open_bucket corresponds to:
 64          */
 65         u8                      ec_idx;
 66         enum bch_data_type      data_type:6;
 67         unsigned                valid:1;
 68         unsigned                on_partial_list:1;
 69 
 70         u8                      dev;
 71         u8                      gen;
 72         u32                     sectors_free;
 73         u64                     bucket;
 74         struct ec_stripe_new    *ec;
 75 };
 76 
 77 #define OPEN_BUCKET_LIST_MAX    15
 78 
 79 struct open_buckets {
 80         open_bucket_idx_t       nr;
 81         open_bucket_idx_t       v[OPEN_BUCKET_LIST_MAX];
 82 };
 83 
 84 struct dev_stripe_state {
 85         u64                     next_alloc[BCH_SB_MEMBERS_MAX];
 86 };
 87 
 88 #define WRITE_POINT_STATES()            \
 89         x(stopped)                      \
 90         x(waiting_io)                   \
 91         x(waiting_work)                 \
 92         x(running)
 93 
 94 enum write_point_state {
 95 #define x(n)    WRITE_POINT_##n,
 96         WRITE_POINT_STATES()
 97 #undef x
 98         WRITE_POINT_STATE_NR
 99 };
100 
101 struct write_point {
102         struct {
103                 struct hlist_node       node;
104                 struct mutex            lock;
105                 u64                     last_used;
106                 unsigned long           write_point;
107                 enum bch_data_type      data_type;
108 
109                 /* calculated based on how many pointers we're actually going to use: */
110                 unsigned                sectors_free;
111 
112                 struct open_buckets     ptrs;
113                 struct dev_stripe_state stripe;
114 
115                 u64                     sectors_allocated;
116         } __aligned(SMP_CACHE_BYTES);
117 
118         struct {
119                 struct work_struct      index_update_work;
120 
121                 struct list_head        writes;
122                 spinlock_t              writes_lock;
123 
124                 enum write_point_state  state;
125                 u64                     last_state_change;
126                 u64                     time[WRITE_POINT_STATE_NR];
127         } __aligned(SMP_CACHE_BYTES);
128 };
129 
130 struct write_point_specifier {
131         unsigned long           v;
132 };
133 
134 #endif /* _BCACHEFS_ALLOC_TYPES_H */
135 

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