Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp615557rwb; Thu, 12 Jan 2023 10:02:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXsbVKyGXT4zko+sk4xx59zwdbHqjD/1FFMKC8Q+DqzznLoutfCWS5HpqpcXRe5SoAqzNrTG X-Received: by 2002:a17:90b:891:b0:226:8bbf:1c63 with SMTP id bj17-20020a17090b089100b002268bbf1c63mr36586352pjb.12.1673546521000; Thu, 12 Jan 2023 10:02:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673546520; cv=none; d=google.com; s=arc-20160816; b=sqV+1/3ald/FYEpukAzg97vww897xdJuEOUN52FvDaI5+tMs3+MlHYKVU5Rz9qsIqC Nhj0/6l6TDktND6+M/aPQuN/Eolaj7ZTd4UPD8cCIc7B3vn/VrCKBDS3YrOO73PmD03y bAM46i3hbRQjhnU5R5kJfq/qJULeUU0bwFp8GHDuGt60m6l39v5CZW+Ip4BQKEZkcnlD 8MZmEh2aksK5TQ1UEXEAusBkxm3SPSrI7BTPMiXmV57ACVoBKohex4TpZTV65ku4/GpB fIS5wPRMNSa6rKoIYlJ/6ucyRzaYxU8JW+ySXxlEYJ04O3hzOX984204GbPtJcQG0nXm eH+g== 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=E+c881Dpe/85Aq62y2qtNDOsySQkmPy3VHLSOKalLuM=; b=nLbFwrIlP1zfm1gFEEiecFQ8bp7Fxuo+gbsDTdGWf0ZOp7oPjNsx8s0ZTyJYmYlnW4 wXIyOW6SNZXFa92HnCOyZ9qW40OqbBZoyJKcrDSAuWWNKcqEaSkRmjlwvriXDIgnOpba zxclz8UK7QkjaXvjooNM/TX8HwWStUbOya79ZamX+LjNgzsPJeW09AL6UHFAjkIRLfx4 dUcVzFgASywKn6BCZMMuFEcw42eNGVNggqJX9korX1+gBADSWrlX+MZkiyWMJrvTGKA1 LLYlvN14nPO9a76wLF0ALlN6TYH6mCfRydi0Vpu36CtLCuAUfpBfxqiTmjWfO8u/1qzd LDVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Pc/Xg/kv"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 nl10-20020a17090b384a00b00223b1092804si24661967pjb.163.2023.01.12.10.01.28; Thu, 12 Jan 2023 10:02:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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="Pc/Xg/kv"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S239861AbjALSAs (ORCPT + 99 others); Thu, 12 Jan 2023 13:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239847AbjALSAI (ORCPT ); Thu, 12 Jan 2023 13:00:08 -0500 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242B15E0BF; Thu, 12 Jan 2023 09:20:02 -0800 (PST) Received: by mail-yb1-xb2b.google.com with SMTP id e76so19458633ybh.11; Thu, 12 Jan 2023 09:20:02 -0800 (PST) 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:subject:date:message-id:reply-to; bh=E+c881Dpe/85Aq62y2qtNDOsySQkmPy3VHLSOKalLuM=; b=Pc/Xg/kvl8DhMy2mV5DSv0JY0A6VI9FAm0F9VYc/dWZQyf9ydWoM7408OMWs2Kt4+S eCo3wgwd+MlvDDhfoUGkDIHkrJCrglJGkVPgM1Oz/eqrjqRxIUt6ATz63+Zu6orRFNgG FQGLvnnrHoT7dPPaTZzgvM7ZMRU4T4kxqvK2dz+jrBacryTz+KXjnEm1lE9Im5xoXhH6 uaeXjEyPwqRZI6/5GVgzLBgcQ8qcs+by+yaLr7atp5Urs68114vwsX10TNqGRNH04pMs QclnYeakKcSogdPbUF9XgR9U7I3ZKCshjFY/gZue60/KZOW51I77izQ6dwI6z0pu5/hK x6BA== 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:subject:date:message-id :reply-to; bh=E+c881Dpe/85Aq62y2qtNDOsySQkmPy3VHLSOKalLuM=; b=VDaqOA08Dm5H79a2XQauxlLeiIwYmNVaZ11oQvcBhE6nWnUgIBx1IpBMRkT/lBa1dt eGSBZgy9hi7DcHoe+i5UE2WtPJVZdKmpqp9WHovW/5de0uNyG/1WMdH1Ro1zhX4jvDEO ZaxyZ7WsPWXFpeCm/kbh6y5hFBz1i8NvOi9NA+pqkNvNAIUu51rh1MfrGyN3cCiPp0Wc T8x2HCn/ZWXpC/Bk4jeh4+5ylYpns5JzGVYKwG/MXvC6NgkjWaT6IquLDfBX2I1VB7gO ZKX/MSAa95yt8Oth45WCJprkFyekCfekbfudJobSYt6PQplcvJNdZ957Od8xcsLQ3VX2 rpyw== X-Gm-Message-State: AFqh2kp/O7oF3w3q4s9aoAvr5fSGxJLk37f2aBMaOvFhm+N2H1NtDF/D z3eeBHT0G8PHPMhE59QuabMNPqJue1uSmMVHxt3Nl38KcYUYPQ== X-Received: by 2002:a25:8a:0:b0:7ca:7f22:5c15 with SMTP id 132-20020a25008a000000b007ca7f225c15mr196720yba.219.1673544001120; Thu, 12 Jan 2023 09:20:01 -0800 (PST) MIME-Version: 1.0 References: <20230104211448.4804-1-vishal.moola@gmail.com> <20230104211448.4804-10-vishal.moola@gmail.com> In-Reply-To: <20230104211448.4804-10-vishal.moola@gmail.com> From: Vishal Moola Date: Thu, 12 Jan 2023 09:19:50 -0800 Message-ID: Subject: Re: [PATCH v5 09/23] cifs: Convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag() To: linux-fsdevel@vger.kernel.org, pc@cjr.nz, tom@talpey.com Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 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 autolearn=ham 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-ext4@vger.kernel.org On Wed, Jan 4, 2023 at 1:15 PM Vishal Moola (Oracle) wrote: > > This is in preparation for the removal of find_get_pages_range_tag(). Now also > supports the use of large folios. > > Since tofind might be larger than the max number of folios in a > folio_batch (15), we loop through filling in wdata->pages pulling more > batches until we either reach tofind pages or run out of folios. > > This function may not return all pages in the last found folio before > tofind pages are reached. > > Signed-off-by: Vishal Moola (Oracle) > --- > fs/cifs/file.c | 32 +++++++++++++++++++++++++++++--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/fs/cifs/file.c b/fs/cifs/file.c > index 22dfc1f8b4f1..8cdd2f67af24 100644 > --- a/fs/cifs/file.c > +++ b/fs/cifs/file.c > @@ -2527,14 +2527,40 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping, > unsigned int *found_pages) > { > struct cifs_writedata *wdata; > - > + struct folio_batch fbatch; > + unsigned int i, idx, p, nr; > wdata = cifs_writedata_alloc((unsigned int)tofind, > cifs_writev_complete); > if (!wdata) > return NULL; > > - *found_pages = find_get_pages_range_tag(mapping, index, end, > - PAGECACHE_TAG_DIRTY, tofind, wdata->pages); > + folio_batch_init(&fbatch); > + *found_pages = 0; > + > +again: > + nr = filemap_get_folios_tag(mapping, index, end, > + PAGECACHE_TAG_DIRTY, &fbatch); > + if (!nr) > + goto out; /* No dirty pages left in the range */ > + > + for (i = 0; i < nr; i++) { > + struct folio *folio = fbatch.folios[i]; > + > + idx = 0; > + p = folio_nr_pages(folio); > +add_more: > + wdata->pages[*found_pages] = folio_page(folio, idx); > + folio_get(folio); > + if (++*found_pages == tofind) { > + folio_batch_release(&fbatch); > + goto out; > + } > + if (++idx < p) > + goto add_more; > + } > + folio_batch_release(&fbatch); > + goto again; > +out: > return wdata; > } > > -- > 2.38.1 > Could someone review this cifs patch, please? This is one of the 2 remaining patches that need to be looked at in the series.