Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5274644rwb; Wed, 17 Aug 2022 14:36:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7p62DQ6ad3eGtLhWzzPomkNisVu0GYwheUhcZGQUpphNtQ7dphyOb2R6QdRC8VcfgngN3j X-Received: by 2002:a17:90b:3805:b0:1f4:ebfe:558b with SMTP id mq5-20020a17090b380500b001f4ebfe558bmr5711221pjb.48.1660772203836; Wed, 17 Aug 2022 14:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660772203; cv=none; d=google.com; s=arc-20160816; b=Za7JJ3YZwlj/VfrQ05AmIzmH3pK4IgshcyPkDVtv5TRB3NzK8uK62SiLAF6oJoYFVi 9gLzvoQdjpziPPfUlWvoxyW9oynCCd39s4WWvNCNyVh+uCiqajVJy6VNAe9qTkx1YCEO lbM+7Pa1YaLDPqj2wNZkUF22AYpgko/ZaMcijWspwMjUHFhPUXAeH22viVqsILThCLpW 2gVevGNV0GSpdc/n+94bGdAdbT71aJZysE+SGMK3jZFsVRoutg6ClxjEaGrw5BWB4oMq RAeIh9KNcNigNKw8ugXGX9deMTX5rg8d9/LMznWlt2L2jRbgAVNDeCdnwrXhnku2PAwu 9kQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gxYbz4vgkJrv2ZDG6l+fEiYODdiBDS379CnGFFAEQCA=; b=rxLp9yGgpR09PxqP0HFUeiEo4VxgybhcRNeaW2nyCt0k3Ejtp4EPofnHhROyZhEPP+ xpeUEXTNMkRZiEbSddpZZQ1lLpiKGlDAxDyquzAz8mFF01Zqv8lmT85J2rv7Sb2L7Bsz hBU6zn8PsMfqRQKtkw/oEFd0BlKh01vELOC7pbw5FRH3ypDIlsnXPU0DbMzGdCSVtI4p jiV5Tw6NTX8yPKCKJADrcCRjlfesCDPEKzGdzjwVf8BLaDG9QTrpTMqeoEEWsAvW3PCd 6DE86bHBrdMAJGC7eRV5VQQX63OY6I/tEenfZ26DTYHfV/wztCZeuHyKL00FbUiiK4tD t34w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Uf8/JMbJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oj18-20020a17090b4d9200b001f3a8793077si2826925pjb.43.2022.08.17.14.36.33; Wed, 17 Aug 2022 14:36:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Uf8/JMbJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242016AbiHQUfY (ORCPT + 99 others); Wed, 17 Aug 2022 16:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241986AbiHQUfQ (ORCPT ); Wed, 17 Aug 2022 16:35:16 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A5CEAA3E5; Wed, 17 Aug 2022 13:35:14 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id q39-20020a056830442700b0063889adc0ddso9216795otv.1; Wed, 17 Aug 2022 13:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=gxYbz4vgkJrv2ZDG6l+fEiYODdiBDS379CnGFFAEQCA=; b=Uf8/JMbJrj//7ezxkLb/aOXHNfyJLkuRC5MHSWStBXI5zX+Ljl+T4G26MZfdmT1tUi +oeuYc/4J7ElSoHOITcjQmHHNZ0zB4Iy7OwLx+YyLIQweEfcsND7lCCAZSmi8i5C8vw9 po0DE79mAnRSmOOjCV/ixl2HQZc3Da7CEuVmlR5GKJkGwdDuqqbBeIkO4KfOLKyJzPFp je0dwtAPPYsg2UrjWkl3DIcBtXtC5rcJWvqu+HZVhlySw6WuSgH+WiMZuKots3a/6eFH 5rFUFIxXVlm+aeJTzYiKktnFYJqoaji+uf+n35Annv4EB6aCJBWzj7nFMo9tHnzOHvLT V9wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=gxYbz4vgkJrv2ZDG6l+fEiYODdiBDS379CnGFFAEQCA=; b=F1QiAvZudC0ps9cgIPgAUvsfdvcyYz4A+d49ItmZQXSHLP8xH7fnReJ/+N164mQ7mq 4O89LTrD2BoMonNiA5VWkqfiDpEFeWYxTIK5ZuXoMn3d/NIgd+8OqctFKXSWaP8C/Uh1 9jiJUNQ4UV5lJR9I0uSzbVdOt1oXGKQoEzy+bztoAwltpVF1rA10G6reEfFGUqMaNGIH LcCGmQTSpW+qVQQm6/tsggXk8Y4CbhZPv9WlnFMMUmNQ9x4SljdCvuEcm+imbkn6FhYg zsHPaiOYHtZgEGf/MrwfCMMjke/VCsY4diY07+3rf0X4EkPeKTlJ86FazEdGuywGSXOf Pltg== X-Gm-Message-State: ACgBeo09aY4z2ViR/WRQb6X7VoWwi/IO295eTsvHRtvRanaUJ7WuUP5X AAuhZIsmoyKzGUEQaQmJMgIZDfzvNtI6X5IT0HxogIvVloo= X-Received: by 2002:a05:6830:449e:b0:638:c72b:68ff with SMTP id r30-20020a056830449e00b00638c72b68ffmr3925360otv.26.1660768513316; Wed, 17 Aug 2022 13:35:13 -0700 (PDT) MIME-Version: 1.0 References: <20220816175246.42401-1-vishal.moola@gmail.com> <20220816175246.42401-6-vishal.moola@gmail.com> In-Reply-To: From: Vishal Moola Date: Wed, 17 Aug 2022 13:35:01 -0700 Message-ID: Subject: Re: [PATCH v2 5/7] nilfs2: Convert nilfs_find_uncommited_extent() to use filemap_get_folios_contig() To: Ryusuke Konishi Cc: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,SUSPICIOUS_RECIPS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 16, 2022 at 9:33 PM Ryusuke Konishi wrote: > > On Wed, Aug 17, 2022 at 2:54 AM Vishal Moola (Oracle) wrote: > > > > Converted function to use folios throughout. This is in preparation for > > the removal of find_get_pages_contig(). Now also supports large folios. > > > > Also cleaned up an unnecessary if statement - pvec.pages[0]->index > index > > will always evaluate to false, and filemap_get_folios_contig() returns 0 if > > there is no folio found at index. > > > > Signed-off-by: Vishal Moola (Oracle) > > --- > > > > v2: > > - Fixed a warning regarding a now unused label "out" > > - Reported-by: kernel test robot > > --- > > fs/nilfs2/page.c | 39 +++++++++++++++++---------------------- > > 1 file changed, 17 insertions(+), 22 deletions(-) > > > > diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c > > index 3267e96c256c..14629e03d0da 100644 > > --- a/fs/nilfs2/page.c > > +++ b/fs/nilfs2/page.c > > @@ -480,13 +480,13 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, > > sector_t start_blk, > > sector_t *blkoff) > > { > > - unsigned int i; > > + unsigned int i, nr; > > pgoff_t index; > > unsigned int nblocks_in_page; > > unsigned long length = 0; > > sector_t b; > > - struct pagevec pvec; > > - struct page *page; > > + struct folio_batch fbatch; > > + struct folio *folio; > > > > if (inode->i_mapping->nrpages == 0) > > return 0; > > @@ -494,27 +494,24 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, > > index = start_blk >> (PAGE_SHIFT - inode->i_blkbits); > > nblocks_in_page = 1U << (PAGE_SHIFT - inode->i_blkbits); > > > > - pagevec_init(&pvec); > > + folio_batch_init(&fbatch); > > > > repeat: > > - pvec.nr = find_get_pages_contig(inode->i_mapping, index, PAGEVEC_SIZE, > > - pvec.pages); > > - if (pvec.nr == 0) > > + nr = filemap_get_folios_contig(inode->i_mapping, &index, ULONG_MAX, > > + &fbatch); > > + if (nr == 0) > > return length; > > > > - if (length > 0 && pvec.pages[0]->index > index) > > - goto out; > > - > > - b = pvec.pages[0]->index << (PAGE_SHIFT - inode->i_blkbits); > > + b = fbatch.folios[0]->index << (PAGE_SHIFT - inode->i_blkbits); > > i = 0; > > do { > > - page = pvec.pages[i]; > > + folio = fbatch.folios[i]; > > > > - lock_page(page); > > - if (page_has_buffers(page)) { > > + folio_lock(folio); > > + if (folio_buffers(folio)) { > > struct buffer_head *bh, *head; > > > > - bh = head = page_buffers(page); > > + bh = head = folio_buffers(folio); > > do { > > if (b < start_blk) > > continue; > > @@ -532,18 +529,16 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, > > > > > b += nblocks_in_page; > > Here, It looks like the block index "b" should be updated with the > number of blocks in the > folio because the loop is now per folio, not per page. Yup, thanks for catching that. > Instead of replacing it with a calculation that uses folio_size(folio) > or folio_shift(folio), > I think it would be better to move the calculation of "b" inside the > branch where the folio > has buffers as follows: > > if (folio_buffers(folio)) { > struct buffer_head *bh, *head; > sector_t b; > > b = folio->index << (PAGE_SHIFT - inode->i_blkbits); > bh = head = folio_buffers(folio); > ... > } else if (length > 0) { > goto out_locked; > } > > This way, we can remove calculations for the block index "b" outside > the above part > and the variable "nblocks_in_page" as well. Sounds good, I'll do that. > Thanks, > Ryusuke Konishi > > > } > > - unlock_page(page); > > + folio_unlock(folio); > > > > - } while (++i < pagevec_count(&pvec)); > > + } while (++i < nr); > > > > - index = page->index + 1; > > - pagevec_release(&pvec); > > + folio_batch_release(&fbatch); > > cond_resched(); > > goto repeat; > > > > out_locked: > > - unlock_page(page); > > -out: > > - pagevec_release(&pvec); > > + folio_unlock(folio); > > + folio_batch_release(&fbatch); > > return length; > > } > > -- > > 2.36.1 > >