Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp751207ybb; Wed, 25 Mar 2020 08:55:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv/H4Z3jsw7DXGSAiFC6RxwmXf2T7euMiPHhKgPgAhR1UylCLnqLUQpzSGZbEvtjOMKeLNC X-Received: by 2002:aca:7517:: with SMTP id q23mr2981051oic.23.1585151747527; Wed, 25 Mar 2020 08:55:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585151747; cv=none; d=google.com; s=arc-20160816; b=WTTaSYcRBPy4KHJajWjpbfy5JTgjQvT75mj0rXgdDnwrhXGAw5JNzALOgERzQ83eip ti2EeqjwpMKQC63FMvDFJA1QqLXBuAqVhjgVHw6LcMfeLRb8ipV00X4sQB7C+s0buCfx JNju/76tEl88hB4GIJvSdepHfyK56dTnC/Hc4lwMQTAkAaeyykf4C05uex0+205FDRlB 7tHAyLiHjIBtVlzdmXXzCCRqMAB6TonwA5A6sKCVXVbZORqmPRUVcTGMUjJdVY1qijC0 SMhWp3cpi/usMWDAlaA8G/gPxpa2Z/ZFEmuhnt1GKMcwAfKdtTTftgz9UfeLAf7gvmqR Qebg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=WUvTsX9+jdPoLTOSHShSbaoohqGvLnmJWJx3goFYuLM=; b=nDuiGQDU0I+RyLHrOV5FGZryWIVPhgYTv0tNMVUs/92IoJKe0sTJdMuwEvU/0Y7OAx jyamMFqNKZMoNLrkDfKZcMgCQ2g4YB9211ZJeTyBD9wK4/Y8YOHawskq1w+o0WBy4tcy rfXDfpzf+2RyQkjAhSAZp4MmedC+3xDCeMpnRZsqmsDH9jL4VJ5q1XU53Qb+w8O1s3P/ furT469n5w0KPN6ua+GL5ayx4vcXQqjxpgddzzMox3Dpy3mzKUV9Wjkk1DNICLCuPwG1 ZDPCpDHWUUMIZwYy9QeWLeXu57t6eIRwZNrghdAgAfAQlrm8W12xBXJlYBelZv9c79hJ F6/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=PotvV1Ev; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si4806839otp.314.2020.03.25.08.55.33; Wed, 25 Mar 2020 08:55:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=PotvV1Ev; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727934AbgCYPy4 (ORCPT + 99 others); Wed, 25 Mar 2020 11:54:56 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:45721 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727911AbgCYPy4 (ORCPT ); Wed, 25 Mar 2020 11:54:56 -0400 Received: by mail-io1-f65.google.com with SMTP id a24so2125414iol.12 for ; Wed, 25 Mar 2020 08:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WUvTsX9+jdPoLTOSHShSbaoohqGvLnmJWJx3goFYuLM=; b=PotvV1Ev6OzVSaF6m2X5tC6JwxVWHxAGf6FLW8AjKTGJyK/QJ8dyn6xJiqfkSFaAqz OCdtBX9daql7+1gX8+5dT3S5uMqemNZ36FP4ZPoQpwuOHn42a4uh+PVPR7d5d59NuA3a t2/cRclIFAps/zNhsd7jyIV2vHIEY2rkQ4dM0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WUvTsX9+jdPoLTOSHShSbaoohqGvLnmJWJx3goFYuLM=; b=np3EyBzvbpfsTe1GcQlieVYzni5JSYZS1SX3+2VYloiUgbwhNtc6a5ulK6PthNnAbk ffMy01Z9Om+SBoeU5ZnBYGKCIg8/5bJvLdX75FHN1NGKxxiBd/8P4c1Iq1ftAfLpbqfN ZlGXV7YqoKLTERcgmCSqvqvljvXEA/bQL2qmMSDlHVmNOcMEwxdn0RTo7hwv94QkmVVb nrrS30N9UJwC6ZLBs3mlLYmdjDnCl/tC92RyU3gESqFxl+/7WbBmGdnoM0waambXAV3w qROLO5kGD3CU1+BVTaFReDwt9aEyxg2eXhuZmPmou1Pln8L3cxJHGUT426NA9tGRNQ7p 9pEA== X-Gm-Message-State: ANhLgQ0+Y32IydEl16FwRl2qOSzHpZforKJaXiMIXPZ9AqFYN0zq1sNM eGbh22D1mckfXFoghRdIifQe+0z7+AaYk3bfcaK/3g== X-Received: by 2002:a5d:9142:: with SMTP id y2mr3418704ioq.185.1585151694868; Wed, 25 Mar 2020 08:54:54 -0700 (PDT) MIME-Version: 1.0 References: <20200323202259.13363-1-willy@infradead.org> <20200323202259.13363-25-willy@infradead.org> <20200325120254.GA22483@bombadil.infradead.org> <20200325153228.GB22483@bombadil.infradead.org> In-Reply-To: <20200325153228.GB22483@bombadil.infradead.org> From: Miklos Szeredi Date: Wed, 25 Mar 2020 16:54:43 +0100 Message-ID: Subject: Re: [PATCH v10 24/25] fuse: Convert from readpages to readahead To: Matthew Wilcox Cc: Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, ocfs2-devel@oss.oracle.com, linux-xfs , Dave Chinner , William Kucharski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 25, 2020 at 4:32 PM Matthew Wilcox wrote: > > On Wed, Mar 25, 2020 at 03:43:02PM +0100, Miklos Szeredi wrote: > > > > > > - while ((page = readahead_page(rac))) { > > > - if (fuse_readpages_fill(&data, page) != 0) > > > + nr_pages = min(readahead_count(rac), fc->max_pages); > > > > Missing fc->max_read clamp. > > Yeah, I realised that. I ended up doing ... > > + unsigned int i, max_pages, nr_pages = 0; > ... > + max_pages = min(fc->max_pages, fc->max_read / PAGE_SIZE); > > > > + ia = fuse_io_alloc(NULL, nr_pages); > > > + if (!ia) > > > return; > > > + ap = &ia->ap; > > > + __readahead_batch(rac, ap->pages, nr_pages); > > > > nr_pages = __readahead_batch(...)? > > That's the other bug ... this was designed for btrfs which has a fixed-size > buffer. But you want to dynamically allocate fuse_io_args(), so we need to > figure out the number of pages beforehand, which is a little awkward. I've > settled on this for the moment: > > for (;;) { > struct fuse_io_args *ia; > struct fuse_args_pages *ap; > > nr_pages = readahead_count(rac) - nr_pages; > if (nr_pages > max_pages) > nr_pages = max_pages; > if (nr_pages == 0) > break; > ia = fuse_io_alloc(NULL, nr_pages); > if (!ia) > return; > ap = &ia->ap; > __readahead_batch(rac, ap->pages, nr_pages); > for (i = 0; i < nr_pages; i++) { > fuse_wait_on_page_writeback(inode, > readahead_index(rac) + i); > ap->descs[i].length = PAGE_SIZE; > } > ap->num_pages = nr_pages; > fuse_send_readpages(ia, rac->file); > } > > but I'm not entirely happy with that either. Pondering better options. I think that's fine. Note how the original code possibly over-allocates the the page array, because it doesn't know the batch size beforehand. So this is already better. > > > This will give consecutive pages, right? > > readpages() was already being called with consecutive pages. Several > filesystems had code to cope with the pages being non-consecutive, but > that wasn't how the core code worked; if there was a discontiguity it > would send off the pages that were consecutive and start a new batch. > > __readahead_batch() can't return fewer than nr_pages, so you don't need > to check for that. That's far from obvious. I'd put a WARN_ON at least to make document the fact. Thanks, Miklos