Skip to content

Commit d74a383

Browse files
calebsanderaxboe
authored andcommitted
ublk: add helpers to check ublk_device flags
Introduce ublk_device analogues of the ublk_queue flag helpers: - ublk_support_zero_copy() -> ublk_dev_support_user_copy() - ublk_support_auto_buf_reg() -> ublk_dev_support_auto_buf_reg() - ublk_support_user_copy() -> ublk_dev_support_user_copy() - ublk_need_map_io() -> ublk_dev_need_map_io() - ublk_need_req_ref() -> ublk_dev_need_req_ref() - ublk_need_get_data() -> ublk_dev_need_get_data() These will be used in subsequent changes to avoid accessing the ublk_queue just for the flags, and instead use the ublk_device. Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0265595 commit d74a383

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

drivers/block/ublk_drv.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,22 +662,44 @@ static inline bool ublk_support_zero_copy(const struct ublk_queue *ubq)
662662
return ubq->flags & UBLK_F_SUPPORT_ZERO_COPY;
663663
}
664664

665+
static inline bool ublk_dev_support_zero_copy(const struct ublk_device *ub)
666+
{
667+
return ub->dev_info.flags & UBLK_F_SUPPORT_ZERO_COPY;
668+
}
669+
665670
static inline bool ublk_support_auto_buf_reg(const struct ublk_queue *ubq)
666671
{
667672
return ubq->flags & UBLK_F_AUTO_BUF_REG;
668673
}
669674

675+
static inline bool ublk_dev_support_auto_buf_reg(const struct ublk_device *ub)
676+
{
677+
return ub->dev_info.flags & UBLK_F_AUTO_BUF_REG;
678+
}
679+
670680
static inline bool ublk_support_user_copy(const struct ublk_queue *ubq)
671681
{
672682
return ubq->flags & UBLK_F_USER_COPY;
673683
}
674684

685+
static inline bool ublk_dev_support_user_copy(const struct ublk_device *ub)
686+
{
687+
return ub->dev_info.flags & UBLK_F_USER_COPY;
688+
}
689+
675690
static inline bool ublk_need_map_io(const struct ublk_queue *ubq)
676691
{
677692
return !ublk_support_user_copy(ubq) && !ublk_support_zero_copy(ubq) &&
678693
!ublk_support_auto_buf_reg(ubq);
679694
}
680695

696+
static inline bool ublk_dev_need_map_io(const struct ublk_device *ub)
697+
{
698+
return !ublk_dev_support_user_copy(ub) &&
699+
!ublk_dev_support_zero_copy(ub) &&
700+
!ublk_dev_support_auto_buf_reg(ub);
701+
}
702+
681703
static inline bool ublk_need_req_ref(const struct ublk_queue *ubq)
682704
{
683705
/*
@@ -695,6 +717,13 @@ static inline bool ublk_need_req_ref(const struct ublk_queue *ubq)
695717
ublk_support_auto_buf_reg(ubq);
696718
}
697719

720+
static inline bool ublk_dev_need_req_ref(const struct ublk_device *ub)
721+
{
722+
return ublk_dev_support_user_copy(ub) ||
723+
ublk_dev_support_zero_copy(ub) ||
724+
ublk_dev_support_auto_buf_reg(ub);
725+
}
726+
698727
static inline void ublk_init_req_ref(const struct ublk_queue *ubq,
699728
struct ublk_io *io)
700729
{
@@ -726,6 +755,11 @@ static inline bool ublk_need_get_data(const struct ublk_queue *ubq)
726755
return ubq->flags & UBLK_F_NEED_GET_DATA;
727756
}
728757

758+
static inline bool ublk_dev_need_get_data(const struct ublk_device *ub)
759+
{
760+
return ub->dev_info.flags & UBLK_F_NEED_GET_DATA;
761+
}
762+
729763
/* Called in slow path only, keep it noinline for trace purpose */
730764
static noinline struct ublk_device *ublk_get_device(struct ublk_device *ub)
731765
{

0 commit comments

Comments
 (0)