Thread (8 messages) 8 messages, 3 authors, 2021-07-22

Re: [PATCH rdma-next v2 1/2] lib/scatterlist: Fix wrong update of orig_nents

From: Christoph Hellwig <hch@infradead.org>
Date: 2021-07-22 13:08:57
Also in: intel-gfx, lkml

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help