[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220427130315.GB9558@test-zns>
Date: Wed, 27 Apr 2022 18:33:15 +0530
From: Nitesh Shetty <nj.shetty@...sung.com>
To: Damien Le Moal <damien.lemoal@...nsource.wdc.com>
Cc: linux-block@...r.kernel.org, linux-scsi@...r.kernel.org,
dm-devel@...hat.com, linux-nvme@...ts.infradead.org,
linux-fsdevel@...r.kernel.org, nitheshshetty@...il.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 03/10] block: Introduce a new ioctl for copy
O Wed, Apr 27, 2022 at 11:48:57AM +0900, Damien Le Moal wrote:
> On 4/26/22 19: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;
> > }
>
> Nice to have a code example. But please format it correctly.
>
acked
--
Nitesh Shetty
Powered by blists - more mailing lists