RE: [PATCH 5/9 next] scsi: Use iovec_import() instead of import_iovec().

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

 



From: Christoph Hellwig
> Sent: 21 September 2020 15:22
> 
> So looking at the various callers I'm not sure this API is the
> best.  If we want to do something fancy I'd hide the struct iovec
> instances entirely with something like:
> 
> struct iov_storage {
> 	struct iovec stack[UIO_FASTIOV], *vec;
> }
> 
> int iov_iter_import_iovec(struct iov_iter *iter, struct iov_storage *s,
> 		const struct iovec __user *vec, unsigned long nr_segs,
> 		int type);
> 
> and then add a new helper to free the thing if needed:
> 
> void iov_iter_release_iovec(struct iov_storage *s)
> {
> 	if (s->vec != s->stack)
> 		kfree(s->vec);
> }

I didn't think of going that far.
There are 2 call sites (in scsi) that don't pass the cache.

Given that the 'buffer to free' address probably needs to
be spilled to stack forcing in into an on-stack structure
that is already passed by address is probably a good idea.

The iov_iter_release_iovec() should be static inline and just:
	if (s->vec)
		kfree(s->vec);
You want the test because 99.99% of the time it will be NULL.
The kernel iov[] to use is iter.iov not part of the cache.

That will be a bigger change on the io_uring code.
(The patch I didn't write.)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[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