Block storage copy offloading#768
Open
blktests-ci[bot] wants to merge 12 commits intolinus-master_basefrom
Open
Block storage copy offloading#768blktests-ci[bot] wants to merge 12 commits intolinus-master_basefrom
blktests-ci[bot] wants to merge 12 commits intolinus-master_basefrom
Conversation
Add the following request queue limits: - max_copy_hw_sectors: the maximum number of sectors supported by the block driver for a single offloaded copy operation. - max_copy_src_segments: the maximum number of source segments supported by the block driver for a single offloaded copy operation. - max_copy_dst_segments: the maximum number of destination segments supported by the block driver for a single offloaded copy operation. - max_user_copy_sectors: the maximum number of sectors configured by the user for a single offloaded copy operation. - max_copy_sectors: the maximum number of sectors for a single offloaded copy operation. This is the minimum of the above two parameters. The default value for all these new limits is zero which means that copy offloading is not supported unless if these limits are set by the block driver. ake the following two limits available in sysfs: - copy_max_bytes (RW) - copy_max_hw_bytes (RO) These limits will be used by the function that implements copy offloading to decide the bio size. Signed-off-by: Nitesh Shetty <[email protected]> Signed-off-by: Kanchan Joshi <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> [ bvanassche: Added max_copy_{src,dst}_segments limits. Introduced blk_validate_copy_limits(). Introduced BLK_FEAT_STACKING_COPY_OFFL. Modified patch description. ] Signed-off-by: Bart Van Assche <[email protected]>
Introduce the REQ_OP_COPY_SRC and REQ_OP_COPY_DST operations. The source
and destination LBA range information is in separate bios because any
other approach would require a rewrite of the device mapper. These bios
are associated with each other via the new bi_copy_ctx pointer. A new
pointer has been introduced because the copy offloading context
information must be preserved when cloning a bio and the bi_private bio
member must not be copied when cloning a bio.
This patch supports the following approach for copy offloading:
1. Allocate a struct bio_copy_offload_ctx instance and set phase to
BLKDEV_TRANSLATE_LBAS.
2. Allocate REQ_OP_COPY_SRC and REQ_OP_COPY_DST bios. Set the
bi_copy_ctx member of these bios.
3. Set the bio_count member of struct bio_copy_offload_ctx.
4. Submit all REQ_OP_COPY_* bios.
5. In submit_bio(), do the following for REQ_OP_COPY_* bios:
- If bio->bi_bdev is a stacking device, submit the bio. This will
send the bio to the device mapper. The device mapper will clone the
bio, translate the LBAs and will submit the cloned bio. That will
result in a recursive submit_bio() call.
- If bio->bi_bdev is not a stacking device, add the bio to the
copy_ctx->bios list and decrement copy_ctx->bio_count.
6. Once copy_ctx->bio_count == 0, call copy_ctx->translation_complete().
7. In the implementation of copy_ctx->translation_complete(), change
copy_ctx->phase from BLKDEV_TRANSLATE_LBAS into BLKDEV_COPY.
8. Submit the first REQ_OP_COPY_* bio of the copy_ctx->bios list.
9. Once this bio reaches the block driver associated with the bio,
retrieve the other bios involved in the copy operation from the copy
context data structure and convert all these bios into a copy offload
operation.
10. Once this bio completes, also complete all the other bios involved
in the copy offload operation.
This patch increases the size of struct bio from 104 to 112 bytes on 64-bit
systems.
To be discussed further: whether adding a new member in struct bio is
acceptable or whether the new pointer perhaps should be stored in front of
the bio. bioset_init() supports front padding.
Signed-off-by: Nitesh Shetty <[email protected]>
Signed-off-by: Anuj Gupta <[email protected]>
[ bvanassche: changed the approach of this patch from combining the
COPY_SRC and COPY_DST operations immediately to translating the LBA
information first. ]
Signed-off-by: Bart Van Assche <[email protected]>
Introduce blkdev_copy_offload() for performing copy offloading. This function implements the algorithm explained the description of the previous patch. If the input parameters exceed what can be supported with a single copy offload operation, multiple copy offload operations are submitted. Signed-off-by: Bart Van Assche <[email protected]>
For the devices which do not support copy offloading, add a function that copies data by submitting READ and WRITE operations. Onloaded copying is implemented by reading from the source block device into memory and by writing this data to the destination block device. Signed-off-by: Nitesh Shetty <[email protected]> Signed-off-by: Vincent Fu <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> Signed-off-by: Bart Van Assche <[email protected]>
Make it easy for block drivers to iterate over the copy offload bios by providing accessor functions for the copy offloading bios. Signed-off-by: Bart Van Assche <[email protected]>
Prepare for adding copy_file_range() support for block devices by making the following changes: - Change file_inode(file) into file->f_mapping->host. Although only one inode is associated with regular files, two inodes are associated with block devices. file->f_mapping->host is the primary block device inode. - Change S_ISREG() into S_ISREG() || S_ISBLK(). - Add an inode->i_mode & S_IFMT check that verifies that source and destination have the same type (block device or regular file). Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> Signed-off-by: Nitesh Shetty <[email protected]> [ bvanassche: rewrote patch description ] Signed-off-by: Bart Van Assche <[email protected]>
Add copy_file_range() support for block devices. If input and output block devices have been opened with O_DIRECT and if copy offloading is supported use blkdev_copy_offload(). Otherwise use splice_copy_file_range(). Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> Signed-off-by: Nitesh Shetty <[email protected]> Signed-off-by: Bart Van Assche <[email protected]>
Add support for the NVMe Copy command. This command supports a single destination range and up to 256 source ranges. Add trace event support for nvme_copy_cmd. Signed-off-by: Kanchan Joshi <[email protected]> Signed-off-by: Nitesh Shetty <[email protected]> Signed-off-by: Javier González <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> [ bvanassche: generalized Copy support from one to 256 source ranges; fixed an endianness issue in nvme_config_copy(); renamed rsvd91 into rsvd81 and verified the offset with pahole ] Signed-off-by: Bart Van Assche <[email protected]>
Support the Copy command for namespaces backed by a block device or by a file. For namespaces backed by a block device, we call blkdev_copy_offload() and fall back to blkdev_copy_onload() if necessary. For namespaces backed by a file we call vfs_copy_file_range(). nvmet always reports that the Copy command is supported. Tracing support is added for the Copy command. Signed-off-by: Nitesh Shetty <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> [ bvanassche: Increased namespace limits. ] Signed-off-by: Bart Van Assche <[email protected]>
In dm_calculate_queue_limits(), clear the copy offload limits if the device mapper driver does not support copy offloading. This is necessary since blk_set_stacking_limits() sets the copy offload limits to their maximum. Signed-off-by: Bart Van Assche <[email protected]>
Set BLK_FEAT_STACKING_COPY_OFFL and max_copy_hw_sectors to enable copy offloading. Signed-off-by: Bart Van Assche <[email protected]>
Implementation is based on existing read and write infrastructure. copy_max_bytes: A new configfs and module parameter is introduced, which can be used to set hardware/driver supported maximum copy limit. Only request based queue mode will support for copy offload. Added tracefs support to copy IO tracing. Suggested-by: Damien Le Moal <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> Signed-off-by: Nitesh Shetty <[email protected]> Signed-off-by: Vincent Fu <[email protected]> [ bvanassche: Split nullb_do_copy() into two functions. Added a cond_resched() call inside nullb_do_copy(). ] Signed-off-by: Bart Van Assche <[email protected]>
Author
|
Upstream branch: dd6c438 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: Block storage copy offloading
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1085363