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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A396CC25B08 for ; Wed, 17 Aug 2022 20:35:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D82CA8D0003; Wed, 17 Aug 2022 16:35:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D09FB8D0002; Wed, 17 Aug 2022 16:35:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD33A8D0003; Wed, 17 Aug 2022 16:35:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AB13A8D0002 for ; Wed, 17 Aug 2022 16:35:14 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 764931C6FF1 for ; Wed, 17 Aug 2022 20:35:14 +0000 (UTC) X-FDA: 79810239348.17.B19BC8B Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by imf25.hostedemail.com (Postfix) with ESMTP id 2567AA008A for ; Wed, 17 Aug 2022 20:35:13 +0000 (UTC) Received: by mail-ot1-f41.google.com with SMTP id t11-20020a05683014cb00b0063734a2a786so10103185otq.11 for ; Wed, 17 Aug 2022 13:35:13 -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=ftCmR0Jv4ZywTK1r6mDOwLo6PGskRGztK4fYZJ4ZZkJh5qK/U5FOJ+KgdzDnTzZes1 JgbfEaQNeJrnYEOocoiO19uJaWl3Nv0AQp20jEx8704Y97OLsx/G5cNwwUcImPpnOAKk JDI7BbV7RHqPR2mgfelq201WMqt08RoiUoUlbiqZ4H3gXHfmjGC14cVfWf7jIvOtcgzC idHBve7YYo9VHLihnF6sLeJjEYCStmsKqWHTXeiqWEnwIV95moy9n7JsR4Ul9lr/QnNN VN4UZ6YoejafKYpxZkcTCANG5QJ1/pcQl+ggA2ZXMGdsh+/iFO8zCP4Kb310O+y5kBVC 12eQ== X-Gm-Message-State: ACgBeo0UGj4ozu2OX3cpJwjqMQIKaDHF1BGY9a+32SG8nRLaZiQ+M95Y Gi2zrTliWEcUChQOcShr0wZtSUFStyuwxpQpTzc= X-Google-Smtp-Source: AA6agR6fWtVoNrOD7JgMSokpy8oT8f5OQpwjiqzz0CiLyVnI5Kvr+Ua/5vUIOYrZCE8GFyy5YCy81xhLnbftN4xBEzY= 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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660768514; a=rsa-sha256; cv=none; b=ocq8zOlcU/tQ8EpBIS+stmpn7GC03zcIZoouTqeNG9g6C0DJTQWqojstHZRMVrHG9FZa4i xX8ap0JIEDLhpbK49Qy1Dsut1ZV638baMKkm3bqlsq+fyjZSXX5LnveCDlhmzMDrST6rnm yu1eLDH+GOU/e5k1rjxqSaCRf4Uqv0w= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Uf8/JMbJ"; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.41 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660768514; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gxYbz4vgkJrv2ZDG6l+fEiYODdiBDS379CnGFFAEQCA=; b=bv4Z7abkfujo7UMLRYVodlVOF5Gj6vENfzKe599pMUYOqBIa1MJNVN4Hbepd7U3jmJBRNG UaqlohhfkZzwtRDJVgwa+IWiNUqdJ/oOyaaZNadpCycy422cJswq0SUPDaQut+Js46Ah/W /UuloF4aP+VLI8g+mtEWQgOaDPr54Hc= X-Stat-Signature: npujngmh8qtbif7nr35sf5sj1uhxkw6w X-Rspamd-Queue-Id: 2567AA008A Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Uf8/JMbJ"; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.41 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1660768513-737880 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 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 > >