block: Add top level BSG support
PATCH 1/5 block: Add top level BSG support
From: Nicholas Bellinger <[email protected]>
This patch adds top level BSG support to QEMU-KVM block and adds the BDS_* prefixed defines for SG_IO and BSG.
It adds the BDS_SCSI_GENERIC and BDS_BSG assignments in block/raw-posix.c:hdev_open() using S_ISCHR() and major(st.st_rdev) in order to determine when we are dealing with scsi-generic or scsi-bsg backstores.
--- block.c | 7 +++++- block.h | 1 + block/raw-posix.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++--- block_int.h | 6 +++++ 4 files changed, 74 insertions(+), 5 deletions(-)
block.c +6 -1
@@ -1340,7 +1340,12 @@ int bdrv_is_read_only(BlockDriverState *bs)int bdrv_is_sg (BlockDriverState *bs) { -return bs->sg; +return bs->sg ==BDS_SCSI_GENERIC ; +} + +int bdrv_is_bsg (BlockDriverState *bs) +{ +return bs->sg ==BDS_BSG ; }int bdrv_enable_write_cache (BlockDriverState *bs)
block.h +1 -0
@@ -174,6 +174,7 @@ void bdrv_set_removable(BlockDriverState *bs, int removable);int bdrv_is_removable (BlockDriverState *bs);int bdrv_is_read_only (BlockDriverState *bs);int bdrv_is_sg (BlockDriverState *bs); +int bdrv_is_bsg (BlockDriverState *bs);int bdrv_enable_write_cache (BlockDriverState *bs);int bdrv_is_inserted (BlockDriverState *bs);int bdrv_media_changed (BlockDriverState *bs);
block/raw-posix.c +61 -4
80 lines not on this page · raw message
block_int.h +6 -0
@@ -40,6 +40,11 @@#define BLOCK_OPT_CLUSTER_SIZE "cluster_size"#define BLOCK_OPT_PREALLOC "preallocation" +/* Used for BlockDriverState->sg */ +#define BDS_NONE 0 +#define BDS_SCSI_GENERIC 1 +#define BDS_BSG 2 + typedef struct AIOPool { void (*cancel)(BlockDriverAIOCB *acb); int aiocb_size;
@@ -150,6 +155,7 @@ struct BlockDriverState {int encrypted;/* if true, the media is encrypted */ int valid_key;/* if true, a valid encryption key has been set */ int sg;/* if true, the device is a /dev/sg* */ +int fd;/* Used for BSG file descriptor */ /* event callback when inserting/removing */ void (*change_cb)(void *opaque);void *change_opaque;
Signature · 1 line
1.5.6.5
Nick,
can we wait a bit with this series? With the threadlets currently pending for inclusion I can get my rewrite of the generic-generic to not abuse the qemu block layer out of the closet again, which should simplify a lot of the things you're touching here.
Quoted 7 lines · Christoph Hellwig
Nick,
can we wait a bit with this series? With the threadlets currently pending for inclusion I can get my rewrite of the generic-generic to not abuse the qemu block layer out of the closet again, which should simplify a lot of the things you're touching here.
Sure, no big rush on this series now that it's been updated to run against recent v2 QEMU SCSI changes and latest megasas emulation code. I must have missed your threadlets block rewrite series, but am interested to see how this can simply things wrt to scsi-generic and scsi-bsg -> accessing kernel backend devices.
But yeah, the lack of a proper bsg_rq_map_user_iov() handler in block/bsg.c:bsg_map_hdr() still needs to be addressed in the mainline kernel, so that SCSIDeviceInfo->alloc_req_iov() generated SCSIRequest can function properly in patch #5.
--nab