From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH 1/3] fs: add vfs_bvec_{read,write} helpers Date: Fri, 23 Jan 2015 06:00:49 +0000 Message-ID: <20150123060049.GD29656@ZenIV.linux.org.uk> References: <1421593624-4462-1-git-send-email-hch@lst.de> <1421593624-4462-2-git-send-email-hch@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jens Axboe , Nicholas Bellinger , Ming Lei , linux-fsdevel@vger.kernel.org, target-devel@vger.kernel.org To: Christoph Hellwig Return-path: Content-Disposition: inline In-Reply-To: <1421593624-4462-2-git-send-email-hch@lst.de> Sender: target-devel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sun, Jan 18, 2015 at 04:07:02PM +0100, Christoph Hellwig wrote: > Signed-off-by: Christoph Hellwig > --- > fs/read_write.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > fs/splice.c | 23 +++------------------ > include/linux/fs.h | 5 +++++ > 3 files changed, 68 insertions(+), 20 deletions(-) > > diff --git a/fs/read_write.c b/fs/read_write.c > index c0805c9..299e262 100644 > --- a/fs/read_write.c > +++ b/fs/read_write.c > @@ -333,6 +333,66 @@ out_putf: > } > #endif > > +ssize_t vfs_bvec_read(struct file *file, struct bio_vec *vec, > + unsigned long nr_segs, size_t count, loff_t *ppos) > +{ > + struct iov_iter iter; > + struct kiocb kiocb; > + ssize_t ret; > + > + if (!file->f_op->read_iter) > + return -EBADFD; #define EBADFD 77 /* File descriptor in bad state */ Looks really odd. For crying out loud, what's a STREAMS-related error doing here? What's more, it's a bloody awful one - spelling is too similar to EBADF and it's really asking for typos that end up as uncaught rarely-triggered bugs. > + iter.type = ITER_BVEC | READ; > + iter.bvec = vec; > + iter.nr_segs = nr_segs; > + iter.count = count; > + iter.iov_offset = 0; iov_iter_bvec(), please (see vfs.git#for-next). > +ssize_t vfs_bvec_write(struct file *file, struct bio_vec *vec, > + unsigned long nr_segs, size_t count, loff_t *ppos) Same comments here. I can pick that, but EBADFD is awful and I would very much prefer to avoid it from the very beginning.