Messages in this thread | | | Date | Wed, 27 Apr 2022 12:37:07 +0200 | From | Hannes Reinecke <> | Subject | Re: [PATCH v4 03/10] block: Introduce a new ioctl for copy |
| |
On 4/26/22 12:12, Nitesh Shetty wrote: > Add new BLKCOPY ioctl that offloads copying of one or more sources ranges > to one or more destination in a device. COPY ioctl accepts a 'copy_range' > structure that contains no of range, a reserved field , followed by an > array of ranges. Each source range is represented by 'range_entry' that > contains source start offset, destination start offset and length of > source ranges (in bytes) > > MAX_COPY_NR_RANGE, limits the number of entries for the IOCTL and > MAX_COPY_TOTAL_LENGTH limits the total copy length, IOCTL can handle. > > Example code, to issue BLKCOPY: > /* Sample example to copy three entries with [dest,src,len], > * [32768, 0, 4096] [36864, 4096, 4096] [40960,8192,4096] on same device */ > > int main(void) > { > int i, ret, fd; > unsigned long src = 0, dst = 32768, len = 4096; > struct copy_range *cr; > cr = (struct copy_range *)malloc(sizeof(*cr)+ > (sizeof(struct range_entry)*3)); > cr->nr_range = 3; > cr->reserved = 0; > for (i = 0; i< cr->nr_range; i++, src += len, dst += len) { > cr->range_list[i].dst = dst; > cr->range_list[i].src = src; > cr->range_list[i].len = len; > cr->range_list[i].comp_len = 0; > } > fd = open("/dev/nvme0n1", O_RDWR); > if (fd < 0) return 1; > ret = ioctl(fd, BLKCOPY, cr); > if (ret != 0) > printf("copy failed, ret= %d\n", ret); > for (i=0; i< cr->nr_range; i++) > if (cr->range_list[i].len != cr->range_list[i].comp_len) > printf("Partial copy for entry %d: requested %llu, completed %llu\n", > i, cr->range_list[i].len, > cr->range_list[i].comp_len); > close(fd); > free(cr); > return ret; > } > > Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com> > Signed-off-by: Javier González <javier.gonz@samsung.com> > Signed-off-by: Arnav Dawn <arnav.dawn@samsung.com> > --- > block/ioctl.c | 32 ++++++++++++++++++++++++++++++++ > include/uapi/linux/fs.h | 9 +++++++++ > 2 files changed, 41 insertions(+) > Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
| |