2019-07-10 23:12:15 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2017-10-06 01:41:44 +03:00
|
|
|
#ifndef _BCACHEFS_IO_TYPES_H
|
|
|
|
#define _BCACHEFS_IO_TYPES_H
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-12-14 00:01:18 +03:00
|
|
|
#include "alloc_types.h"
|
2017-01-08 12:13:18 +03:00
|
|
|
#include "btree_types.h"
|
|
|
|
#include "buckets_types.h"
|
2017-12-14 00:01:18 +03:00
|
|
|
#include "extents_types.h"
|
2017-01-08 12:13:18 +03:00
|
|
|
#include "keylist_types.h"
|
2017-12-22 02:00:30 +03:00
|
|
|
#include "opts.h"
|
2017-06-14 04:06:05 +03:00
|
|
|
#include "super_types.h"
|
2017-01-08 12:13:18 +03:00
|
|
|
|
|
|
|
#include <linux/llist.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
|
|
|
|
struct bch_read_bio {
|
2017-06-14 04:06:05 +03:00
|
|
|
struct bch_fs *c;
|
2018-05-04 21:04:31 +03:00
|
|
|
u64 start_time;
|
|
|
|
u64 submit_time;
|
2017-06-14 04:06:05 +03:00
|
|
|
|
2017-01-08 12:13:18 +03:00
|
|
|
/*
|
|
|
|
* Reads will often have to be split, and if the extent being read from
|
|
|
|
* was checksummed or compressed we'll also have to allocate bounce
|
|
|
|
* buffers and copy the data back into the original bio.
|
|
|
|
*
|
|
|
|
* If we didn't have to split, we have to save and restore the original
|
|
|
|
* bi_end_io - @split below indicates which:
|
|
|
|
*/
|
|
|
|
union {
|
|
|
|
struct bch_read_bio *parent;
|
2017-06-14 04:06:05 +03:00
|
|
|
bio_end_io_t *end_io;
|
2017-01-08 12:13:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2017-06-14 04:06:05 +03:00
|
|
|
* Saved copy of bio->bi_iter, from submission time - allows us to
|
2017-01-08 12:13:18 +03:00
|
|
|
* resubmit on IO error, and also to copy data back to the original bio
|
|
|
|
* when we're bouncing:
|
|
|
|
*/
|
2017-06-14 04:06:05 +03:00
|
|
|
struct bvec_iter bvec_iter;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2019-08-21 20:17:42 +03:00
|
|
|
unsigned offset_into_extent;
|
|
|
|
|
2018-05-04 21:04:31 +03:00
|
|
|
u16 flags;
|
2017-06-14 04:06:05 +03:00
|
|
|
union {
|
|
|
|
struct {
|
2018-05-04 21:04:31 +03:00
|
|
|
u16 bounce:1,
|
2017-06-14 04:06:05 +03:00
|
|
|
split:1,
|
2018-05-04 21:04:31 +03:00
|
|
|
kmalloc:1,
|
|
|
|
have_ioref:1,
|
2017-12-14 00:01:18 +03:00
|
|
|
narrow_crcs:1,
|
2018-05-04 21:04:31 +03:00
|
|
|
hole:1,
|
2017-12-14 00:01:18 +03:00
|
|
|
retry:2,
|
|
|
|
context:2;
|
2017-06-14 04:06:05 +03:00
|
|
|
};
|
2018-05-04 21:04:31 +03:00
|
|
|
u16 _state;
|
2017-06-14 04:06:05 +03:00
|
|
|
};
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-12-14 00:01:18 +03:00
|
|
|
struct bch_devs_list devs_have;
|
|
|
|
|
2018-11-04 03:11:29 +03:00
|
|
|
struct extent_ptr_decoded pick;
|
2021-03-17 04:45:21 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* pos we read from - different from data_pos for indirect extents:
|
|
|
|
*/
|
2021-09-27 01:19:46 +03:00
|
|
|
u32 subvol;
|
2021-03-17 04:45:21 +03:00
|
|
|
struct bpos read_pos;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* start pos of data we read (may not be pos of data we want) - for
|
|
|
|
* promote, narrow extents paths:
|
|
|
|
*/
|
|
|
|
enum btree_id data_btree;
|
|
|
|
struct bpos data_pos;
|
2017-03-17 01:51:41 +03:00
|
|
|
struct bversion version;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-06-14 04:06:05 +03:00
|
|
|
struct promote_op *promote;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-12-22 02:00:30 +03:00
|
|
|
struct bch_io_opts opts;
|
|
|
|
|
2017-03-17 01:51:41 +03:00
|
|
|
struct work_struct work;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
|
|
|
struct bio bio;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bch_write_bio {
|
2017-03-17 01:51:41 +03:00
|
|
|
struct bch_fs *c;
|
2017-05-13 05:45:15 +03:00
|
|
|
struct bch_write_bio *parent;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2018-05-04 21:04:31 +03:00
|
|
|
u64 submit_time;
|
|
|
|
|
2017-12-22 02:00:30 +03:00
|
|
|
struct bch_devs_list failed;
|
2018-05-04 21:04:31 +03:00
|
|
|
u8 dev;
|
2017-05-13 05:45:15 +03:00
|
|
|
|
2017-01-08 12:13:18 +03:00
|
|
|
unsigned split:1,
|
|
|
|
bounce:1,
|
2017-04-04 10:05:13 +03:00
|
|
|
put_bio:1,
|
2018-05-04 21:04:31 +03:00
|
|
|
have_ioref:1,
|
2021-07-16 04:42:36 +03:00
|
|
|
used_mempool:1,
|
|
|
|
first_btree_write:1;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
|
|
|
struct bio bio;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bch_write_op {
|
|
|
|
struct closure cl;
|
2017-05-13 05:45:15 +03:00
|
|
|
struct bch_fs *c;
|
2019-11-04 20:53:59 +03:00
|
|
|
void (*end_io)(struct bch_write_op *);
|
2018-05-04 21:04:31 +03:00
|
|
|
u64 start_time;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-12-22 02:00:30 +03:00
|
|
|
unsigned written; /* sectors */
|
2017-01-08 12:13:18 +03:00
|
|
|
u16 flags;
|
2018-01-11 14:41:59 +03:00
|
|
|
s16 error; /* dio write path expects it to hold -ERESTARTSYS... */
|
2017-12-14 00:01:18 +03:00
|
|
|
|
2016-10-04 06:22:17 +03:00
|
|
|
unsigned csum_type:4;
|
2017-01-08 12:13:18 +03:00
|
|
|
unsigned compression_type:4;
|
|
|
|
unsigned nr_replicas:4;
|
2017-12-14 00:01:18 +03:00
|
|
|
unsigned nr_replicas_required:4;
|
2020-02-23 00:21:32 +03:00
|
|
|
unsigned alloc_reserve:3;
|
2020-01-22 01:24:32 +03:00
|
|
|
unsigned incompressible:1;
|
2017-12-14 00:01:18 +03:00
|
|
|
|
|
|
|
struct bch_devs_list devs_have;
|
|
|
|
u16 target;
|
|
|
|
u16 nonce;
|
2018-02-19 05:43:46 +03:00
|
|
|
struct bch_io_opts opts;
|
|
|
|
|
2021-09-27 01:19:46 +03:00
|
|
|
u32 subvol;
|
2017-01-08 12:13:18 +03:00
|
|
|
struct bpos pos;
|
2016-10-04 06:22:17 +03:00
|
|
|
struct bversion version;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-12-14 00:01:18 +03:00
|
|
|
/* For BCH_WRITE_DATA_ENCODED: */
|
|
|
|
struct bch_extent_crc_unpacked crc;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-12-14 00:01:18 +03:00
|
|
|
struct write_point_specifier write_point;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-11-22 08:42:55 +03:00
|
|
|
struct disk_reservation res;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2018-10-12 21:55:27 +03:00
|
|
|
struct open_buckets open_buckets;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
};
|
2019-10-11 01:04:36 +03:00
|
|
|
u64 new_i_size;
|
|
|
|
s64 i_sectors_delta;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
|
|
|
int (*index_update_fn)(struct bch_write_op *);
|
|
|
|
|
2017-06-14 04:06:05 +03:00
|
|
|
struct bch_devs_mask failed;
|
|
|
|
|
2017-01-08 12:13:18 +03:00
|
|
|
struct keylist insert_keys;
|
|
|
|
u64 inline_keys[BKEY_EXTENT_U64s_MAX * 2];
|
2017-05-13 05:45:15 +03:00
|
|
|
|
|
|
|
/* Must be last: */
|
|
|
|
struct bch_write_bio wbio;
|
2017-01-08 12:13:18 +03:00
|
|
|
};
|
|
|
|
|
2017-10-06 01:41:44 +03:00
|
|
|
#endif /* _BCACHEFS_IO_TYPES_H */
|