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
|
|
|
|
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;
|
|
|
|
|
2017-06-14 04:06:05 +03:00
|
|
|
struct extent_pick_ptr pick;
|
2017-12-14 00:01:18 +03:00
|
|
|
/* start pos of data we read (may not be pos of data we want) */
|
|
|
|
struct bpos 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;
|
2017-05-13 05:45:15 +03:00
|
|
|
u8 order;
|
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,
|
2017-05-13 05:45:15 +03:00
|
|
|
used_mempool: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;
|
2017-01-08 12:13:18 +03:00
|
|
|
struct workqueue_struct *io_wq;
|
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;
|
2017-01-08 12:13:18 +03:00
|
|
|
unsigned alloc_reserve:4;
|
2017-12-14 00:01:18 +03:00
|
|
|
|
|
|
|
u8 open_buckets_nr;
|
|
|
|
struct bch_devs_list devs_have;
|
|
|
|
u16 target;
|
|
|
|
u16 nonce;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2018-02-19 05:43:46 +03:00
|
|
|
struct bch_io_opts opts;
|
|
|
|
|
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
|
|
|
|
|
|
|
u8 open_buckets[16];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
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 */
|