From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeremy Allison Subject: Re: [PATCH v7 0/5] vfs: Non-blockling buffered fs read (page cache only) Date: Mon, 30 Mar 2015 10:19:12 -0700 Message-ID: <20150330171912.GB5835@samba2> 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> <20150327155854.GA5548@samba2> <20150330073604.GB22229@infradead.org> Reply-To: Jeremy Allison Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20150330073604.GB22229-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Christoph Hellwig Cc: Jeremy Allison , Andrew Morton , Milosz Tanski , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-aio-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Mel Gorman , Volker Lendecke , Tejun Heo , Jeff Moyer , Theodore Ts'o , Al Viro , linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Michael Kerrisk , linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Dave Chinner List-Id: linux-arch.vger.kernel.org On Mon, Mar 30, 2015 at 12:36:04AM -0700, Christoph Hellwig wrote: > On Fri, Mar 27, 2015 at 08:58:54AM -0700, Jeremy Allison wrote: > > 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. > > Is a race vs truncate really that time critical that you can't > wait for the thread pool to do the second read to notice it? Probably not, as this is the fallback path anyway. > > 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). > > That is easily implementable, but I can see that for example web apps > would be happy to get as much as possible. So if Samba can be ok > with short reads and only detecting the truncated case in the slow > path that would make life simpler. Otherwise we might indeed need two > flags. Simpler is better. I can live with the partial read+fallback. Jeremy. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fn.samba.org ([216.83.154.106]:56623 "EHLO mail.samba.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752853AbbC3RTP (ORCPT ); Mon, 30 Mar 2015 13:19:15 -0400 Date: Mon, 30 Mar 2015 10:19:12 -0700 From: Jeremy Allison Subject: Re: [PATCH v7 0/5] vfs: Non-blockling buffered fs read (page cache only) Message-ID: <20150330171912.GB5835@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> <20150327155854.GA5548@samba2> <20150330073604.GB22229@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150330073604.GB22229@infradead.org> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Christoph Hellwig Cc: Jeremy Allison , Andrew Morton , 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 Message-ID: <20150330171912.P2OYN6tOJ9Rwob2xTWS9gAuqMVeRoY6XTDXeP5_vkdk@z> On Mon, Mar 30, 2015 at 12:36:04AM -0700, Christoph Hellwig wrote: > On Fri, Mar 27, 2015 at 08:58:54AM -0700, Jeremy Allison wrote: > > 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. > > Is a race vs truncate really that time critical that you can't > wait for the thread pool to do the second read to notice it? Probably not, as this is the fallback path anyway. > > 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). > > That is easily implementable, but I can see that for example web apps > would be happy to get as much as possible. So if Samba can be ok > with short reads and only detecting the truncated case in the slow > path that would make life simpler. Otherwise we might indeed need two > flags. Simpler is better. I can live with the partial read+fallback. Jeremy.