diff --git a/drivers/block/ubd/ubd_drv.c b/drivers/block/ubd/ubd_drv.c index 0176d81b87972..765940f12dbda 100644 --- a/drivers/block/ubd/ubd_drv.c +++ b/drivers/block/ubd/ubd_drv.c @@ -311,11 +311,44 @@ static int ubd_unmap_io(struct request *req) return 0; } +static inline unsigned int ubd_req_build_flags(struct request *req) +{ + unsigned flags = 0; + + if (req->cmd_flags & REQ_FAILFAST_DEV) + flags |= UBD_IO_F_FAILFAST_DEV; + + if (req->cmd_flags & REQ_FAILFAST_TRANSPORT) + flags |= UBD_IO_F_FAILFAST_TRANSPORT; + + if (req->cmd_flags & REQ_FAILFAST_DRIVER) + flags |= UBD_IO_F_FAILFAST_DRIVER; + + if (req->cmd_flags & REQ_META) + flags |= UBD_IO_F_META; + + if (req->cmd_flags & REQ_INTEGRITY) + flags |= UBD_IO_F_INTEGRITY; + + if (req->cmd_flags & REQ_FUA) + flags |= UBD_IO_F_FUA; + + if (req->cmd_flags & REQ_PREFLUSH) + flags |= UBD_IO_F_PREFLUSH; + + if (req->cmd_flags & REQ_NOUNMAP) + flags |= UBD_IO_F_NOUNMAP; + + if (req->cmd_flags & REQ_SWAP) + flags |= UBD_IO_F_SWAP; + + return flags; +} + static int ubd_setup_iod(struct ubd_queue *ubq, struct request *req) { struct ubdsrv_io_desc *iod = ubd_get_iod(ubq, req->tag); struct ubd_io *io = &ubq->ios[req->tag]; - u32 flags = req->cmd_flags & ~REQ_OP_MASK; u32 ubd_op; switch (req_op(req)) { @@ -339,7 +372,7 @@ static int ubd_setup_iod(struct ubd_queue *ubq, struct request *req) } /* need to translate since kernel may change */ - iod->op_flags = ubd_op | flags; + iod->op_flags = ubd_op | ubd_req_build_flags(req); iod->tag_blocks = req->tag | (blk_rq_sectors(req) << 12); iod->start_block = blk_rq_pos(req); iod->addr = io->addr; diff --git a/include/uapi/linux/ubd_cmd.h b/include/uapi/linux/ubd_cmd.h index 652919ef15f0d..be25bb72c1094 100644 --- a/include/uapi/linux/ubd_cmd.h +++ b/include/uapi/linux/ubd_cmd.h @@ -97,25 +97,15 @@ struct ubdsrv_ctrl_dev_info { #define UBD_IO_OP_WRITE_SAME 4 #define UBD_IO_OP_WRITE_ZEROES 5 -#define UBD_IO_F_FAILFAST_DEV 8 -#define UBD_IO_F_FAILFAST_TRANS 9 -#define UBD_IO_F_FAILFAST_DRV 10 -#define UBD_IO_F_SYC 11 -#define UBD_IO_F_META 12 -#define UBD_IO_F_PRIO 13 -#define UBD_IO_F_NOMERGE 14 -#define UBD_IO_F_IDLE 15 -#define UBD_IO_F_INTEGRITY 16 -#define UBD_IO_F_FUA 17 -#define UBD_IO_F_PREFLUSH 18 -#define UBD_IO_F_RAHEAD 19 -#define UBD_IO_F_BACKGROUND 20 -#define UBD_IO_F_NOWAIT 21 -#define UBD_IO_F_CG_PUNT 22 -#define UBD_IO_F_NOUNMAP 23 -#define UBD_IO_F_POLLED 24 -#define UBD_IO_F_DRV 25 -#define UBD_IO_F_SWAP 26 +#define UBD_IO_F_FAILFAST_DEV (1U << 8) +#define UBD_IO_F_FAILFAST_TRANSPORT (1U << 9) +#define UBD_IO_F_FAILFAST_DRIVER (1U << 10) +#define UBD_IO_F_META (1U << 11) +#define UBD_IO_F_INTEGRITY (1U << 12) +#define UBD_IO_F_FUA (1U << 13) +#define UBD_IO_F_PREFLUSH (1U << 14) +#define UBD_IO_F_NOUNMAP (1U << 15) +#define UBD_IO_F_SWAP (1U << 16) /* * io cmd is described by this structure, and stored in share memory, indexed