Re: [PATCH 3/5] fs: remove ki_nbytes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> @@ -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.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux