Skip to content

Commit

Permalink
iov_iter: Add extraction functions
Browse files Browse the repository at this point in the history
Hi Al, Jeff,

Here's a replacement for the extract_iter_to_iter() patch I had previously.
It's a WIP, some bits aren't fully implemented, though some bits I have tested
and got to work, but if you could take a look and see if you're okay with the
interface.

I think I've addressed most of Al's comments.  The page-pinning is conditional
on certain types of iterator, and a number of the iterator types just extract
to the same thing.  It should now handle kvec-class iterators that refer to
vmalloc'd data.

I've also added extraction to scatterlist (which I'll need for doing various
crypto things) and extraction to ib_sge which could be used in cifs/smb RDMA,
bypassing the conversion-to-scatterlist step.

As mentioned, there are bits that aren't fully implemented, let alone tested.

David
  • Loading branch information
dhowells authored and intel-lab-lkp committed Sep 9, 2022
1 parent ce88822 commit a8df8a8
Show file tree
Hide file tree
Showing 3 changed files with 699 additions and 1 deletion.
45 changes: 45 additions & 0 deletions include/linux/uio2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* iov_iter extractors
*
* Copyright (C) 2022 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com)
*/

#ifndef _LINUX_UIO2_H
#define _LINUX_UIO2_H

#include <linux/uio.h>
#include <linux/dma-direction.h>

struct sg_table;
struct ib_device;
struct ib_sge;

/*
* Cleanup information for an extracted iterator.
*/
struct iov_iter_cleanup {
union {
struct bio_vec *bv;
struct kvec *kv;
};
unsigned int nr_segs;
bool pages_pinned;
enum iter_type type:8;
};

ssize_t extract_iter_to_iter(struct iov_iter *iter, size_t len,
struct iov_iter *to,
struct iov_iter_cleanup *cleanup);
ssize_t extract_iter_to_sg(struct iov_iter *iter, size_t len,
struct sg_table *sgtable, bool *pinned);
ssize_t extract_iter_to_rdma(struct iov_iter *iter, size_t len,
struct ib_device *device, u32 local_dma_lkey,
enum dma_data_direction direction,
struct ib_sge *sge, unsigned int max_sge,
unsigned int *nr_sge);
void iov_iter_flush_dcache(struct iov_iter *iter,
struct iov_iter_cleanup *cleanup);
void iov_iter_clean_up(struct iov_iter_cleanup *cleanup);

#endif /* _LINUX_UIO2_H */
2 changes: 1 addition & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ obj-y += lockref.o

obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
bust_spinlocks.o kasprintf.o bitmap.o scatterlist.o \
list_sort.o uuid.o iov_iter.o clz_ctz.o \
list_sort.o uuid.o iov_iter.o iov_iter_extract.o clz_ctz.o \
bsearch.o find_bit.o llist.o memweight.o kfifo.o \
percpu-refcount.o rhashtable.o base64.o \
once.o refcount.o usercopy.o errseq.o bucket_locks.o \
Expand Down

0 comments on commit a8df8a8

Please sign in to comment.