Re: [RFC PATCH v5 3/4] nvme: add simple copy support

Selva Jove
2021-02-22T15:58:17Z

Matthew,

Maximum Source Range Count (MSRC) is limited by u8. So the maximum
number of source ranges is 256 (0 base value). The number of pages
required to be sent to the device is at most 2. Since we are
allocating the memory using kmalloc_array(), we would get a continuous
physical segment. nvme_map_data() maps the physical segment either by
setting 2 PRP pointers or by SGL. So the copy command sends two pages
to the device for copying more than128 ranges.

On Sat, Feb 20, 2021 at 9:08 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Fri, Feb 19, 2021 at 06:15:16PM +0530, SelvaKumar S wrote:
> > + struct nvme_copy_range *range = NULL;
> [...]
> > + range = kmalloc_array(nr_range, sizeof(*range),
> > + GFP_ATOMIC | __GFP_NOWARN);
> [...]
> > + req->special_vec.bv_page = virt_to_page(range);
> > + req->special_vec.bv_offset = offset_in_page(range);
> > + req->special_vec.bv_len = sizeof(*range) * nr_range;
> [...]
> > +struct nvme_copy_range {
> > + __le64 rsvd0;
> > + __le64 slba;
> > + __le16 nlb;
> > + __le16 rsvd18;
> > + __le32 rsvd20;
> > + __le32 eilbrt;
> > + __le16 elbat;
> > + __le16 elbatm;
> > +};
>
> so ... at 32 bytes, you can get 128 per 4kB page. What happens if you
> try to send down a command that attempts to copy 129 ranges?