Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1232554pxb; Fri, 1 Apr 2022 08:02:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYN8+k1BORvd43TRakBanIljaUU4kG1YwRR89S7k5Ve38kWSO/gwoQFskvvIChN6JcQPdj X-Received: by 2002:a17:907:72d6:b0:6df:8b52:bb50 with SMTP id du22-20020a17090772d600b006df8b52bb50mr218578ejc.254.1648825369487; Fri, 01 Apr 2022 08:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648825369; cv=none; d=google.com; s=arc-20160816; b=Mld/JfNpU1dKB4CNs7N+VsYuPYMQ9m8yMjRFTwayrv9wRr+2HJa0Z57uCUelZ3Wxxv PLOkvL1gjFpH3M0+DlqJH3gxFSWIayBqsYXt+mXnuydOUDO4UM8IfX5JuTMktMPS2BS2 wcFQvAkrk+F3eJa59DmL9UIrkOuANgeObGeIDQ6Gk0mmEnh3Pu+8hymcs5WEIAmB3ZuT sCDiFwy1PDb8rXU72e+CkAJGHPsC9JStwFfQL0kkQt0AekAHG43uaIyOI6YIB3PfFHt8 OJT7+0lgnx0MmDMp9Yae9CLc7mQdc3O3BpIoNv7f4AyqF9xCIiKuMYSSuth1UanDwH4s PwOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=pPs7BScwn3Gb8H8NTJQGKbvPx9S/Gi0731uzRmABSCY=; b=g1XirRI9uwZgzdZJm3izKUCYSagyhJ5OQX4gFEQUJl8jgrroo1aZIO+JXB5bJF2km7 vVJIebvpMU2gMCuIIpwJYNAT2zW7dn4ZngzzHF/YE9aOKw8BLLxg14uS1uPHhelVx1ci Xj1tfKqhZSG6kysX4cCaD2A7depH1R3m2ai4dOs42w8fJ+dbq7yUXufdyDJ5Eb/a0gGh XABKbP6YSemUOzLOZ4e/ZnnFbjfsUwhg8ST4CLP7CJJmTQTnsfU4ty001I3BqmCCcrir uWfIBRXR1qUdcYxBbqdVV9UZ6rF+ywnGO0H2CXKGVe2qF9v0LwtTtiZuiogRrxvdquWT jOYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=y8uvKwYo; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=4Pr7CWms; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv21-20020a170906b1d500b006df76385d3csi1762473ejb.476.2022.04.01.08.02.21; Fri, 01 Apr 2022 08:02:49 -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=@suse.cz header.s=susede2_rsa header.b=y8uvKwYo; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=4Pr7CWms; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231144AbiCaRbt (ORCPT + 99 others); Thu, 31 Mar 2022 13:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230455AbiCaRbs (ORCPT ); Thu, 31 Mar 2022 13:31:48 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 762FA16F6E3; Thu, 31 Mar 2022 10:30:00 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3074A210FC; Thu, 31 Mar 2022 17:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1648747799; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pPs7BScwn3Gb8H8NTJQGKbvPx9S/Gi0731uzRmABSCY=; b=y8uvKwYoylti0qC/RmSlDN7zerCQLiLvaPXL7Hc+AZ0OsgPnywn8UpiyTB5RfWRKAyv7dr YPcPzNOkmEF1+BN2en8M0Zd9hAJpCqaoc85FrQ1GvuvCBQOkyw4x3ex9gO0EjCD9y7qwDI XWjOPKAEJv6N1Gw7kMTb8WYjya28xFI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1648747799; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pPs7BScwn3Gb8H8NTJQGKbvPx9S/Gi0731uzRmABSCY=; b=4Pr7CWms7CFD3QZwqTbsGnC5lIB4d4CTJzmgcn/SMhA3IhsLZJEMiSv+kywgGJiZlSKlRv mczrRCbZqcY7duCg== Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 255E0A3B92; Thu, 31 Mar 2022 17:29:59 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 8E11DDA7F3; Thu, 31 Mar 2022 19:26:00 +0200 (CEST) Date: Thu, 31 Mar 2022 19:26:00 +0200 From: David Sterba To: Sweet Tea Dorminy Cc: Chris Mason , Josef Bacik , David Sterba , Nick Terrell , linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, kernel-team@fb.com, Nikolay Borisov Subject: Re: [PATCH v3 1/2] btrfs: factor out allocating an array of pages Message-ID: <20220331172600.GE15609@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Sweet Tea Dorminy , Chris Mason , Josef Bacik , David Sterba , Nick Terrell , linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, kernel-team@fb.com, Nikolay Borisov References: <3feb62bb8e605e708a0f839136a7354ec66b7b6b.1648669832.git.sweettea-kernel@dorminy.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3feb62bb8e605e708a0f839136a7354ec66b7b6b.1648669832.git.sweettea-kernel@dorminy.me> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On Wed, Mar 30, 2022 at 04:11:22PM -0400, Sweet Tea Dorminy wrote: > +/** > + * Populate every slot in a provided array with pages. > + * > + * @nr_pages: the number of pages to request > + * @page_array: the array to fill with pages; any existing non-null entries in > + * the array will be skipped > + * > + * Return: 0 if all pages were able to be allocated; -ENOMEM otherwise, and the > + * caller is responsible for freeing all non-null page pointers in the array. > + */ > +int btrfs_alloc_page_array(unsigned long nr_pages, struct page **page_array) I've switched nr_pages to 'unsigned int', that's what all callers use and I don't see a reason for long. > +{ > + int i; > + > + for (i = 0; i < nr_pages; i++) { > + struct page *page; > + > + if (page_array[i]) > + continue; > + page = alloc_page(GFP_NOFS); > + if (!page) > + return -ENOMEM; > + page_array[i] = page; > + } > + return 0; > +}