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

TOMOYO Linux Cross Reference
Linux/fs/bcachefs/btree_gc.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_BTREE_GC_H
  3 #define _BCACHEFS_BTREE_GC_H
  4 
  5 #include "bkey.h"
  6 #include "btree_gc_types.h"
  7 #include "btree_types.h"
  8 
  9 int bch2_check_topology(struct bch_fs *);
 10 int bch2_check_allocations(struct bch_fs *);
 11 
 12 /*
 13  * For concurrent mark and sweep (with other index updates), we define a total
 14  * ordering of _all_ references GC walks:
 15  *
 16  * Note that some references will have the same GC position as others - e.g.
 17  * everything within the same btree node; in those cases we're relying on
 18  * whatever locking exists for where those references live, i.e. the write lock
 19  * on a btree node.
 20  *
 21  * That locking is also required to ensure GC doesn't pass the updater in
 22  * between the updater adding/removing the reference and updating the GC marks;
 23  * without that, we would at best double count sometimes.
 24  *
 25  * That part is important - whenever calling bch2_mark_pointers(), a lock _must_
 26  * be held that prevents GC from passing the position the updater is at.
 27  *
 28  * (What about the start of gc, when we're clearing all the marks? GC clears the
 29  * mark with the gc pos seqlock held, and bch_mark_bucket checks against the gc
 30  * position inside its cmpxchg loop, so crap magically works).
 31  */
 32 
 33 /* Position of (the start of) a gc phase: */
 34 static inline struct gc_pos gc_phase(enum gc_phase phase)
 35 {
 36         return (struct gc_pos) { .phase = phase, };
 37 }
 38 
 39 static inline struct gc_pos gc_pos_btree(enum btree_id btree, unsigned level,
 40                                          struct bpos pos)
 41 {
 42         return (struct gc_pos) {
 43                 .phase  = GC_PHASE_btree,
 44                 .btree  = btree,
 45                 .level  = level,
 46                 .pos    = pos,
 47         };
 48 }
 49 
 50 static inline int gc_btree_order(enum btree_id btree)
 51 {
 52         if (btree == BTREE_ID_alloc)
 53                 return -2;
 54         if (btree == BTREE_ID_stripes)
 55                 return -1;
 56         return btree;
 57 }
 58 
 59 static inline int gc_pos_cmp(struct gc_pos l, struct gc_pos r)
 60 {
 61         return  cmp_int(l.phase, r.phase) ?:
 62                 cmp_int(gc_btree_order(l.btree),
 63                         gc_btree_order(r.btree)) ?:
 64                 cmp_int(l.level, r.level) ?:
 65                 bpos_cmp(l.pos, r.pos);
 66 }
 67 
 68 static inline bool gc_visited(struct bch_fs *c, struct gc_pos pos)
 69 {
 70         unsigned seq;
 71         bool ret;
 72 
 73         do {
 74                 seq = read_seqcount_begin(&c->gc_pos_lock);
 75                 ret = gc_pos_cmp(pos, c->gc_pos) <= 0;
 76         } while (read_seqcount_retry(&c->gc_pos_lock, seq));
 77 
 78         return ret;
 79 }
 80 
 81 void bch2_gc_pos_to_text(struct printbuf *, struct gc_pos *);
 82 
 83 int bch2_gc_gens(struct bch_fs *);
 84 void bch2_gc_gens_async(struct bch_fs *);
 85 void bch2_fs_gc_init(struct bch_fs *);
 86 
 87 #endif /* _BCACHEFS_BTREE_GC_H */
 88 

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