diff options
author | Milosz Tanski <milosz@adfin.com> | 2017-08-29 16:13:19 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-09-04 19:04:22 -0400 |
commit | 3239d834847627b6634a4139cf1dc58f6f137a46 (patch) | |
tree | 7fb8e4424d69ecd3cc0d4d151464f513942d7bfb /mm/filemap.c | |
parent | 47c27bc46946dea543196a92061da14c6da9889e (diff) | |
download | lwn-3239d834847627b6634a4139cf1dc58f6f137a46.tar.gz lwn-3239d834847627b6634a4139cf1dc58f6f137a46.zip |
fs: support IOCB_NOWAIT in generic_file_buffered_read
Allow generic_file_buffered_read to bail out early instead of waiting for
the page lock or reading a page if IOCB_NOWAIT is specified.
Signed-off-by: Milosz Tanski <milosz@adfin.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Acked-by: Sage Weil <sage@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index b7c039669020..92d4e0a6c012 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1939,6 +1939,8 @@ find_page: page = find_get_page(mapping, index); if (!page) { + if (iocb->ki_flags & IOCB_NOWAIT) + goto would_block; page_cache_sync_readahead(mapping, ra, filp, index, last_index - index); @@ -1952,6 +1954,11 @@ find_page: index, last_index - index); } if (!PageUptodate(page)) { + if (iocb->ki_flags & IOCB_NOWAIT) { + put_page(page); + goto would_block; + } + /* * See comment in do_read_cache_page on why * wait_on_page_locked is used to avoid unnecessarily @@ -2133,6 +2140,8 @@ no_cached_page: goto readpage; } +would_block: + error = -EAGAIN; out: ra->prev_pos = prev_index; ra->prev_pos <<= PAGE_SHIFT; |