Skip to content

NAS-129309 / None / Copy offload support for block devices#203

Merged
ixhamza merged 6 commits intotruenas/linux-6.12from
NAS-129309
Dec 19, 2024
Merged

NAS-129309 / None / Copy offload support for block devices#203
ixhamza merged 6 commits intotruenas/linux-6.12from
NAS-129309

Conversation

@ixhamza
Copy link
Copy Markdown
Member

@ixhamza ixhamza commented Dec 18, 2024

This PR introduces partial upstream support for copy offload functionality to make zvol block cloning functional. In addition, we have implemented support for single-queue and cross-device copy, which are currently not supported by the upstream patch.

Related Patches

How Has This Been Tested?

nj-shetty and others added 5 commits December 18, 2024 05:51
Add device limits as sysfs entries,
	- copy_max_bytes (RW)
	- copy_max_hw_bytes (RO)

Above limits help to split the copy payload in block layer.
copy_max_bytes: maximum total length of copy in single payload.
copy_max_hw_bytes: Reflects the device supported maximum limit.

Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
We add two new opcode REQ_OP_COPY_DST, REQ_OP_COPY_SRC.
Since copy is a composite operation involving src and dst sectors/lba,
each needs to be represented by a separate bio to make it compatible
with device mapper.
We expect caller to take a plug and send bio with destination information,
followed by bio with source information.
Once the dst bio arrives we form a request and wait for source
bio. Upon arrival of source bio we merge these two bio's and send
corresponding request down to device driver.
Merging non copy offload bio is avoided by checking for copy specific
opcodes in merge function.

Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Introduce blkdev_copy_offload to perform copy offload.
Issue REQ_OP_COPY_DST with destination info along with taking a plug.
This flows till request layer and waits for src bio to arrive.
Issue REQ_OP_COPY_SRC with source info and this bio reaches request
layer and merges with dst request.
For any reason, if a request comes to the driver with only one of src/dst
bio, we fail the copy offload.

Larger copy will be divided, based on max_copy_sectors limit.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
This is a prep patch. Allow copy_file_range to work for block devices.
Relaxing generic_copy_file_checks allows us to reuse the existing infra,
instead of adding a new user interface for block copy offload.
Change generic_copy_file_checks to use ->f_mapping->host for both inode_in
and inode_out. Allow block device in generic_file_rw_checks.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
For direct block device opened with O_DIRECT, use blkdev_copy_offload to
issue device copy offload, or use splice_copy_file_range in case
device copy offload capability is absent or the device files are not open
with O_DIRECT.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
@bugclerk
Copy link
Copy Markdown

@bugclerk bugclerk changed the title Copy offload support for block devices NAS-129309 / None / Copy offload support for block devices Dec 18, 2024
Comment thread block/blk-lib.c Outdated
@ixhamza ixhamza force-pushed the NAS-129309 branch 2 times, most recently from 500c6ff to 9236ab0 Compare December 18, 2024 15:39
Comment thread block/fops.c Outdated
@ixhamza ixhamza force-pushed the NAS-129309 branch 2 times, most recently from 124d7bc to dd5ffc3 Compare December 19, 2024 18:08
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
@ixhamza ixhamza merged commit d2e6686 into truenas/linux-6.12 Dec 19, 2024
@bugclerk
Copy link
Copy Markdown

Not updating JIRA ticket https://ixsystems.atlassian.net/browse/NAS-129309 target versions as no JIRA version corresponds to this PR

@bugclerk
Copy link
Copy Markdown

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Dec 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants