From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH v7 0/5] vfs: Non-blockling buffered fs read (page cache only) Date: Fri, 27 Mar 2015 09:39:42 -0700 Message-ID: <20150327093942.8ad38cd7.akpm@linux-foundation.org> 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> <20150327093046.53c2769a.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150327093046.53c2769a.akpm@linux-foundation.org> Sender: linux-fsdevel-owner@vger.kernel.org To: Jeremy Allison , 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 List-Id: linux-arch.vger.kernel.org On Fri, 27 Mar 2015 09:30:46 -0700 Andrew Morton wrote: > I expect that this situation (first part in cache, latter part not in > cache) is rare - for reasonably small requests the common cases will be > "all cached" and "nothing cached". So perhaps the best approach here > is for samba to add special handling for the short read, to work out > the reason for its occurrence. > > Alternatively we could add another flag to pread2() to select this > "throw away my data and return -EAGAIN" behaviour. Presumably > implemented with an i_size check, but it's gonna be racy. Here's a better way: nr_read = pread2(buf, len); if (nr_read < len) nr_read += pread(buf + nr_read, len - nr_read); if (nr_read < len) we_hit_eof(); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:46325 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752776AbbC0Qia (ORCPT ); Fri, 27 Mar 2015 12:38:30 -0400 Date: Fri, 27 Mar 2015 09:39:42 -0700 From: Andrew Morton Subject: Re: [PATCH v7 0/5] vfs: Non-blockling buffered fs read (page cache only) Message-ID: <20150327093942.8ad38cd7.akpm@linux-foundation.org> In-Reply-To: <20150327093046.53c2769a.akpm@linux-foundation.org> 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> <20150327093046.53c2769a.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Jeremy Allison , 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 Message-ID: <20150327163942.KaloJu6OBsHgwyhL_PDFhLC5TCwXPYBFScdEa9PEkqk@z> On Fri, 27 Mar 2015 09:30:46 -0700 Andrew Morton wrote: > I expect that this situation (first part in cache, latter part not in > cache) is rare - for reasonably small requests the common cases will be > "all cached" and "nothing cached". So perhaps the best approach here > is for samba to add special handling for the short read, to work out > the reason for its occurrence. > > Alternatively we could add another flag to pread2() to select this > "throw away my data and return -EAGAIN" behaviour. Presumably > implemented with an i_size check, but it's gonna be racy. Here's a better way: nr_read = pread2(buf, len); if (nr_read < len) nr_read += pread(buf + nr_read, len - nr_read); if (nr_read < len) we_hit_eof();