Linux Audio

Check our new training course

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