]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/io_types.h
Update bcachefs sources to 7c0fe6f104 bcachefs: Fix bch2_fsck_ask_yn()
[bcachefs-tools-debian] / libbcachefs / io_types.h
index 9842019d19b3b70e0bd560a4fb349e23eebf51cc..4149291c0df6f153f8f7a147eed75487767efd18 100644 (file)
@@ -1,22 +1,22 @@
-#ifndef _BCACHE_IO_TYPES_H
-#define _BCACHE_IO_TYPES_H
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _BCACHEFS_IO_TYPES_H
+#define _BCACHEFS_IO_TYPES_H
 
+#include "alloc_types.h"
 #include "btree_types.h"
 #include "buckets_types.h"
+#include "extents_types.h"
 #include "keylist_types.h"
+#include "opts.h"
 #include "super_types.h"
 
 #include <linux/llist.h>
 #include <linux/workqueue.h>
 
-struct extent_pick_ptr {
-       struct bch_extent_crc128        crc;
-       struct bch_extent_ptr           ptr;
-       struct bch_dev                  *ca;
-};
-
 struct bch_read_bio {
        struct bch_fs           *c;
+       u64                     start_time;
+       u64                     submit_time;
 
        /*
         * Reads will often have to be split, and if the extent being read from
@@ -38,31 +38,44 @@ struct bch_read_bio {
         */
        struct bvec_iter        bvec_iter;
 
-       unsigned                submit_time_us;
-       u8                      flags;
+       unsigned                offset_into_extent;
+
+       u16                     flags;
        union {
        struct {
-       u                     bounce:1,
+       u16                     bounce:1,
                                split:1,
-                               process_context:1,
-                               retry:2;
+                               kmalloc:1,
+                               have_ioref:1,
+                               narrow_crcs:1,
+                               hole:1,
+                               retry:2,
+                               context:2;
        };
-       u                     _state;
+       u16                     _state;
        };
 
-       struct extent_pick_ptr  pick;
-       struct bversion         version;
+       struct bch_devs_list    devs_have;
 
-       struct promote_op       *promote;
+       struct extent_ptr_decoded pick;
 
        /*
-        * If we have to retry the read (IO error, checksum failure, read stale
-        * data (raced with allocator), we retry the portion of the parent bio
-        * that failed (i.e. this bio's portion, bvec_iter).
-        *
-        * But we need to stash the inode somewhere:
+        * pos we read from - different from data_pos for indirect extents:
+        */
+       u32                     subvol;
+       struct bpos             read_pos;
+
+       /*
+        * start pos of data we read (may not be pos of data we want) - for
+        * promote, narrow extents paths:
         */
-       u64                     inode;
+       enum btree_id           data_btree;
+       struct bpos             data_pos;
+       struct bversion         version;
+
+       struct promote_op       *promote;
+
+       struct bch_io_opts      opts;
 
        struct work_struct      work;
 
@@ -70,25 +83,24 @@ struct bch_read_bio {
 };
 
 struct bch_write_bio {
+       struct_group(wbio,
        struct bch_fs           *c;
-       struct bch_dev          *ca;
-       union {
        struct bch_write_bio    *parent;
-       struct closure          *cl;
-       };
 
-       u8                      ptr_idx;
-       u8                      replicas_failed;
-       u8                      order;
+       u64                     submit_time;
+       u64                     inode_offset;
+
+       struct bch_devs_list    failed;
+       u8                      dev;
 
        unsigned                split:1,
                                bounce:1,
                                put_bio:1,
-                               have_io_ref:1,
-                               used_mempool:1;
-
-       unsigned                submit_time_us;
-       void                    *data;
+                               have_ioref:1,
+                               nocow:1,
+                               used_mempool:1,
+                               first_btree_write:1;
+       );
 
        struct bio              bio;
 };
@@ -96,56 +108,58 @@ struct bch_write_bio {
 struct bch_write_op {
        struct closure          cl;
        struct bch_fs           *c;
-       struct workqueue_struct *io_wq;
+       void                    (*end_io)(struct bch_write_op *);
+       u64                     start_time;
 
        unsigned                written; /* sectors */
-
-       short                   error;
-
        u16                     flags;
+       s16                     error; /* dio write path expects it to hold -ERESTARTSYS... */
+
        unsigned                csum_type:4;
        unsigned                compression_type:4;
        unsigned                nr_replicas:4;
-       unsigned                alloc_reserve:4;
-       unsigned                nonce:14;
+       unsigned                nr_replicas_required:4;
+       unsigned                alloc_reserve:3;
+       unsigned                incompressible:1;
+       unsigned                stripe_waited:1;
 
+       struct bch_devs_list    devs_have;
+       u16                     target;
+       u16                     nonce;
+       struct bch_io_opts      opts;
+
+       u32                     subvol;
        struct bpos             pos;
        struct bversion         version;
 
-       /* For BCH_WRITE_DATA_COMPRESSED: */
-       struct bch_extent_crc128 crc;
-       unsigned                size;
+       /* For BCH_WRITE_DATA_ENCODED: */
+       struct bch_extent_crc_unpacked crc;
 
-       struct disk_reservation res;
+       struct write_point_specifier write_point;
 
        struct write_point      *wp;
+       struct list_head        wp_list;
 
-       union {
-       u8                      open_buckets[16];
-       struct {
-       struct bch_write_op     *next;
-       unsigned long           expires;
-       };
-       };
+       struct disk_reservation res;
 
-       /*
-        * If caller wants to flush but hasn't passed us a journal_seq ptr, we
-        * still need to stash the journal_seq somewhere:
-        */
-       union {
-               u64                     *journal_seq_p;
-               u64                     journal_seq;
-       };
+       struct open_buckets     open_buckets;
 
-       int                     (*index_update_fn)(struct bch_write_op *);
+       u64                     new_i_size;
+       s64                     i_sectors_delta;
 
        struct bch_devs_mask    failed;
 
        struct keylist          insert_keys;
        u64                     inline_keys[BKEY_EXTENT_U64s_MAX * 2];
 
+       /*
+        * Bitmask of devices that have had nocow writes issued to them since
+        * last flush:
+        */
+       struct bch_devs_mask    *devs_need_flush;
+
        /* Must be last: */
        struct bch_write_bio    wbio;
 };
 
-#endif /* _BCACHE_IO_TYPES_H */
+#endif /* _BCACHEFS_IO_TYPES_H */