{
        int r;
        struct dm_io_request io_req = {
-               .bi_op = rw,
-               .bi_op_flags = 0,
+               .bi_opf = rw,
                .notify.fn = dmio_complete,
                .notify.context = b,
                .client = b->c->dm_io,
 int dm_bufio_issue_flush(struct dm_bufio_client *c)
 {
        struct dm_io_request io_req = {
-               .bi_op = REQ_OP_WRITE,
-               .bi_op_flags = REQ_PREFLUSH | REQ_SYNC,
+               .bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC,
                .mem.type = DM_IO_KMEM,
                .mem.ptr.addr = NULL,
                .client = c->dm_io,
 int dm_bufio_issue_discard(struct dm_bufio_client *c, sector_t block, sector_t count)
 {
        struct dm_io_request io_req = {
-               .bi_op = REQ_OP_DISCARD,
-               .bi_op_flags = REQ_SYNC,
+               .bi_opf = REQ_OP_DISCARD | REQ_SYNC,
                .mem.type = DM_IO_KMEM,
                .mem.ptr.addr = NULL,
                .client = c->dm_io,
 
        struct dm_io_region io_loc;
        int r;
 
-       io_req.bi_op = op;
-       io_req.bi_op_flags = op_flags;
+       io_req.bi_opf = op | op_flags;
        io_req.mem.type = DM_IO_KMEM;
        io_req.mem.ptr.addr = ic->sb;
        io_req.notify.fn = NULL;
        pl_index = sector >> (PAGE_SHIFT - SECTOR_SHIFT);
        pl_offset = (sector << SECTOR_SHIFT) & (PAGE_SIZE - 1);
 
-       io_req.bi_op = op;
-       io_req.bi_op_flags = op_flags;
+       io_req.bi_opf = op | op_flags;
        io_req.mem.type = DM_IO_PAGE_LIST;
        if (ic->journal_io)
                io_req.mem.ptr.pl = &ic->journal_io[pl_index];
        pl_index = sector >> (PAGE_SHIFT - SECTOR_SHIFT);
        pl_offset = (sector << SECTOR_SHIFT) & (PAGE_SIZE - 1);
 
-       io_req.bi_op = REQ_OP_WRITE;
-       io_req.bi_op_flags = 0;
+       io_req.bi_opf = REQ_OP_WRITE;
        io_req.mem.type = DM_IO_PAGE_LIST;
        io_req.mem.ptr.pl = &ic->journal[pl_index];
        io_req.mem.offset = pl_offset;
        if (!ic->meta_dev)
                flush_data = false;
        if (flush_data) {
-               fr.io_req.bi_op = REQ_OP_WRITE,
-               fr.io_req.bi_op_flags = REQ_PREFLUSH | REQ_SYNC,
+               fr.io_req.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC,
                fr.io_req.mem.type = DM_IO_KMEM,
                fr.io_req.mem.ptr.addr = NULL,
                fr.io_req.notify.fn = flush_notify,
        if (unlikely(dm_integrity_failed(ic)))
                goto err;
 
-       io_req.bi_op = REQ_OP_READ;
-       io_req.bi_op_flags = 0;
+       io_req.bi_opf = REQ_OP_READ;
        io_req.mem.type = DM_IO_VMA;
        io_req.mem.ptr.addr = ic->recalc_buffer;
        io_req.notify.fn = NULL;
 
 
        case DM_IO_VMA:
                flush_kernel_vmap_range(io_req->mem.ptr.vma, size);
-               if (io_req->bi_op == REQ_OP_READ) {
+               if ((io_req->bi_opf & REQ_OP_MASK) == REQ_OP_READ) {
                        dp->vma_invalidate_address = io_req->mem.ptr.vma;
                        dp->vma_invalidate_size = size;
                }
 
        if (!io_req->notify.fn)
                return sync_io(io_req->client, num_regions, where,
-                              io_req->bi_op, io_req->bi_op_flags, &dp,
+                              io_req->bi_opf & REQ_OP_MASK,
+                              io_req->bi_opf & ~REQ_OP_MASK, &dp,
                               sync_error_bits);
 
-       return async_io(io_req->client, num_regions, where, io_req->bi_op,
-                       io_req->bi_op_flags, &dp, io_req->notify.fn,
+       return async_io(io_req->client, num_regions, where,
+                       io_req->bi_opf & REQ_OP_MASK,
+                       io_req->bi_opf & ~REQ_OP_MASK, &dp, io_req->notify.fn,
                        io_req->notify.context);
 }
 EXPORT_SYMBOL(dm_io);
 
 {
        int r;
        struct dm_io_request io_req = {
-               .bi_op = job->rw,
-               .bi_op_flags = 0,
+               .bi_opf = job->rw,
                .mem.type = DM_IO_PAGE_LIST,
                .mem.ptr.pl = job->pages,
                .mem.offset = 0,
 
 
 static int rw_header(struct log_c *lc, int op)
 {
-       lc->io_req.bi_op = op;
-       lc->io_req.bi_op_flags = 0;
+       lc->io_req.bi_opf = op;
 
        return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
 }
                .count = 0,
        };
 
-       lc->io_req.bi_op = REQ_OP_WRITE;
-       lc->io_req.bi_op_flags = REQ_PREFLUSH;
+       lc->io_req.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
 
        return dm_io(&lc->io_req, 1, &null_location, NULL);
 }
 
        struct dm_io_region io[MAX_NR_MIRRORS];
        struct mirror *m;
        struct dm_io_request io_req = {
-               .bi_op = REQ_OP_WRITE,
-               .bi_op_flags = REQ_PREFLUSH | REQ_SYNC,
+               .bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC,
                .mem.type = DM_IO_KMEM,
                .mem.ptr.addr = NULL,
                .client = ms->io_client,
 {
        struct dm_io_region io;
        struct dm_io_request io_req = {
-               .bi_op = REQ_OP_READ,
-               .bi_op_flags = 0,
+               .bi_opf = REQ_OP_READ,
                .mem.type = DM_IO_BIO,
                .mem.ptr.bio = bio,
                .notify.fn = read_callback,
        unsigned int i;
        struct dm_io_region io[MAX_NR_MIRRORS], *dest = io;
        struct mirror *m;
+       blk_opf_t op_flags = bio->bi_opf & (REQ_FUA | REQ_PREFLUSH);
        struct dm_io_request io_req = {
-               .bi_op = REQ_OP_WRITE,
-               .bi_op_flags = bio->bi_opf & (REQ_FUA | REQ_PREFLUSH),
+               .bi_opf = REQ_OP_WRITE | op_flags,
                .mem.type = DM_IO_BIO,
                .mem.ptr.bio = bio,
                .notify.fn = write_callback,
        };
 
        if (bio_op(bio) == REQ_OP_DISCARD) {
-               io_req.bi_op = REQ_OP_DISCARD;
+               io_req.bi_opf = REQ_OP_DISCARD | op_flags;
                io_req.mem.type = DM_IO_KMEM;
                io_req.mem.ptr.addr = NULL;
        }
 
                .count = ps->store->chunk_size,
        };
        struct dm_io_request io_req = {
-               .bi_op = op,
-               .bi_op_flags = op_flags,
+               .bi_opf = op | op_flags,
                .mem.type = DM_IO_VMA,
                .mem.ptr.vma = area,
                .client = ps->io_client,
 
 
                region.sector += wc->start_sector;
                atomic_inc(&endio.count);
-               req.bi_op = REQ_OP_WRITE;
-               req.bi_op_flags = REQ_SYNC;
+               req.bi_opf = REQ_OP_WRITE | REQ_SYNC;
                req.mem.type = DM_IO_VMA;
                req.mem.ptr.vma = (char *)wc->memory_map + (size_t)i * BITMAP_GRANULARITY;
                req.client = wc->dm_io;
 
        region.sector += wc->start_sector;
 
-       req.bi_op = REQ_OP_WRITE;
-       req.bi_op_flags = REQ_SYNC | REQ_FUA;
+       req.bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_FUA;
        req.mem.type = DM_IO_VMA;
        req.mem.ptr.vma = (char *)wc->memory_map;
        req.client = wc->dm_io;
        region.bdev = dev->bdev;
        region.sector = 0;
        region.count = 0;
-       req.bi_op = REQ_OP_WRITE;
-       req.bi_op_flags = REQ_PREFLUSH;
+       req.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
        req.mem.type = DM_IO_KMEM;
        req.mem.ptr.addr = NULL;
        req.client = wc->dm_io;
        region.bdev = wc->ssd_dev->bdev;
        region.sector = wc->start_sector;
        region.count = n_sectors;
-       req.bi_op = REQ_OP_READ;
-       req.bi_op_flags = REQ_SYNC;
+       req.bi_opf = REQ_OP_READ | REQ_SYNC;
        req.mem.type = DM_IO_VMA;
        req.mem.ptr.vma = (char *)wc->memory_map;
        req.client = wc->dm_io;
 
 #ifdef __KERNEL__
 
 #include <linux/types.h>
+#include <linux/blk_types.h>
 
 struct dm_io_region {
        struct block_device *bdev;
  */
 struct dm_io_client;
 struct dm_io_request {
-       int bi_op;                      /* REQ_OP */
-       int bi_op_flags;                /* req_flag_bits */
+       blk_opf_t           bi_opf;     /* Request type and flags */
        struct dm_io_memory mem;        /* Memory to use for io */
        struct dm_io_notify notify;     /* Synchronous if notify.fn is NULL */
        struct dm_io_client *client;    /* Client memory handler */