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=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 D749AC3815B for ; Mon, 20 Apr 2020 11:26:36 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E7AA2054F; Mon, 20 Apr 2020 11:26:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="FIZT+bCc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="eDiWGclR"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=szeredi.hu header.i=@szeredi.hu header.b="IDveWlOS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E7AA2054F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=szeredi.hu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jQUZM-0003ts-94; Mon, 20 Apr 2020 11:26:32 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jQUZK-0003te-2s for linux-f2fs-devel@lists.sourceforge.net; Mon, 20 Apr 2020 11:26:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=okPBkG9vtS/wVdJh/KDIc+hdg6krV+bND5agW6vUaRM=; b=FIZT+bCcGbBHSJZRU0CBbUKMDd GtURmz1kww3AWVJm/8M7KV/hRuuHMq/wlgqcXOV5wH0rU5QHj7YAevmIQDXu+FSl/7lpD7n9pOgM1 xV4lnFt3u8iJJchg3do1WvJnPLaai0RS9wSrL4M5KHkOzw7+12HBGa9InwShFNyN4A30=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=okPBkG9vtS/wVdJh/KDIc+hdg6krV+bND5agW6vUaRM=; b=eDiWGclRnmT0wyA8odcyAQHwNh jCqEpXfJGWo/phADNdlM6Q7eGksgpyf+SzkAru+qBV+GDNfCrDhKlgBqidHMiOHbThr2fagpSxV21 yPEqxLZtYo3+y8Y0YhDE88oDH3vYwACohsoCNCRPTklYzEpLjSRJq7gUGl8ElLdFQTXE=; Received: from mail-wr1-f68.google.com ([209.85.221.68]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jQUZA-0080dj-BS for linux-f2fs-devel@lists.sourceforge.net; Mon, 20 Apr 2020 11:26:30 +0000 Received: by mail-wr1-f68.google.com with SMTP id f13so11638472wrm.13 for ; Mon, 20 Apr 2020 04:26:20 -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=okPBkG9vtS/wVdJh/KDIc+hdg6krV+bND5agW6vUaRM=; b=IDveWlOS7Tzhrdb36+hZpTST6wjOAPrAj2jj5uib3vbWbabqwzW9IWuAtw8h4eTBNA 9a9lkdgEJOm6Eb3fwCtOVTxrVmphaH2PGWy9bhlS9QBo4VsFK/CUgj6vV9uyCovU0arA 5Kj1tMT4D5sNr37XYcPWFQo9UnIzxN1guBg1w= 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=okPBkG9vtS/wVdJh/KDIc+hdg6krV+bND5agW6vUaRM=; b=tJ8qSWSTDjEzn+/hh5Im+IdYC3x/VJ+OQjjwGAu2cqneWgaRoUfoMbscRIBcWH1gaE 3TIrJJLtTMc4sSQ2pkrmXxcMwX7Qq0Qv16GcyPkTjC2bg1ZsV+JOyU3whLeJG+tI0jeI KNWuK0jd8QXQhr3OU5M3O5AvAjv9A7Bh8ktjkbYrOAvAeL2+XyXLuDo7wqeqVyfq3jGJ M3+d3QO4rqiAmPxacPIN0a+z61RvGLeNZHGzdW94QnAqMujOW4WZ5w0yFuT0z1Ra7Fg6 UFF1Lhg1cwnEGSZODcvr6H/SK7JtH0Pw3aKPHbVT7gkDeR16uaCzrYDg+n3nnOAOfCzr 1Y6g== X-Gm-Message-State: AGi0PuYiU9QaBxiBqlsNIo/Sp1VbDb7TBWFaVBgyZ4EeCKA5yebyjBse 0HSNt5J7YpMMWnz1e5wYrj0lK6J0s/AnmPwkb7qPdTjm X-Google-Smtp-Source: APiQypIVhtjPPYqBEymAM1SkD4SYcU1V6bmTKvyt+63wSYT0tOjvuXxym8edoJZS6GcpMs4Nq+7PF2DextVY/K9Ax1g= X-Received: by 2002:a17:906:841a:: with SMTP id n26mr16038100ejx.43.1587381268754; Mon, 20 Apr 2020 04:14:28 -0700 (PDT) MIME-Version: 1.0 References: <20200414150233.24495-1-willy@infradead.org> <20200414150233.24495-25-willy@infradead.org> In-Reply-To: <20200414150233.24495-25-willy@infradead.org> From: Miklos Szeredi Date: Mon, 20 Apr 2020 13:14:17 +0200 Message-ID: To: Matthew Wilcox X-Headers-End: 1jQUZA-0080dj-BS Subject: Re: [f2fs-dev] [PATCH v11 24/25] fuse: Convert from readpages to readahead X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-xfs , William Kucharski , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com, Dave Chinner , linux-fsdevel@vger.kernel.org, Andrew Morton , linux-ext4@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Tue, Apr 14, 2020 at 5:08 PM Matthew Wilcox wrote: > > From: "Matthew Wilcox (Oracle)" > > Implement the new readahead operation in fuse by using __readahead_batch() > to fill the array of pages in fuse_args_pages directly. This lets us > inline fuse_readpages_fill() into fuse_readahead(). > > Signed-off-by: Matthew Wilcox (Oracle) > Reviewed-by: Dave Chinner > Reviewed-by: William Kucharski > --- > fs/fuse/file.c | 99 ++++++++++++++------------------------------------ > 1 file changed, 27 insertions(+), 72 deletions(-) > > diff --git a/fs/fuse/file.c b/fs/fuse/file.c > index 9d67b830fb7a..db82fb29dd39 100644 > --- a/fs/fuse/file.c > +++ b/fs/fuse/file.c > @@ -915,84 +915,39 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) > fuse_readpages_end(fc, &ap->args, err); > } > > -struct fuse_fill_data { > - struct fuse_io_args *ia; > - struct file *file; > - struct inode *inode; > - unsigned int nr_pages; > - unsigned int max_pages; > -}; > - > -static int fuse_readpages_fill(void *_data, struct page *page) > +static void fuse_readahead(struct readahead_control *rac) > { > - struct fuse_fill_data *data = _data; > - struct fuse_io_args *ia = data->ia; > - struct fuse_args_pages *ap = &ia->ap; > - struct inode *inode = data->inode; > + struct inode *inode = rac->mapping->host; > struct fuse_conn *fc = get_fuse_conn(inode); > + unsigned int i, max_pages, nr_pages = 0; > > - fuse_wait_on_page_writeback(inode, page->index); > - > - if (ap->num_pages && > - (ap->num_pages == fc->max_pages || > - (ap->num_pages + 1) * PAGE_SIZE > fc->max_read || > - ap->pages[ap->num_pages - 1]->index + 1 != page->index)) { > - data->max_pages = min_t(unsigned int, data->nr_pages, > - fc->max_pages); > - fuse_send_readpages(ia, data->file); > - data->ia = ia = fuse_io_alloc(NULL, data->max_pages); > - if (!ia) { > - unlock_page(page); > - return -ENOMEM; > - } > - ap = &ia->ap; > - } > - > - if (WARN_ON(ap->num_pages >= data->max_pages)) { > - unlock_page(page); > - fuse_io_free(ia); > - return -EIO; > - } > - > - get_page(page); > - ap->pages[ap->num_pages] = page; > - ap->descs[ap->num_pages].length = PAGE_SIZE; > - ap->num_pages++; > - data->nr_pages--; > - return 0; > -} > - > -static int fuse_readpages(struct file *file, struct address_space *mapping, > - struct list_head *pages, unsigned nr_pages) > -{ > - struct inode *inode = mapping->host; > - struct fuse_conn *fc = get_fuse_conn(inode); > - struct fuse_fill_data data; > - int err; > - > - err = -EIO; > if (is_bad_inode(inode)) > - goto out; > + return; > > - data.file = file; > - data.inode = inode; > - data.nr_pages = nr_pages; > - data.max_pages = min_t(unsigned int, nr_pages, fc->max_pages); > -; > - data.ia = fuse_io_alloc(NULL, data.max_pages); > - err = -ENOMEM; > - if (!data.ia) > - goto out; > + max_pages = min(fc->max_pages, fc->max_read / PAGE_SIZE); > > - err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data); > - if (!err) { > - if (data.ia->ap.num_pages) > - fuse_send_readpages(data.ia, file); > - else > - fuse_io_free(data.ia); > + for (;;) { > + struct fuse_io_args *ia; > + struct fuse_args_pages *ap; > + > + nr_pages = readahead_count(rac) - nr_pages; Hmm. I see what's going on here, but it's confusing. Why is __readahead_batch() decrementing the readahead count at the start, rather than at the end? At the very least it needs a comment about why nr_pages is calculated this way. > + 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; > + nr_pages = __readahead_batch(rac, ap->pages, nr_pages); > + for (i = 0; i < nr_pages; i++) { > + fuse_wait_on_page_writeback(inode, > + readahead_index(rac) + i); What's wrong with ap->pages[i]->index? Are we trying to wean off using ->index? Thanks, Miklos _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel