From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH 3/5] fs: remove ki_nbytes Date: Sat, 31 Jan 2015 06:08:41 +0000 Message-ID: <20150131060841.GM29656@ZenIV.linux.org.uk> References: <1422381313-24034-1-git-send-email-hch@lst.de> <1422381313-24034-4-git-send-email-hch@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Miklos Szeredi , linux-aio@kvack.org, linux-fsdevel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:55172 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbbAaGIp (ORCPT ); Sat, 31 Jan 2015 01:08:45 -0500 Content-Disposition: inline In-Reply-To: <1422381313-24034-4-git-send-email-hch@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: > @@ -717,14 +718,14 @@ ep_aio_write(struct kiocb *iocb, const struct iovec *iov, > unsigned long nr_segs, loff_t o) > { > struct ep_data *epdata = iocb->ki_filp->private_data; > + size_t len = iov_length(iov, nr_segs); > char *buf; > - size_t len = 0; > int i = 0; > > if (unlikely(!usb_endpoint_dir_in(&epdata->desc))) > return -EINVAL; > > - buf = kmalloc(iocb->ki_nbytes, GFP_KERNEL); > + buf = kmalloc(len, GFP_KERNEL); > if (unlikely(!buf)) > return -ENOMEM; > > @@ -734,7 +735,6 @@ ep_aio_write(struct kiocb *iocb, const struct iovec *iov, > kfree(buf); > return -EFAULT; > } > - len += iov[i].iov_len; > } > return ep_aio_rwtail(iocb, buf, len, epdata, NULL, 0); WTF bother? Just switch it to ->write_iter(): static ssize_t ep_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct ep_data *epdata = iocb->ki_filp->private_data; size_t len = iov_iter_count(from); void *buf; if (unlikely(!usb_endpoint_dir_in(&epdata->desc))) return -EINVAL; buf = kmalloc(iov_iter_count(from), GFP_KERNEL); if (unlikely(!buf)) return -ENOMEM; if (copy_from_iter(buf, from, len) != len) { kfree(buf); return -EFAULT; } return ep_aio_rwtail(iocb, buf, len, epdata, NULL, 0); } and be done with that. I'll put drivers/usb/gadget patches into a stable branch and ask use folks to pull from it - that's the simplest of this series, actually... > @@ -903,10 +903,9 @@ static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, > if (pos != 0) > return -ESPIPE; > > - if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */ > + if (!iov_length(iov, nr_segs)) /* Match SYS5 behaviour */ > return 0; FWIW, it's switched to ->read_iter/->write_iter in vfs.git#for-davem.