lkml.org 
[lkml]   [2021]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH rdma-next v2 1/2] lib/scatterlist: Fix wrong update of orig_nents
On Thu, Jul 22, 2021 at 10:00:40AM -0300, Jason Gunthorpe wrote:
> this is better:
>
> struct sg_append_table state;
>
> sg_append_init(&state, sgt, gfp_mask);
>
> while (..)
> ret = sg_append_pages(&state, pages, n_pages, ..)
> if (ret)
> sg_append_abort(&state); // Frees the sgt and puts it to NULL
> sg_append_complete(&state)
>
> Which allows sg_alloc_table_from_pages() to be written as
>
> struct sg_append_table state;
> sg_append_init(&state, sgt, gfp_mask);
> ret = sg_append_pages(&state,pages, n_pages, offset, size, UINT_MAX)
> if (ret) {
> sg_append_abort(&state);
> return ret;
> }
> sg_append_complete(&state);
> return 0;
>
> And then the API can manage all of this in some sane and
> understandable way.

That would be a lot easier to use for sure. Not sure how invasive the
changes would be, though.

\
 
 \ /
  Last update: 2021-07-22 19:36    [W:0.718 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site