From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932562AbbC0QHK (ORCPT ); Fri, 27 Mar 2015 12:07:10 -0400 Received: from fn.samba.org ([216.83.154.106]:39890 "EHLO mail.samba.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932102AbbC0QHE (ORCPT ); Fri, 27 Mar 2015 12:07:04 -0400 X-Greylist: delayed 487 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 Mar 2015 12:07:04 EDT Date: Fri, 27 Mar 2015 08:58:54 -0700 From: Jeremy Allison To: Andrew Morton Cc: Christoph Hellwig , Milosz Tanski , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, Mel Gorman , Volker Lendecke , Tejun Heo , Jeff Moyer , "Theodore Ts'o" , Al Viro , linux-api@vger.kernel.org, Michael Kerrisk , linux-arch@vger.kernel.org, Dave Chinner Subject: Re: [PATCH v7 0/5] vfs: Non-blockling buffered fs read (page cache only) Message-ID: <20150327155854.GA5548@samba2> Reply-To: Jeremy Allison References: <20150326202824.65d03787.akpm@linux-foundation.org> <20150327081822.GA28669@infradead.org> <20150327013516.8c6788be.akpm@linux-foundation.org> <20150327084833.GA7689@infradead.org> <20150327020159.eadd0ce1.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150327020159.eadd0ce1.akpm@linux-foundation.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 27, 2015 at 02:01:59AM -0700, Andrew Morton wrote: > On Fri, 27 Mar 2015 01:48:33 -0700 Christoph Hellwig wrote: > > > On Fri, Mar 27, 2015 at 01:35:16AM -0700, Andrew Morton wrote: > > > fincore() doesn't have to be ugly. Please address the design issues I > > > raised. How is pread2() useful to the class of applications which > > > cannot proceed until all data is available? > > > > It actually makes them work correctly? preadv2( ..., DONTWAIT) will > > return -EGAIN, which causes them to bounce to the threadpool where > > they call preadv(...). > > (I assume you mean RWF_NONBLOCK) > > That isn't how pread2() works. If the leading one or more pages are > uptodate, pread2() will return a partial read. Now what? Either the > application reads the same data a second time via the worker thread > (dumb, but it will usually be a rare case) The problem with the above is that we can't tell the difference between pread2() returning a short read because the pages are not in cache, or because someone truncated the file. So we need some way to differentiate this. My preference from userspace would be for pread2() to return EAGAIN if *all* the data requested is not available (where 'all' can be less than the size requested if the file has been truncated in the meantime). So: ret = pread2(fd, buf, size_wanted, RWF_NONBLOCK) if (ret == -1) { if (errno == EAGAIN) { goto threadpool... } .. real error.. } if (ret == size_wanted) { .. normal read, file not truncated... } if (ret < size_wanted) { .. file was truncated.. } The thing I want to avoid is the case where ret < size_wanted means only part of the file is in cache.