brintos

brintos / linux-shallow public Read only

0
0
Text · 2.7 KiB · 5aba2c1 Raw
84 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef _BCACHEFS_REPLICAS_H3#define _BCACHEFS_REPLICAS_H4 5#include "bkey.h"6#include "eytzinger.h"7#include "replicas_types.h"8 9void bch2_replicas_entry_sort(struct bch_replicas_entry_v1 *);10void bch2_replicas_entry_to_text(struct printbuf *,11				 struct bch_replicas_entry_v1 *);12int bch2_replicas_entry_validate(struct bch_replicas_entry_v1 *,13				 struct bch_fs *, struct printbuf *);14void bch2_cpu_replicas_to_text(struct printbuf *, struct bch_replicas_cpu *);15 16static inline struct bch_replicas_entry_v1 *17cpu_replicas_entry(struct bch_replicas_cpu *r, unsigned i)18{19	return (void *) r->entries + r->entry_size * i;20}21 22int bch2_replicas_entry_idx(struct bch_fs *,23			    struct bch_replicas_entry_v1 *);24 25void bch2_devlist_to_replicas(struct bch_replicas_entry_v1 *,26			      enum bch_data_type,27			      struct bch_devs_list);28 29bool bch2_replicas_marked_locked(struct bch_fs *,30			  struct bch_replicas_entry_v1 *);31bool bch2_replicas_marked(struct bch_fs *, struct bch_replicas_entry_v1 *);32int bch2_mark_replicas(struct bch_fs *,33		       struct bch_replicas_entry_v1 *);34 35void bch2_bkey_to_replicas(struct bch_replicas_entry_v1 *, struct bkey_s_c);36 37static inline void bch2_replicas_entry_cached(struct bch_replicas_entry_v1 *e,38					      unsigned dev)39{40	e->data_type	= BCH_DATA_cached;41	e->nr_devs	= 1;42	e->nr_required	= 1;43	e->devs[0]	= dev;44}45 46bool bch2_have_enough_devs(struct bch_fs *, struct bch_devs_mask,47			   unsigned, bool);48 49unsigned bch2_sb_dev_has_data(struct bch_sb *, unsigned);50unsigned bch2_dev_has_data(struct bch_fs *, struct bch_dev *);51 52int bch2_replicas_gc_end(struct bch_fs *, int);53int bch2_replicas_gc_start(struct bch_fs *, unsigned);54int bch2_replicas_gc2(struct bch_fs *);55 56#define for_each_cpu_replicas_entry(_r, _i)				\57	for (_i = (_r)->entries;					\58	     (void *) (_i) < (void *) (_r)->entries + (_r)->nr * (_r)->entry_size;\59	     _i = (void *) (_i) + (_r)->entry_size)60 61/* iterate over superblock replicas - used by userspace tools: */62 63#define replicas_entry_next(_i)						\64	((typeof(_i)) ((void *) (_i) + replicas_entry_bytes(_i)))65 66#define for_each_replicas_entry(_r, _i)					\67	for (_i = (_r)->entries;					\68	     (void *) (_i) < vstruct_end(&(_r)->field) && (_i)->data_type;\69	     (_i) = replicas_entry_next(_i))70 71#define for_each_replicas_entry_v0(_r, _i)				\72	for (_i = (_r)->entries;					\73	     (void *) (_i) < vstruct_end(&(_r)->field) && (_i)->data_type;\74	     (_i) = replicas_entry_next(_i))75 76int bch2_sb_replicas_to_cpu_replicas(struct bch_fs *);77 78extern const struct bch_sb_field_ops bch_sb_field_ops_replicas;79extern const struct bch_sb_field_ops bch_sb_field_ops_replicas_v0;80 81void bch2_fs_replicas_exit(struct bch_fs *);82 83#endif /* _BCACHEFS_REPLICAS_H */84