@@ -2244,10 +2244,18 @@ static ssize_t qib_write_iter(struct kiocb *iocb, struct iov_iter *from)
struct qib_filedata *fp = iocb->ki_filp->private_data;
struct qib_ctxtdata *rcd = ctxt_fp(iocb->ki_filp);
struct qib_user_sdma_queue *pq = fp->pq;
+ int nr_segs = iovec_nr_user_vecs(from);
- if (!iter_is_iovec(from) || !from->nr_segs || !pq)
+ if (!from->user_backed)
+ return -EFAULT;
+ if (!nr_segs || !pq)
return -EINVAL;
+ if (nr_segs == 1) {
+ struct iovec iov = iov_iter_iovec(from);
+ return qib_user_sdma_writev(rcd, pq, &iov, 1);
+ }
+
return qib_user_sdma_writev(rcd, pq, from->iov, from->nr_segs);
}
Don't assume that a user backed iterator is always of the type ITER_IOVEC. Handle the single segment case separately, then we can use the same logic for ITER_UBUF and ITER_IOVEC. Signed-off-by: Jens Axboe <axboe@kernel.dk> --- drivers/infiniband/hw/qib/qib_file_ops.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)