RE: [RFC v2] nvfs: a filesystem for persistent memory

From: David Laight
Date: Mon Jan 11 2021 - 06:59:07 EST


From: Mikulas Patocka
> Sent: 11 January 2021 11:44
> On Mon, 11 Jan 2021, David Laight wrote:
>
> > From: Al Viro <viro@xxxxxxxxxxxxxxxx> On Behalf Of Al Viro
> > > Sent: 10 January 2021 16:20
...
...
> > > while (iov_iter_count(to)) {
...
> > > size = copy_to_iter(to, ptr, size);
> > > if (unlikely(!size)) {
> > > r = -EFAULT;
> > > goto ret_r;
> > > }
> > >
> > > pos += size;
> > > total += size;
> > > } while (iov_iter_count(to));
> >
> > That isn't the best formed loop!
> >
> > David
>
> I removed the second "while" statement and fixed the arguments to
> copy_to_iter - other than that, Al's function works.

The extra while is easy to write and can be difficult to spot.
I've found them looking as the object code before now!

Oh - the error return for copy_to_iter() is wrong.
It should (probably) return 'total' if it is nonzero.

David

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