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 ED7D6C1975A for ; Wed, 25 Mar 2020 15:55:07 +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 C13D820777; Wed, 25 Mar 2020 15:55:07 +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="bm10T2Kp"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="RGgKzXD/"; 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 C13D820777 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-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jH8N0-0004Tn-Iu; Wed, 25 Mar 2020 15:55:06 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jH8My-0004TD-JW for linux-f2fs-devel@lists.sourceforge.net; Wed, 25 Mar 2020 15:55:04 +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=WUvTsX9+jdPoLTOSHShSbaoohqGvLnmJWJx3goFYuLM=; b=bm10T2Kp+Xv1VPdIBDXgGKyna7 HzX7w9gphojexBHZ+nETsqkTlqZpZaCQHFSKjli1e48eK7+xcBehDP5vvd+/57QdOgq5yzTQphohC Y7kNQMdtoscDzeB72mAvMqSztklyaiOWYxoqsMPMOYgpiDBeHKFC81gsq+BDPOndzlZM=; 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=WUvTsX9+jdPoLTOSHShSbaoohqGvLnmJWJx3goFYuLM=; b=RGgKzXD/vP6kjvKwlQzgajBwSd LrFbJuKe5fAyBPgPoi1KYCOFFw7KzPx3tkV3OC9ovex8t/1f7O4vjjnNneoo16XntUhx/lvd/+u0s DE4HpD++pXOkEcuPJ383fSVilsqi1HYUNoUBxuC4ffF+2WPNmRGQiywHuxNHEDZTTyxo=; Received: from mail-io1-f66.google.com ([209.85.166.66]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jH8Mu-0036ed-NN for linux-f2fs-devel@lists.sourceforge.net; Wed, 25 Mar 2020 15:55:04 +0000 Received: by mail-io1-f66.google.com with SMTP id c19so2730865ioo.6 for ; Wed, 25 Mar 2020 08:55:00 -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=ecdxTUPnRwdgz4VK0CmPznvKgw+R8DFZyRVjWYSxFSBvm76g3NVs9leG5qQP013RHD txDdPJesshASr/C3wf7eGXGpNwxdvfaiLuTq2pSmbGj5pETzsZ4rBDN0657g6aIETyHb WSjrvvJWYv6WyRWZPBxIS5HAWu3AKykPOaPNrKihjRwnXJ/E8eQZ7ZWfhxsg/bUH7SfT a6ncDEbeNDuf2IpN+YdoqqEF1uZZoA6GXT3J944M8s6E0JrCyOccmE7hvgWAipC0mcZb TaGwWnRUDffrDkdbDu29LkiykxXiU4LqDORMYGo4Tusv6o41wW4Yh0Fpi/cum4FuEmh0 DwXg== X-Gm-Message-State: ANhLgQ1jiA1GKbm1nOJUW0t9PBBIzu/1ZfS+BgCiLZnaCcbmkHdJ3utG mtE+Y+fxsCNY91w4QC4i3UK2WqvjGzNSxG8sZ+XEhA== 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: To: Matthew Wilcox X-Headers-End: 1jH8Mu-0036ed-NN Subject: Re: [f2fs-dev] [PATCH v10 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 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 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel