Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp236442rwb; Thu, 12 Jan 2023 19:06:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJ7ynJt5m4DJe4jzP3hwAlq/niqMu23cFCijueDmwlIs77sOsZmBbA/kFsMKsurozLupKr X-Received: by 2002:a17:907:7707:b0:844:c651:ce4b with SMTP id kw7-20020a170907770700b00844c651ce4bmr64857250ejc.33.1673579162898; Thu, 12 Jan 2023 19:06:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673579162; cv=pass; d=google.com; s=arc-20160816; b=GACgFMQ5B3HjNjIhEKqxRuWv+LhfH2r0v/c2+GI2BNmRElqS5eoNAgLzDO5/AsQ7XM NlxP1fzk37F4xb0q6KEBdwQIi2tDUA9vx1ql4UN7mWHN+agWPEU0IGwQ7Dky/OQBCZ2+ O2UxZDLFwKphqZpCtDP8Z5365U/5XokO0pO8QeDLt14XN9G9t9lSCcWQkZ64wxMJYZOj I0vNPV0hcv8g1zS231VnTplIn8bRfmsV0tmhiHvQRJPOshn93CGiTxzU6u1r7ra35Pir Fe6aEECUZ9euR/zNpmwBbYQ6emLdWICfnH4AiEW20kbUw9XcHpQV+mszRp+s+AihZobp B5XA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:content-language:references:cc:to:subject :user-agent:date:message-id; bh=8vTBhXyIif/stiznOMHNZceBPP7AhXrVUJXFpMBI7nY=; b=lNhGX1/Ceg2aB24nrRx9Tl8v50ugDyOECHXKfWrQJ1oga3fSdQ+aBmwTmYnAxm99Nw P64iQCZg6sHxURl1fs916LgMamKAK3wW30Q1Zrpo0erx6ioqBZKa7ZPCV0pbHAB38uSx yziqhZC2wRxipPrAo19hWmLHqEWjr7xeUnJGOmVdDwDkwACPBH7bLLCpHN/LHETXNeFk 89S6f9J/K6dsArbKQOgQNRbnWPH8kFRSJ1Oj2duHaAArBklKmB4G2RK3Ta5dl9HeskNZ m3I8NnyhO60AMfY4U69L0E9KMUSXUGvGGKOBL8ojx6VutkevuGX3Kp8/SoBwCCNsiaVa 4z/Q== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=talpey.com dkim=pass dkdomain=talpey.com dmarc=pass fromdomain=talpey.com); 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc44-20020a17090716ac00b008566fec3fb8si11610373ejc.392.2023.01.12.19.05.32; Thu, 12 Jan 2023 19:06:02 -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; arc=pass (i=1 spf=pass spfdomain=talpey.com dkim=pass dkdomain=talpey.com dmarc=pass fromdomain=talpey.com); 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240290AbjAMDDr (ORCPT + 99 others); Thu, 12 Jan 2023 22:03:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240644AbjAMDDe (ORCPT ); Thu, 12 Jan 2023 22:03:34 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9B84625DF; Thu, 12 Jan 2023 19:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jja084DOvHz/ysl6drtblRoGPkerac58FjSfr5QRwAVlwwuNY7Xncux5MZZJ55R/Ta9O+KqcHTwHev6Esd1fBn3uFF+okKLkBUK69kL42NI4vxfPMyJm/BT9Xne/l+hGfeiZnM92dMimAGluE7s5Y4G2ZFnPz/zs0r22DS1WWe3mI3rNc0MclDLWEsU5q4ryNZQSmHu+YnIi65CDJzHYml8fMM19GdurQFgbvQ77TU2KZFts7CaK4gHUpZxo+jySN5vXywAxpx6WT6h04qCxF6Kjo8c5ovsmGJOD8hC0iHvyA8d8DVdg688eNxFBKi5E8NwbDxpaEF93NeCBSdi/Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8vTBhXyIif/stiznOMHNZceBPP7AhXrVUJXFpMBI7nY=; b=nfRhn1h8szrl94IYJ3gNSWNQhcQXifiKHWzdfUpVYr8oBBR5XETVQH/dCJipGP3SeZXIVlpiJWD3HUFv5swVMUh3KV5vCA+/rxc2Z9c5X8qYjsYg1fYP1YfZeQvJJuK/e/LcybG3ZR7uQw7BOPtNm7/bsIZP4/Tmp6+8gWfNHkdzs5KbA1J1w7qHUABuMSdrBosBz2lPkfdISOgIHrL228sDpQKXJ2Yjzr2EaGei91pcbV+TiUeZcl2M6KnTCe3hYFh2GsX0F6zLlHW9QM6/gfJkIRw1C71nnnUN174HAzDaRN1Dyd2aK+dPKXSV5YEpmo2Nd1hbtooh4JiOhRqEJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=talpey.com; dmarc=pass action=none header.from=talpey.com; dkim=pass header.d=talpey.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=talpey.com; Received: from SN6PR01MB4445.prod.exchangelabs.com (2603:10b6:805:e2::33) by MN0PR01MB7658.prod.exchangelabs.com (2603:10b6:208:379::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Fri, 13 Jan 2023 03:03:28 +0000 Received: from SN6PR01MB4445.prod.exchangelabs.com ([fe80::d8d6:449f:967:ccb5]) by SN6PR01MB4445.prod.exchangelabs.com ([fe80::d8d6:449f:967:ccb5%7]) with mapi id 15.20.5986.018; Fri, 13 Jan 2023 03:03:28 +0000 Message-ID: Date: Thu, 12 Jan 2023 22:03:27 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v5 09/23] cifs: Convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag() To: Vishal Moola , linux-fsdevel@vger.kernel.org, pc@cjr.nz 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 References: <20230104211448.4804-1-vishal.moola@gmail.com> <20230104211448.4804-10-vishal.moola@gmail.com> Content-Language: en-US From: Tom Talpey In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BL0PR02CA0054.namprd02.prod.outlook.com (2603:10b6:207:3d::31) To SN6PR01MB4445.prod.exchangelabs.com (2603:10b6:805:e2::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR01MB4445:EE_|MN0PR01MB7658:EE_ X-MS-Office365-Filtering-Correlation-Id: 6099c8fe-fcff-41dc-95df-08daf512bea2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ogdor07xuDclJYNPGsRbT/sz7DkjlBIprcyyJ5VDb/QP0ZSqEspkIsHjDr4O8uU89V2ODuYmhU/2S6+E/i4Be1KVoFyrrWobvpnuv2OBwE6qVoYJ64NxpC+rTQYqfIRGMR6xopiiAnahLSQdaE6pUnRBX4s6AYauPdOFzOkxhgHRoMUH/kLt5p0JFThAjFDRFA/FmI5d6RXRcyhwDB6gWCsBIIBAaSJ4d/yOP4b/DiSGzP5WUIMbAbI8qq+46oFGwfb2a7Vm89dNVkS3thQH/NGP/48HAtGgoYyRIHMUCcSq0fyPpcz7lYInM7Q1Jj9sJYMfPHUddCAU8LH6Gq1RjBkmqL8UwY0WLvW9KuwxcQoffX9x2X1EntdTCgmxOvAWik2xu8DQPM8j9qSicQxazWile3NeB9jB/sksQKGSnZ/gEUJTLgM7+svaFiV3/HvVmkd2wwzi+LUyMamL/g8NTRLKTjMEu7z8MnHtF80a/8EXO1YgWGlwHM+2Y5CUHsSk3PRHv3AxPorc/E638x5n9eLn63OfiRuLujKsV3J8VN3P2utiW1L0AlfBVHfM6wobEcj1iFjrl0S7LlRwQgUz7tIsR0vr89AirxRLIc7n0GH27q4ABpPW4P/CULFUiGKu3vdvWNJZwZqsJ6DBJNqjLH2Y6qSwlm8hHoHtqSNeJGBDNyvP6cj864OsxKPB/k1qukyWWuQsuzXKasMvdRcNMOeD6p2qMD6QMT+7Tzvm3C8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR01MB4445.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(346002)(39830400003)(136003)(366004)(396003)(451199015)(41300700001)(66556008)(4326008)(66476007)(2616005)(316002)(36756003)(66946007)(8676002)(86362001)(31696002)(38350700002)(38100700002)(5660300002)(8936002)(83380400001)(7416002)(6506007)(53546011)(31686004)(6486002)(2906002)(52116002)(26005)(478600001)(186003)(6512007)(43740500002);DIR:OUT;S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5TSTcwOWtrd1BLNkVsanNSTkM2UktQZTR6cStrOEJkOWQzdGdr?= =?utf-8?B?d3l6ay9yM0o4TG9kRDdGa01ralpOREF6RXM3NWt1ejFhdHZxQzNCUzVoZXRm?= =?utf-8?B?RTZaekQ2MDlrN0h1bXptZWFvOS9EaGNJcEptNjNMRFVITEdxZ1lEb1ExQ2Zw?= =?utf-8?B?eVpVbUxscHFFeFJ4LzFtaTdnWEw5aGpNRHM0SWNVcGxOb0RucHlMSjJ2anAw?= =?utf-8?B?K0gveGUrV3BWZ2xtS0NlbVNFaHUvMDJ3RmhqK3cxekJsNEFqVEtwVjFFVHoy?= =?utf-8?B?STNJb2crSHpBK3pUUUhka1R5YW9odlJvdUhSdnludUw1L1d3REJ3VzFHMldZ?= =?utf-8?B?YjNwYzFoc0tKWUNBYWZLazVYbWtFUXFwK3NMaDdIaTErT04vZXlnQjNUbTJE?= =?utf-8?Q?VC8wdv4CgwH55vreVT4b906hn?= X-OriginatorOrg: talpey.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6099c8fe-fcff-41dc-95df-08daf512bea2 X-MS-Exchange-CrossTenant-AuthSource: SN6PR01MB4445.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 03:03:28.6482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 2b2dcae7-2555-4add-bc80-48756da031d5 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LNK8TCcsfiAm8iJpU/mL5rmUpyOxGTchhz9GynVpwsSRFaDDa6D2It6URxWjAJxZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR01MB7658 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 This code would be a lot more readable if it had fewer goto's. The goto out's are ok but the again and add_more are easily eliminated. Two possibilities... On 1/12/2023 12:19 PM, Vishal Moola wrote: > 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; >> + This is really just the top of a while loop: while (nr = filemap_get_folios_tag(...)) { >> +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); And this is a "do {" >> +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; To here "} while (++idx < p);" >> + } >> + folio_batch_release(&fbatch); >> + goto again; End while "}" >> +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. It's otherwise ok. Tom. >