]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/super-io.h
Update bcachefs sources to d4b7ef921a bcachefs: Refactoring
[bcachefs-tools-debian] / libbcachefs / super-io.h
index e5e865a9e0b71420d70f9c1e6a88b614e6424f74..8cafb30181fd5579738c8062f14427b34e6a519a 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _BCACHE_SUPER_IO_H
-#define _BCACHE_SUPER_IO_H
+#ifndef _BCACHEFS_SUPER_IO_H
+#define _BCACHEFS_SUPER_IO_H
 
 #include "extents.h"
 #include "eytzinger.h"
@@ -9,8 +9,8 @@
 #include <asm/byteorder.h>
 
 struct bch_sb_field *bch2_sb_field_get(struct bch_sb *, enum bch_sb_field_type);
-struct bch_sb_field *bch2_sb_field_resize(struct bcache_superblock *,
-                                        enum bch_sb_field_type, unsigned);
+struct bch_sb_field *bch2_sb_field_resize(struct bch_sb_handle *,
+                                         enum bch_sb_field_type, unsigned);
 struct bch_sb_field *bch2_fs_sb_field_resize(struct bch_fs *,
                                         enum bch_sb_field_type, unsigned);
 
@@ -26,7 +26,7 @@ bch2_sb_get_##_name(struct bch_sb *sb)                                        \
 }                                                                      \
                                                                        \
 static inline struct bch_sb_field_##_name *                            \
-bch2_sb_resize_##_name(struct bcache_superblock *sb, unsigned u64s)    \
+bch2_sb_resize_##_name(struct bch_sb_handle *sb, unsigned u64s)        \
 {                                                                      \
        return field_to_type(bch2_sb_field_resize(sb,                   \
                                BCH_SB_FIELD_##_name, u64s), _name);    \
@@ -104,6 +104,7 @@ static inline struct bch_member_cpu bch2_mi_to_cpu(struct bch_member *mi)
                .tier           = BCH_MEMBER_TIER(mi),
                .replacement    = BCH_MEMBER_REPLACEMENT(mi),
                .discard        = BCH_MEMBER_DISCARD(mi),
+               .data_allowed   = BCH_MEMBER_DATA_ALLOWED(mi),
                .valid          = !bch2_is_zero(mi->uuid.b, sizeof(uuid_le)),
        };
 }
@@ -111,21 +112,36 @@ static inline struct bch_member_cpu bch2_mi_to_cpu(struct bch_member *mi)
 int bch2_sb_to_fs(struct bch_fs *, struct bch_sb *);
 int bch2_sb_from_fs(struct bch_fs *, struct bch_dev *);
 
-void bch2_free_super(struct bcache_superblock *);
-int bch2_super_realloc(struct bcache_superblock *, unsigned);
+void bch2_free_super(struct bch_sb_handle *);
+int bch2_super_realloc(struct bch_sb_handle *, unsigned);
 
 const char *bch2_sb_validate_journal(struct bch_sb *,
                                         struct bch_member_cpu);
-const char *bch2_sb_validate(struct bcache_superblock *);
+const char *bch2_sb_validate(struct bch_sb_handle *);
 
-const char *bch2_read_super(struct bcache_superblock *,
-                          struct bch_opts, const char *);
+const char *bch2_read_super(const char *, struct bch_opts,
+                           struct bch_sb_handle *);
 void bch2_write_super(struct bch_fs *);
 
+/* replicas: */
+
+/* iterate over bch_sb_field_replicas: */
+
+static inline struct bch_replicas_entry *
+replicas_entry_next(struct bch_replicas_entry *i)
+{
+       return (void *) i + offsetof(struct bch_replicas_entry, devs) + i->nr;
+}
+
+#define for_each_replicas_entry(_r, _i)                                        \
+       for (_i = (_r)->entries;                                        \
+            (void *) (_i) < vstruct_end(&(_r)->field) && (_i)->data_type;\
+            (_i) = replicas_entry_next(_i))
+
 bool bch2_sb_has_replicas(struct bch_fs *, struct bkey_s_c_extent,
-                         enum bch_data_types);
+                         enum bch_data_type);
 int bch2_check_mark_super(struct bch_fs *, struct bkey_s_c_extent,
-                         enum bch_data_types);
+                         enum bch_data_type);
 
 struct replicas_status {
        struct {
@@ -145,4 +161,4 @@ unsigned bch2_dev_has_data(struct bch_fs *, struct bch_dev *);
 int bch2_replicas_gc_end(struct bch_fs *, int);
 int bch2_replicas_gc_start(struct bch_fs *, unsigned);
 
-#endif /* _BCACHE_SUPER_IO_H */
+#endif /* _BCACHEFS_SUPER_IO_H */