]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/journal_io.h
Update bcachefs sources to 50847e296b34 bcachefs: Check subvol <-> inode pointers...
[bcachefs-tools-debian] / libbcachefs / journal_io.h
index c035e7c108e19012e6e4e1f708136dec27b5387c..f18b90000cc5db24f11ec8f3595557c22cce53ab 100644 (file)
@@ -2,19 +2,22 @@
 #ifndef _BCACHEFS_JOURNAL_IO_H
 #define _BCACHEFS_JOURNAL_IO_H
 
+#include <linux/darray_types.h>
+
+struct journal_ptr {
+       bool            csum_good;
+       u8              dev;
+       u32             bucket;
+       u32             bucket_offset;
+       u64             sector;
+};
+
 /*
  * Only used for holding the journal entries we read in btree_journal_read()
  * during cache_registration
  */
 struct journal_replay {
-       struct journal_ptr {
-               bool            csum_good;
-               u8              dev;
-               u32             bucket;
-               u32             bucket_offset;
-               u64             sector;
-       }                       ptrs[BCH_REPLICAS_MAX];
-       unsigned                nr_ptrs;
+       DARRAY_PREALLOCATED(struct journal_ptr, 8) ptrs;
 
        bool                    csum_good;
        bool                    ignore;
@@ -62,4 +65,20 @@ int bch2_journal_read(struct bch_fs *, u64 *, u64 *, u64 *);
 
 CLOSURE_CALLBACK(bch2_journal_write);
 
+static inline struct jset_entry *jset_entry_init(struct jset_entry **end, size_t size)
+{
+       struct jset_entry *entry = *end;
+       unsigned u64s = DIV_ROUND_UP(size, sizeof(u64));
+
+       memset(entry, 0, u64s * sizeof(u64));
+       /*
+        * The u64s field counts from the start of data, ignoring the shared
+        * fields.
+        */
+       entry->u64s = cpu_to_le16(u64s - 1);
+
+       *end = vstruct_next(*end);
+       return entry;
+}
+
 #endif /* _BCACHEFS_JOURNAL_IO_H */