From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29D61C54FCF for ; Wed, 25 Mar 2020 15:54:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB5702073E for ; Wed, 25 Mar 2020 15:54:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=szeredi.hu header.i=@szeredi.hu header.b="PotvV1Ev" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB5702073E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=szeredi.hu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 801116B0036; Wed, 25 Mar 2020 11:54:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B1966B0037; Wed, 25 Mar 2020 11:54:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A0C36B006C; Wed, 25 Mar 2020 11:54:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id 542746B0036 for ; Wed, 25 Mar 2020 11:54:57 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3121C1820F27A for ; Wed, 25 Mar 2020 15:54:57 +0000 (UTC) X-FDA: 76634333034.02.bed19_65569a2232d0c X-HE-Tag: bed19_65569a2232d0c X-Filterd-Recvd-Size: 5909 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 15:54:56 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id m15so2742602iob.5 for ; Wed, 25 Mar 2020 08:54:56 -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=finEf2J75dzAmQUgc5paIyb1SJ+SF73Ef2SBa2/ZRtmeWdGkgePc1tt1x/mtwiz5f/ 0O2VJxpTBxblydsO9RjwK8WRRddKbcMa11rwter+G0dQphE+qq4tzOMpdPUdY5Qdxsan CChAOl9bgHTHZAFs+zsSZo03/nD/bCH68axmPNhjFyjBrdqlnhG9nGUl+ecEnxN0hXh2 PwCbp2vc7wDh7gf5IetBnsSG5Cp5FsYVoqcJ+0SRfi8TpXzqZ/deC0M0V7zdsbg7Nkbe VSj6nK4EIFNLZYWr8M2l5XVh6wqFVkkwrneRc+YzayeJEQ+LY6K1x77I3QNku84Xnd8G fuCQ== X-Gm-Message-State: ANhLgQ0C5/auZTGygGKZnbqlTHYYrTtKftv6MAhShWB57VZbxdTebGjs UatyN9xKrSWOB1FA32DTK4d4FnpNABsQaLSqX/qrXtkY X-Google-Smtp-Source: ADFU+vtWPrSX9gO9pLLxpavehCkl/CaKr8w3OI8WID1sZHiGcDBmq2nlMdLwxJGUo5kQXivDvVBrGhSFup9s33zQy+o= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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