lkml.org 
[lkml]   [2014]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 4/7] O_NONBLOCK flag for readv2/preadv2
Date
Milosz Tanski <milosz@adfin.com> writes:

> Filesystems that generic_file_read_iter will not be allowed to perform
> non-blocking reads. This only will read data if it's in the page cache and if
> there is no page error (causing a re-read).
>
> Signed-off-by: Milosz Tanski <milosz@adfin.com>

> @@ -1662,6 +1676,10 @@ no_cached_page:
> goto out;
> }
> goto readpage;
> +
> +would_block:
> + error = -EAGAIN;
> + goto out;
> }

Why did you put the wouldblock label inside the loop? That should be
pushed down to just above out, and then you can get rid of the goto.

Other than that, it looks like you put the check in all the right places
in that function.

> out:
> @@ -1697,6 +1715,9 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter, int flags)
> size_t count = iov_iter_count(iter);
> loff_t size;
>
> + if (flags & O_NONBLOCK)
> + return -EAGAIN;
> +

If a program is attempting non-blocking reads on a file opened with
O_DIRECT, I think returning -EAGAIN is very misleading. Better to
return -EINVAL in this case, and maybe check that earlier in the stack?

Cheers,
Jeff


\
 
 \ /
  Last update: 2014-09-16 22:01    [W:0.463 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site